Asterisk Admin Guide PDF
Asterisk Admin Guide PDF
1. Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.1 Precursors, Background and Business . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.1.1 Asterisk Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.2 Beginning Asterisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1.2.1 Installing Asterisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.2.2 Asterisk Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 1.2.3 Basic PBX Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 1.2.4 Dialplan Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 1.2.5 Auto-attendant and IVR Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 1.2.6 Dialplan Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 1.2.7 Installing Asterisk From Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 1.2.8 Getting Started with Asterisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 1.2.9 Asterisk Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 1.2.10 Asterisk on (Open)Solaris . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 2. Configuration and Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 2.1 Asterisk Calendaring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 2.1.1 Configuring Asterisk Calendaring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 2.1.2 Calendaring Dialplan Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 2.1.3 Calendaring Dialplan Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 2.2 Asterisk Channel Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 2.2.1 Inter-Asterisk eXchange protocol, version 2 (IAX2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 2.2.2 mISDN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 2.2.3 Local Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 2.2.4 Mobile Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 2.2.5 Unistim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 2.2.6 Skinny . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 2.3 Asterisk Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 2.3.1 General Configuration Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 2.3.2 Database Support Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 2.3.3 Privacy Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 2.4 Asterisk Extension Language (AEL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 2.4.1 Introduction to AEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 2.4.2 AEL and Asterisk in a Nutshell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 2.4.3 Getting Started with AEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 2.4.4 AEL Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 2.4.5 About "aelparse" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 2.4.6 General Notes about AEL Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 2.4.7 AEL Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 2.4.8 AEL Procedural Interface and Internals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 2.4.9 AEL Example Usages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 2.4.10 AEL Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 2.4.11 AEL Semantic Checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 2.4.12 Differences with the original version of AEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 2.4.13 AEL Hints and Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 2.4.14 The Full Power of AEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 2.5 Asterisk Manager Interface (AMI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 2.5.1 The Asterisk Manager TCP IP API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 2.5.2 AMI Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 2.5.3 AMI Manager Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 2.5.4 AMI Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 2.5.5 Ensuring all modules are loaded with AMI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 2.5.6 Device Status Reports with AMI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 2.5.7 Some Standard AMI Headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 2.5.8 Asynchronous Javascript Asterisk Manger (AJAM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 2.6 Asterisk Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 2.6.1 Configuring Call Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 2.6.2 Queue Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 2.7 Asterisk Security Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 2.7.1 Security Framework Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 2.7.2 Security Event Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 2.7.3 Asterisk Security Event Logger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
2.7.4 Security Events to Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.7.5 Security Log File Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8 Asterisk Sounds Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8.1 Getting the Sounds Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.8.2 About the Sounds Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.9 Call Completion Supplementary Services (CCSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.9.1 CCSS Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.9.2 The Call Completion Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.9.3 Call Completion Info and Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.9.4 Generic Call Completion Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.10 Call Detail Records (CDR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.10.1 CDR Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.10.2 CDR Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.10.3 CDR Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.10.4 CDR Storage Backends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.11 Calling using Google . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.12 Channel Event Logging (CEL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.12.1 CEL Design Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.12.2 CEL Events and Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.12.3 CEL Applications and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.12.4 CEL Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.12.5 Generating Billing Information from CEL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.12.6 CEL Storage Backends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13 Channel Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13.1 Parameter Quoting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13.2 About Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13.3 Variable Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13.4 Selecting Characters from Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13.5 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13.6 Asterisk Standard Channel Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.13.7 Case Sensitivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.14 Distributed Universal Number Discovery (DUNDi) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.14.1 Introduction to DUNDi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.14.2 DUNDIQUERY and DUNDIRESULT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.14.3 DUNDi Peering Agreement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.15 E.164 NUmber Mapping (ENUM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.15.1 The ENUMLOOKUP Dialplan Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.1 Asterisk Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.2 Asterisk Call Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.3 Asterisk Command Line Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.4 Asterisk Manager Interface (AMI) Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.5 Building Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.6 Call Completion Supplementary Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.7 Call Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.8 Channel Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.9 Corosync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.10 Database Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.11 Distributed Device State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.12 DUNDi - Distributed Universal Number Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.13 External IVR Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.14 Followme - Realtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.15 IAX2 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.16 LDAP Realtime Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.17 Open Settlement Protocol (OSP) User Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.18 PSTN Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.19 Real-time Text (T.140) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.20 RTP Packetization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.21 Simple Message Desk Interface (SMDI) Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.22 Simple Network Management Protocol (SNMP) Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.23 SIP Retransmissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
304 305 307 308 309 310 311 312 314 316 317 318 319 320 321 332 336 337 347 349 352 353 354 364 365 366 367 369 370 384 400 402 403 404 405 410 411 419 420 425 427 428 437 452 453 454 455 458 459 472 480 483 484 490 492 509 517 518 520 523 535
2.16.24 SIP TLS Transport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.25 Speech Recognition API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.26 SQLite Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.27 Storing Voicemail in PostgreSQL via ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.28 Timing Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.29 Using the Hoard Memory Allocator with Asterisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.30 Video Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.16.31 Video Telephony . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.17 Lua Dialplan Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.17.1 Dialplan to Lua Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.17.2 Interacting with Asterisk from Lua (apps, variables, and functions) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.17.3 Lua Dialplan Tips and Tricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.17.4 Lua Dialplan Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.17.5 Lua Dialplan Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.17.6 Advanced pbx_lua Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.18 Manipulating Party ID Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.19 Packet Loss Concealment (PLC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.19.1 PLC Background on Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.19.2 PLC Restrictions and Caveats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.19.3 Requirements for PLC Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.19.4 PLC Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.20 Phone Provisioning in Asterisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.20.1 Configuration of phoneprov.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.20.2 Creating Phone Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.20.3 Configuration of users.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.20.4 Phone Provisioning Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.20.5 Phone Provisioning, Putting it all together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.21 Reference Information Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.21.1 License Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.21.2 Important Security Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.21.3 Telephony Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.22 Secure Calling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.22.1 Secure Calling Specifics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.22.2 Secure Calling Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.23 Shared Line Appearances (SLA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.23.1 Introduction to Shared Line Appearances (SLA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.23.2 SLA Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.23.3 SLA Configuration Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.23.4 SLA and Call Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.24 Short Message Service (SMS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.24.1 Introduction to SMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.24.2 SMS and extensions.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.24.3 SMS Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.24.4 SMS Delivery Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.24.5 SMS File Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.24.6 SMS Sub Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.24.7 SMS Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.24.8 SMS Typical Use with Asterisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.24.9 Using SMSq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.25 Voicemail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.25.1 ODBC Voicemail Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.25.2 IMAP Voicemail Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.26 Asterisk SIP Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.27 Asterisk GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.28 Historical Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.28.1 Jabber in Asterisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.28.2 Old Calling using Google . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3. Asterisk Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4. Asterisk Module Support States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5. Asterisk Issue Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6. Asterisk Community . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
537 539 544 547 554 556 557 560 561 562 567 569 571 572 574 576 581 582 583 584 585 586 587 588 589 590 591 592 593 595 600 605 606 607 613 614 615 620 624 629 630 631 632 633 634 635 636 637 638 640 641 642 650 651 655 656 658 662 664 669 675
6.1 Asterisk Community Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2 Community Services Signup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3 IRC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.4 Mailing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Getting Started
A Beginners Guide to Asterisk. Herein, you will find content related to installing Asterisk and basic usage concepts.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Asterisk Concepts
Asterisk is a very large application that does many things. It can be somewhat difficult to understand, especially if you are new to communications technologies. In the next few chapters we will do our best to explain what Asterisk is, what it is not, and how it came to be this way. This section doesn't cover the technology so much as the concept. If you're already familiar with the function of a telephony engine, feel free to jump ahead to the next section.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
<html> <head> <title>Hello World Demo</title> </head> <body> <h1>Hello World!</h1> </body> </html>
The following Dialplan script answers the phone, waits for one second, plays back "hello world" then hangs up.
In both cases the server components are handling all of the low level details of the underlying protocols. Your application doesn't have to worry about the byte alignment, the packet size, the codec or any of the thousands of other critical details that make the application work. This is the power of an engine. Who Uses Asterisk? Asterisk is created by communication system developers, for communication system developers. As an open source project, Asterisk is a collaboration between many different individuals and companies, all of which need a flexible communications engine to power their applications.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
10
Beginning Asterisk
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
11
Installing Asterisk
Now that you know a bit about Asterisk and how it is used, it's time to get you up and running with your own Asterisk installation. There are various ways to get started with Asterisk on your own system:
Install an Asterisk-based Linux distribution such as AsteriskNOW. This takes care of installing Linux, Asterisk, and some web-based interfaces all at the same time, and is the easiest way to get started if you're new to Linux and/or Asterisk. If you're already familiar with Linux or Unix, you can simply install packages for Asterisk and its related tools using the package manager in your operating system. We'll cover this in more detail below in Alternate Install Methods. For the utmost in control of your installation, you can compile and install Asterisk (and its related tools) from source code. We'll explain how to do this in Installing Asterisk From Source.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
12
Installing AsteriskNOW
Thank you for downloading AsteriskNOW. This Linux distribution has been carefully customized and tested with Asterisk, and installs all of the packages needed for its use. It is the officially recommended development and runtime platform for Asterisk and Digium hardware, including Digium phones. This guide provides a brief overview of installation, configuration, and maintenance of your system. More information is available at http://wiki.centos.org/. Please report any bugs at https://issues.asterisk.org/jira
Installation
Burn the AsteriskNOW DVD image to DVD disc and then boot from the DVD to begin the installation process. If you are unfamiliar with burning disc images, the Ubuntu community has a great Burning ISO Howto available at https://help.ub untu.com/community/BurningIsoHowto. If you are unfamiliar with booting to DVD, the Ubuntu community has a wonderful Boot From DVD HOWTO available at https://he lp.ubuntu.com/community/BootFromCD. After booting from the AsteriskNOW DVD, you will be presented with the following screen and options for an installation with, or without the FreePBX web interface. This QuickStart assumes that the FreePBX web interface has been installed. To do this, selection option 1 and press <ENTER>:
During the installation, you are first presented with an option for setting the system Time Zone:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
13
** Choose the location that is nearest to you and move to the next screen. Next, you will be prompted to set a root password:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
14
The 'root' user is the administrative account for Linux systems. Most system configuration requires 'root' access. If this password is lost, it is impossible to recover. It is recommend that your password contain a mix of lowercase and UPPERCASE letters, numbers, and/or symbols. Or, if you're into entropy, try a pass phrase.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
15
It is recommended to select "Use All Space" and move to the next screen.
Now, sit back, relax, have a cup of coffee and wait while the system is installed. This will take approximately 15-30 minutes. You will see a progress bar indicating the installation status.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
16
Once installation has completed, you will be prompted to reboot into your installation:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
17
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
18
Notice the text that says "To configure AsteriskNOW with FreePBX, point your web browser to http://xx.xx.xx.xx/." Write this down, you will need it in the next section.
Now, before you move on, it is important to update your AsteriskNOW system to the latest Linux packages. To do this, use the yum utility "yum." Perform a "yum update"
** If new packages are available for installation, the utility will ask permission to install them. And, if the utility has not been run before, it may ask permission to accept a yum key. You should accept both to stay up to date. You are now ready to move on to configuration of AsteriskNOW from the FreePBX web interface.
FreePBX Configuration
To configure your system using FreePBX, open a web browser on another PC to the address specified during boot, e.g. "To configure AsteriskNOW with FreePBX, point your web browser to http://xx.xx.xx.xx/. If successful, you will be presented with the FreePBX main screen:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
19
From here, we want the "FreePBX Administration" link. Click it, and you will see the FreePBX login screen:
Having successfully logged into FreePBX, you will see the FreePBX dashboard:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
20
Notice the Red reload button. It will appear after changes are made to any page. If you see it, it should be clicked, it will affect any changes on the system that FreePBX needs to make. This guide assumes that whenever you see it, you will click it.
Next, we will change the default admin password. This is imperative! Failure to do this is inviting disaster. The importance of doing this C ANNOT be understated. First, visit the Admin tool
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
21
Finally, one should update any out of date modules on the system. To do this, we will visit the Module Admin tool:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
22
Click the Check Online button and you will see any out of date modules
To update a module, click it, and then select the Download option
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
23
Finally, press the Process button and follow the instructions to complete the module update.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
24
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
25
If the command returns nothing, then DAHDI has not been started. Start DAHDI by running:
[root@server asterisk-1.6.X.Y]# service dadhi start
If you have DAHDI running, the output of lsmod | grep dahdi should look something like the output below. (The exact details may be different, depending on which DAHDI modules have been built, and so forth.)
[root@server ~]# lsmod | grep dahdi dahdi_dummy dahdi_transcode dahdi_voicebus dahdi crc_ccitt 4288 7928 40464 0 1 wctc4xxp 2 wctdm24xxp,wcte12xp
Now that DAHDI is running, you can run dahdi_hardware to list any DAHDI-compatible devices in your system. You can also run the dahdi_tool utility to show the various DAHDI-compatible devices, and their current state. To check if Asterisk is running, you can use the Asterisk initscript.
[root@server ~]# service asterisk status asterisk is stopped
To start Asterisk, we'll use the initscript again, this time giving it the start action:
[root@server ~]# service asterisk start Starting asterisk:
When Asterisk starts, it runs as a background service (or daemon), so you typically won't see any response on the command line. We can check the status of Asterisk and see that it's running by using the command below. (The process identifier, or pid, will obviously be different on your system.)
[root@server ~]# service asterisk status asterisk (pid 32117) is running...
And there you have it... you have an Asterisk system up and running! You should now continue on in Section 202. Getting Started with Asterisk.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
26
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
27
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
28
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
29
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
30
Objects
Some Asterisk configuration files also create objects. The syntax for objects is slightly different than for settings. To create an object, you specify the type of object, an arrow formed by the equals sign and a greater-than sign (=>), and the settings for that object.
Confused by Object Syntax? In order to make life easier for newcomers to the Asterisk configuration files, the developers have made it so that you can also create objects with an equal sign. Thus, the two lines below are functionally equivalent.
some_object => settings some_object=settings
It is common to see both versions of the syntax, especially in online Asterisk documentation and examples. This book, however, will denote objects by using the arrow instead of the equals sign.
[section-name] label1=value1 label2=value2 object1 => name1 label1=value0 label3=value3 object2 => name2
In this example, object1 inherits both label1 and label2. It is important to note that object2 also inherits label2, along with label1 (with the new overridden value value0) and label3. In short, objects inherit all the settings defined above them in the current section, and later settings override earlier settings.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
31
Comments
We can (and often do) add comments to the Asterisk configuration files. Comments help make the configuration files easier to read, and can also be used to temporarily disable certain settings.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
32
[section-name] setting=true [another_section] setting=false ; this is a comment ; this entire line is a comment ;awesome=true ; the semicolon on the line above makes it a ; comment, disabling the setting
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
33
Block Comments
Asterisk also allows us to create block comments. A block comment is a comment that begins on one line, and continues for several lines. Block comments begin with the character sequence
--;
is encountered. The block comment ends immediately after --; is encountered.
[section-name] setting=true ;-- this is a block comment that begins on this line and continues across multiple lines, until we get to here --;
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
34
Enabling #exec Functionality The #exec construct is not enabled by default, as it has some risks both in terms of performance and security. To enable this functionality, go to the asterisk.conf configuration file (by default located in /etc/asterisk) and set execincludes=yes in the [options] section. By default both the [ options] section heading and the execincludes=yes option have been commented out, you you'll need to remove the semicolon from the beginning of both lines.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
35
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
36
Templates
Another construct we can use within most Asterisk configuration files is the use of templates. A template is a section of a configuration file that is only used as a base (or template, as the name suggests) to create other sections from.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
37
Template Syntax
To define a section as a template, place an exclamation mark in parentheses after the section heading, as shown in the example below.
[template-name](!) setting=value
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
38
Using Templates
To use a template when creating another section, simply put the template name in parentheses after the section heading name, as shown in the example below. If you want to inherit from multiple templates, use commas to separate the template names).
[test-one](!) permit=192.168.0.2 host=alpha.example.com deny=192.168.0.1 [test-two](!) permit=192.168.1.2 host=bravo.example.com deny=192.168.1.1 [test-three](test-one,test-two) permit=192.168.3.1 host=charlie.example.com
The [test-three] section will be processed as though it had been written in the following way:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
39
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
40
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
41
[demo-alice] type=friend host=dynamic secret=verysecretpassword ; put a strong, unique password here instead context=users deny=0.0.0.0/0 permit=192.168.5.0/255.255.255.0 ; replace with your network settings [demo-bob] type=friend host=dynamic secret=othersecretpassword ; put a strong, unique password here instead context=users deny=0.0.0.0/0 permit=192.168.5.0/255.255.255.0 ; replace with your network settings
Be Serious About Account Security We can't stress enough how important it is for you to pick a strong password for all accounts on Asterisk, and to only allow access from trusted networks. Unfortunately, we've found many instances of people exposing their Asterisk to the internet at large with easily-guessable passwords, or no passwords at all. You could be at risk of toll fraud, scams, and other malicious behavior. For more information on Asterisk security and how you can protect yourself, check out http://www.asterisk.org/security/webinar/.
After adding the two sections above to your sip.conf file, go to the Asterisk command-line interface and run the sip reload command to tell Asterisk to re-read the sip.conf configuration file.
server*CLI> sip reload Reloading SIP server*CLI>
Reloading Configuration Files Don't forget to reload the appropriate Asterisk configuration files after you have made changes to them.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
42
Registrar/Registration Server - The location of the server which the phone should register to. This should be set to the IP address of your Asterisk system. *SIP User Name/Account Name/Address - *The SIP username on the remote system. This should be set to demo-alice on one phone and demo-bob on the other. This username corresponds directly to the section name in square brackets in sip.conf. SIP Authentication User/Auth User - On Asterisk-based systems, this will be the same as the SIP user name above. Proxy Server/Outbound Proxy Server - This is the server with which your phone communicates to make outside calls. This should be set to the IP address of your Asterisk system.
You can tell whether or not your phone has registered successfully to Asterisk by checking the output of the sip show peers command at the Asterisk CLI. If the Host column says (Unspecified), the phone has not yet registered. On the other hand, if the Host column contains an IP address and the Dyn colum n contains the letter D, you know that the phone has successfully registered.
server*CLI> sip show peers Name/username Host Dyn NAT ACL Port Status demo-alice (Unspecified) D A 5060 Unmonitored demo-bob 192.168.5.105 D A 5060 Unmonitored 2 sip peers [Monitored: 0 online, 0 offline Unmonitored: 2 online, 0 offline]
In the example above, you can see that Alice's phone has not registered, but Bob's phone has registered.
Debugging SIP Registrations If you're having troubles getting a phone to register to Asterisk, make sure you watch the Asterisk CLI with the verbosity level set to at least three while you reboot the phone. You'll likely see error messages indicating what the problem is, like in this example:
NOTICE[22214]: chan_sip.c:20824 handle_request_register: Registration from '"Alice" <sip:[email protected]>' failed for '192.168.5.103' - Wrong password
As you can see, Asterisk has detected that the password entered into the phone doesn't match the secret setting in the [demo-alice] section of sip.conf.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
43
What is an Extension? When dealing with Asterisk, the term extension does not represent a physical device such as a phone. An extension is simply a set of actions in the dialplan which may or may not write a physical device. In addition to writing a phone, an extensions might be used for such things auto-attendant menus and conference bridges. In this guide we will be careful to use the words phone or device when referring to the physical phone, and extension when referencing the set of instructions in the Asterisk dialplan.
Let's take a quick look at the dialplan, and then add two extensions. Open extensions.conf, and take a quick look at the file. Near the top of the file, you'll see some general-purpose sections named [general] and [globals]. Any sections in the dialplan beneath those two sections is known as a context. The sample extensions.conf file has a number of other contexts, with names like [demo] and [default]. We'll cover contexts more in Dialplan Fundamentals, but for now you should know that each phone or outside connection in Asterisk points at a single context. If the dialed extension does not exist in the specified context, Asterisk will reject the call. Go to the bottom of your extensions.conf file, and add a new context named [users]. Naming Your Dialplan Contexts There's nothing special about the name users for this context. It could have been named strawberry_milkshake, and it would have behaved exactly the same way. It is considered best practice, however, to name your contexts for the types of extensions that are contained in that context. Since this context contains extensions for the users of our PBX system, we'll call our context users. Underneath that context name, we'll create an extesion numbered 6001 which attempts to ring Alice's phone for twenty seconds, and an extension 6002 wh ich attempts to rings Bob's phone for twenty seconds.
[pbx_config] [pbx_config]
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
44
As you can see, Alice called extension 6002 in the [users] context, which in turn used the Dial application to call Bob's phone. Bob's phone rang, and then answered the call. Asterisk then bridged the two calls (one call from Alice to Asterisk, and the other from Asterisk to Bob), until Alice hung up the phone. At this point, you have a very basic PBX. It has two extensions which can dial each other, but that's all. Before we move on, however, let's review a few basic troubleshooting steps that will help you be more successful as you learn about Asterisk.
Basic PBX Troubleshooting The most important troubleshooting step is to set your verbosity level to three (or higher), and watch the command-line interface for errors or warnings as calls are placed. To ensure that your SIP phones are registered, type sip show peers at the Asterisk CLI. To see which context your SIP phones will send calls to, type sip show users. To ensure that you've created the extensions correctly in the [users] context in the dialplan, type dialplan show users. To see which extension will be executed when you dial extension 6002, type dialplan show 6002@users.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
45
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
46
Dialplan Fundamentals
The dialplan is essential to the operation of any successful Asterisk system. In this module, we'll help you learn the fundamental components of the Asterisk dialplan, and how to combine them to begin scripting your own dialplan. We'll also add voice mail and a dial-by-name directory features to your dialplan.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
47
[users]
Within each context, we can define one or more extensions. As explained in the previous module, an extension is simply a named set of actions. Asterisk will perform each action, in sequence, when that extension number is dialed. The syntax for an extension is:
Priority numbers Priority numbers must begin with 1, and must increment sequentially. If Asterisk can't find the next priority number, it will terminate the call. We call this auto-fallthrough. Consider the example below:
exten => 6123,1,do something exten => 6123,2,do something else exten => 6123,4,do something different
In this case, Asterisk would execute priorites one and two, but would then terminate the call, because it couldn't find priority number three.
Priority number can also be simplied by using the letter n in place of the priority numbers greater than one. The letter n stands for next, and when Asterisk sees priority n it replaces it in memory with the previous priority number plus one. Note that you must still explicitly declare priority number one.
exten => 6123,1,do something exten => 6123,n,do something else exten => 6123,n,do something different
You can also assign a label (or alias) to a particular priority number by placing the label in parentheses directly after the priority number, as shown below. Labels make it easier to jump back to a particular location within the extension at a later time.
exten => 6123,1,do something exten => 6123,n(repeat),do something else exten => 6123,n,do something different
Here, we've assigned a label named repeat to the second priority. Included in the Asterisk 1.6.2 branch (and later) there is a way to avoid having to repeat the extension name/number or pattern using the same => prefix.
exten => _1NXXNXXXXXX,1,do something same => n(repeat),do something else same => n,do something different
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
48
Applications
Each priority in the dialplan calls an application. An application does some work on the channel, such as answering a call or playing back a sound prompt. There are a wide variety of dialplan applications available for your use. For a complete list of the dialplan applications available to your installation of Asterisk, type core show applications at the Asterisk CLI. Most applications take one or more parameters, which provide additional information to the application or change its behavior. Parameters should be separated by commas.
Syntax for Parameters You'll often find examples of Asterisk dialplan code online and in print which use the pipe character or vertical bar character (|) between parameters, as shown in this example:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
49
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
50
In the example above, we start an early media call which waits for a second and then plays a rather rudely named message indicating that the requested service has closed for whatever reason before hanging up. It is worth observing that the Playback application is called with the 'noanswer' argument. Without that argument, Playback would automatically answer the call and then we would no longer be in early media mode. Strictly speaking, Asterisk will send audio via RTP to any device that calls in regardless of whether Asterisk ever answers or progresses the call. It is possible to make early media calls to some devices without ever sending the progress message, however this is improper and can lead to a myriad of nasty issues that vary from device to device. For instance, in internal testing, there was a problem reported against the Queue application involving the following extension:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
51
Sound Prompt Formats Sound prompts come in a variety of file formats, such as .wav and .ulaw files. When asked to play a sound prompt from disk, Asterisk plays the sound prompt with the file format that can most easily be converted to the CODEC of the current call. For example, if the inbound call is using the alaw CODEC and the sound prompt is available in .gsm and .ulaw format, Asterisk will play the .ulaw file because it requires fewer CPU cycles to transcode to the alaw CODEC. You can type the command core show translation at the Asterisk CLI to see the transcoding times for various CODECs. The times reported (in Asterisk 1.6.0 and later releases) are the number of microseconds it takes Asterisk to transcode one second worth of audio. These times are calculated when Asterisk loads the codec modules, and often vary slightly from machine to machine. To perform a current calculation of translation times, you can type the command core show translation recalc 60.
How Asterisk Searches for Sound Prompts Based on Channel Language Each channel in Asterisk can be assigned a language by the channel driver. The channel's language code is split, piece by piece (separated by underscores), and used to build paths to look for sound prompts. Asterisk then uses the first file that is found. This means that if we set the language to en_GB_female_BT, for example, Asterisk would search for files in: .../sounds/en/GB/female/BT .../sounds/en/GB/female .../sounds/en/GB .../sounds/en .../sounds This scheme makes it easy to add new sound prompts for various language variants, while falling back to a more general prompt if there is no prompt recorded in the more specific variant. The Hangup() application hangs up the current call. While not strictly necessary due to auto-fallthrough (see the note on Priority numbers above), in general we recommend you add the Hangup() application as the last priority in any extension. Now let's put Answer(), Playback(), and Hangup() together to play a sample sound file. Place this extension in your [docs:users] context:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
52
Dial Application
Now that you've learned the basics of using dialplan applications, let's take a closer look at the Dial() application that we used earlier in extensions 6001 an d 6002. Dial() attempts to ring an external device, and if the call is answered it bridges the two channels together and does any necessary protocol or CODEC conversion. It also handles call progress responses (busy, no-answer, ringing).
Dial() and the Dialplan Please note that if the Dial() application successfully bridges two channels together, that the call does not progress in the dialplan. The call will only continue on to the next priority if the Dial() application is unable to bridge the calling channel to the dialed device.
1. Devices A list of the device(s) you want to call. Devices are specified as technology or channel driver, a forward slash, and the device or account name. For example, SIP/demo-alice would use the SIP channel driver to call the device specified in the demo-alice sec tion of sip.conf. Devices using the IAX2 channel driver take the form of IAX2/demo-george, and DAHDI channels take the form of DAHDI/1. When calling through a device (such as a gateway) or service provider to reach another number, the syntax is technology/devic e/number such as SIP/my_provider/5551212 or DAHDI/4/5551212. To dial multiple devices at once, simply concatenate the devices together whith the ampersand character (&). The first device to answer will get bridged with the caller, and the other endpoints will stop ringing.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
53
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
54
VoiceMail Application
The VoiceMail() applications takes two parameters:
1. Mailbox This parameter specifies the mailbox in which the voice mail message should be left. It should be a mailbox number and a voice mail context concatenated with an at-sign (@), like 6001@default. (Voice mail boxes are divided out into various voice mail context, similar to the way that extensions are broken up into dialplan contexts.) If the voice mail context is omitted, it will default to the default voice mail context. 2. Options One or more options for controlling the mailbox greetings. The most popular options include the u option to play the unavailable message, the b option to play the busy message, and the s option to skip the system-generated instructions.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
55
VoiceMailMain Application
The VoiceMailMain() application allows the owner of a voice mail box to retrieve their messages, as well as set mailbox options such as greetings and their PIN number. The VoiceMailMain() application takes two parameters:
1. Mailbox - This parameter specifies the mailbox to log into. It should be a mailbox number and a voice mail context, concatenated with an at-sign (@), like 6001@default. If the voice mail context is omitted, it will default to the default voice mail context. If the mailbox number is omitted, the system will prompt the caller for the mailbox number. 2. Options - One or more options for controlling the voicemail system. The most popular option is the s option, which skips asking for the PIN number
Direct Access to Voice mail Please exercise extreme caution when using the s option! With this option set, anyone which has access to this extension can retrieve voicemail messages without entering the mailbox passcode.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
56
server*CLI> voicemail reload Reloading voicemail configuration... server*CLI> voicemail show users Context Mbox User default general New User default 1234 Example Mailbox other 1234 Company2 User vm-demo 6001 Alice Jones vm-demo 6002 Bob Smith 5 voicemail users configured.
Zone
central eastern
NewMsg 0 0 0 0 0
Now that we have mailboxes defined, let's add a priority to extensions 6001 and 6002 which will allow callers to leave voice mail in their respective mailboxes. We'll also add an extension 6500 to allow Alice and Bob to check their voicemail messages. Please modify your [users] context in extensions. conf to look like the following:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
57
[users] exten => 6000,1,Answer(500) exten => 6000,n,Playback(hello-world) exten => 6000,n,Hangup() exten => 6001,1,Dial(SIP/demo-alice,20) exten => 6001,n,VoiceMail(6001@vm-demo,u) exten => 6002,1,Dial(SIP/demo-bob,20) exten => 6002,n,VoiceMail(6002@vm-demo,u) exten => 6500,1,Answer(500) exten => 6500,n,VoiceMailMain(@vm-demo)
Reload the dialplan by typing dialplan reload at the Asterisk CLI. You can then test the voice mail system by dialing from one phone to the other and waiting twenty seconds. You should then be connected to the voicemail system, where you can leave a message. You should also be able to dial extension 6500 to retrieve the voicemail message. When prompted, enter the mailbox number and PIN number of the mailbox. While in the VoiceMainMain() application, you can also record the mailbox owner's name, unavailable greeting, and busy greeting by pressing 0 at the voicemail menu. Please record at least the name greeting for both Alice and Bob before continuing on to the next section. Go into lots of detail about the voicemail interface? How to move between messages, move between folders, forward messages, etc?
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
58
Directory Application
The next application we'll cover is named Directory(), because it presents the callers with a dial-by-name directory. It asks the caller to enter the first few digits of the person's name, and then attempts to find matching names in the specified voice mail context in voicemail.conf. If the matching mailboxes have a recorded name greeting, Asterisk will play that greeting. Otherwise, Asterisk will spell out the person's name letter by letter.
Directory([voicemail_context,[dialplan_context,[options]]])
The Directory() application takes three parameters: voicemail_context This is the context within voicemail.conf in which to search for a matching directory entry. If not specified , the [docs:default] context will be searched. dialplan_context When the caller finds the directory entry they are looking for, Asterisk will dial the extension matching their mailbox in this context. options A set of options for controlling the dial-by-name directory. Common options include f for searching based on first name instead of last name and e to read the extension number as well as the name.
Directory() Options To see the complete list of options for the Directory() application, type core show application Directory at the Asterisk CLI.
Let's add a dial-by-name directory to our dialplan. Simply add this line to your [docs:users] context in extensions.conf:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
59
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
60
Multiple Prompts If you have multiple prompts you'd like to play during the Background() application, simply concatenate them together with the ampersand (&) character, like this:
One problems you may encounter with the Background() application is that you may want Asterisk to wait a few more seconds after playing the sound prompt. In order to do this, you can call the WaitExten() application. You'll usually see the WaitExten() application called immediately after the Backgroun d() application. The first parameter to the WaitExten() application is the number of seconds to wait for the caller to enter an extension. If you don't supply the first parameter, Asterisk will use the built-in response timeout (which can be modified with the TIMEOUT() dialplan function).
[auto_attendant] exten => start,1,Verbose(2,Incoming call from ${CALLERID(all)}) same => n,Playback(silence/1) same => n,Background(prompt1&prompt2&prompt3) same => n,WaitExten(10) same => n,Goto(timeout-handler,1) exten => timeout-handler,1) same => n,Dial(${GLOBAL(OPERATOR)},30) same => n,Voicemail(operator@default,${IF($[${DIALSTATUS} = BUSY]?b:u)}) same => n,Hangup()
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
61
[StartingContext] exten => 100,1,Goto(monkeys) same => n,NoOp(We skip this) same => n(monkeys),Playback(tt-monkeys) same => n,Hangup() exten => 200,1,Goto(start,1) ; play tt-weasels then tt-monkeys
exten => 300,1,Goto(start,monkeys) ; only play tt-monkeys exten => 400,1,Goto(JumpingContext,start,1) exten => start,1,NoOp() same => n,Playback(tt-weasels) same => n(monkeys),Playback(tt-monkeys) [JumpingContext] exten => start,1,NoOp() same => n,Playback(hello-world) same => n,Hangup() ; play hello-world
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
62
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
63
Sample Sound Prompts Please note that the example below (and many of the other examples in this guide) use sound prompts that are part of the extra sounds packages. If you didn't install the extra sounds earlier, now might be a good time to do that.
[demo-menu] exten => s,1,Answer(500) same => n(loop),Background(press-1&or&press-2) same => n,WaitExten() exten => 1,1,Playback(you-entered) same => n,SayNumber(1) same => n,Goto(s,loop) exten => 2,1,Playback(you-entered) same => n,SayNumber(2) same => n,Goto(s,loop)
Before we can use the demo menu above, we need to add an extension to the [docs:users] context to redirect the caller to our menu. Add this line to the [ docs:users] context in your dialplan:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
64
[demo-menu] exten => s,1,Answer(500) same => n(loop),Background(press-1&or&press-2) same => n,WaitExten() exten => 1,1,Playback(you-entered) same => n,SayNumber(1) same => n,Goto(s,loop) exten => 2,1,Playback(you-entered) same => n,SayNumber(2) same => n,Goto(s,loop) exten => i,1,Playback(option-is-invalid) same => n,Goto(s,loop) exten => t,1,Playback(are-you-still-there) same => n,Goto(s,loop)
Now dial your auto-attendant menu again (by dialing extension 6598), and try entering an invalid option (such as 3) at the auto-attendant menu. If you watch the Asterisk command-line interface while you dial and your verbosity level is three or higher, you should see something similar to the following:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
65
-----------------
Executing [6598@users:1] Goto("SIP/demo-alice-00000008", "demo-menu,s,1") in new stack Goto (demo-menu,s,1) Executing [s@demo-menu:1] Answer("SIP/demo-alice-00000008", "500") in new stack Executing [s@demo-menu:2] BackGround("SIP/demo-alice-00000008", "press-1&or&press-2") in new stack <SIP/demo-alice-00000008> Playing 'press-1.gsm' (language 'en') <SIP/demo-alice-00000008> Playing 'or.gsm' (language 'en') <SIP/demo-alice-00000008> Playing 'press-2.gsm' (language 'en') Invalid extension '3' in context 'demo-menu' on SIP/demo-alice-00000008 Executing [i@demo-menu:1] Playback("SIP/demo-alice-00000008", "option-is-invalid") in new stack <SIP/demo-alice-00000008> Playing 'option-is-invalid.gsm' (language 'en') Executing [i@demo-menu:2] Goto("SIP/demo-alice-00000008", "s,loop") in new stack Goto (demo-menu,s,2) Executing [s@demo-menu:2] BackGround("SIP/demo-alice-00000008", "press-1&or&press-2") in new stack <SIP/demo-alice-00000008> Playing 'press-1.gsm' (language 'en') <SIP/demo-alice-00000008> Playing 'or.gsm' (language 'en') <SIP/demo-alice-00000008> Playing 'press-2.gsm' (language 'en')
If you don't enter anything at the auto-attendant menu and instead wait approximately ten seconds, you should hear (and see) Asterisk go to the t extensio n as well.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
66
Record Application
For creating your own auto-attendant or IVR menus, you're probably going to want to record your own custom prompts. An easy way to do this is with the R ecord() application. The Record() application plays a beep, and then begins recording audio until you press the hash key ( #) on your keypad. It then saves the audio to the filename specified as the first parameter to the application and continues on to the next priority in the extension. If you hang up the call before pressing the hash key, the audio will not be recorded. For example, the following extension records a sound prompt called custom-menu in the gs m format in the en/ sub-directory, and then plays it back to you.
exten => 6597,1,Answer(500) same => n,Record(en/custom-menu.gsm) same => n,Wait(1) same => n,Playback(custom-menu) same => n,Hangup()
Recording Formats When specifiying a file extension when using the Record() application, you must choose a file extension which represents one of the supported file formats in Asterisk. For the complete list of file formats supported in your Asterisk installation, type core show file formats at the Asterisk command-line interface.
You've now learned the basics of how to create a simple auto-attendant menu. Now let's build a more practical menu for callers to be able to reach Alice or Bob or the dial-by-name directory. Procedure 216.1. Building a Practical Auto-Attendant Menu
1. Add an extension 6599 to the [docs:users] context which sends the calls to a new context we'll build called [docs:day-menu]. Your extension should look something like:
exten=>6599,1,Goto(day-menu,s,1)
2. Add a new context called [docs:day-menu], with the following contents:
[day-menu] exten => s,1,Answer(500) same => n(loop),Background(custom-menu) same => n,WaitExten() exten => 1,1,Goto(users,6001,1) exten => 2,1,Goto(users,6002,1) exten => 9,1,Directory(vm-demo,users,fe) exten => *,1,VoiceMailMain(@vm-demo) exten => i,1,Playback(option-is-invalid) same => n,Goto(s,loop) exten => t,1,Playback(are-you-still-there) same => n,Goto(s,loop)
1. Dial extension 6597 to record your auto-attendant sound prompt. Your sound prompt should say something like "Thank you for calling! Press one for Alice, press two for Bob, or press 9 for a company directory". Press the hash key (#) on your keypad when you're finished recording, and Asterisk will play it back to you. If you don't like it, simply dial extension 6597 again to re-record it. 2. Dial extension 6599 to test your auto-attendant menu.
In just a few lines of code, you've created your own auto-attendant menu. Feel free to experiment with your auto-attendant menu before moving on to the next section.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
67
Dialplan Architecture
In this section, we'll begin adding structure to our dialplan. We'll begin by talking about variables and how to use them, as well as how to manipulate them. Then we'll cover more advanced topics, such as pattern matching and using include statements to build classes of functionality.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
68
Variables
Variables are used in most programming and scripting languages. In Asterisk, we can use variables to simplify our dialplan and begin to add logic to the system. A variable is simply a container that has both a name and a value. For example, we can have a variable named COUNT which has a value of three. Later on, we'll show you how to route calls based on the value of a variable. Before we do that, however, let's learn a bit more about variables. The names of variables are case-sensitive, so COUNT is different than Count and count. Any channel variables created by Asterisk will have names that are completely upper-case, but for your own channels you can name them however you would like. In Asterisk, we have two different types of variables: channel variables and global variables.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
69
exten=>6123,1,Set(COUNT=3)
To retrieve the value of a variable, we use a special syntax. We put a dollar sign and curly braces around the variable name, like ${COUNT} When Asterisk sees the dollar sign and curly braces around a variable name, it substitutes in the value of the variable. Let's look at an example with the Sa yNumber() application.
exten=>6123,1,Set(COUNT=3) exten=>6123,n,SayNumber(${COUNT})
In the second line of this example, Asterisk replaces the ${COUNT} text with the value of the COUNT variable, so that it ends up calling SayNumber(3).
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
70
[globals] MYGLOBALVAR=somevalue
You can also set global variables from dialplan logic using the GLOBAL() dialplan function along with the Set() application. Simply use the syntax:
exten=>6124,1,Set(GLOBAL(MYGLOBALVAR)=somevalue)
To retrieve the value of a global channel variable, use the same syntax as you would if you were retrieving the value of a channel variable.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
71
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
72
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
73
Multiple Inheritance
Multiple inheritance means that a channel variable will be inherited by created (spawned) channels, and it will continue to be inherited by any other channels created by the spawned channels. To set multiple inheritance on a channel, preface the variable name with two underscores when giving it a value with the Set() application, as shown below.
exten=>6123,1,Set(__ACCOUNT=5551212)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
74
Single Inheritance
Single inheritance means that a channel variable will be inherited by created (spawned) channels, but not propogate from there to any other swawned channels. To follow our example above, if Alice sets a channel variable with single inheritance and calls Bob, Bob's channel will inherit that channel variable, but the channel variable won't get inherited by any channels that might get spawned by Bob's channel (if the call gets transferred, for example). To set single inheritance on a channel, preface the variable name with an underscore when giving it a value with the Set() application, as shown below.
exten=>6123,1,Set(_ACCOUNT=5551212)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
75
If you were to add this extension to the [docs:users] context of your dialplan and reload the dialplan, you could call extension 6123 and hear Asterisk read back the extension number to you. Another channel variable that Asterisk automatically creates is the UNIQUEID variable. Each channel within Asterisk receives a unique identifier, and that identifier is stored in the UNIQUEID variable. The UNIQUEID is in the form of 1267568856.11, where 1267568856 is the Unix epoch, and 11 shows that this is the eleventh call on the Asterisk system since it was last restarted. Last but not least, we should mention the CHANNEL variable. In addition to a unique identifier, each channel is also given a channel name and that channel name is set in the CHANNEL variable. A SIP call, for example, might have a channel name that looks like SIP/george-0000003b, for example.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
76
The NoOp() application stands for "No Operation". In other words, it does nothing. Because of the way Asterisk prints everything to the console if your verbosity level is three or higher, however, the NoOp() application is often used to print debugging information to the console like the Verbose() does. While you'll probably come across examples of the NoOp() application in other examples, we recommend you use the Verbose() application instead.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
77
In this example, the Read() application plays a sound prompt which says "Please enter the extension of the person you are looking for", and saves the captured digits in a variable called Digits. It then plays a sound prompt which says "You entered" and then reads back the value of the Digits variable.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
78
Pattern Matching
The next concept we'll cover is called pattern matching. Pattern matching allows us to create extension patterns in our dialplan that match more than one possible dialed number. Pattern matching saves us from having to create an extension in the dialplan for every possible number that might be dialed. When Alice dials a number on her phone, Asterisk first looks for an extension (in the context specified by the channel driver configuration) that matches exactly what Alice dialed. If there's no exact match, Asterisk then looks for a pattern that matches. After we show the syntax and some basic examples of pattern matching, we'll explain how Asterisk finds the best match if there are two or more patterns which match the dialed number. Pattern matches always begin with an underscore. This is how Asterisk recognizes that the extension is a pattern and not just an extension with a funny name. Within the pattern, we use various letters and characters to represent sets or ranges of numbers. Here are the most common letters: X The letter X or x represents a single digit from 0 to 9. Z The letter Z or z represents any digit from 1 to 9. N The letter N or n represents a single digit from 2 to 9. Now let's look at a sample pattern. If you wanted to match all four-digit numbers that had the first two digits as six and four, you would create an extension that looks like:
exten => _64XX,1,SayDigits(${EXTEN})
In this example, each X represents a single digit, with any value from zero to nine. We're essentially saying "The first digit must be a six, the second digit must be a four, the third digit can be anything from zero to nine, and the fourth digit can be anything from zero to nine". If we want to be more specific about a range of numbers, we can put those numbers or number ranges in square brackets to define a character set. For example, what if we wanted the second digit to be either a three or a four? One way would be to create two patterns ( _64XX and _63XX), but a more compact method would be to do _6[34]XX. This specifies that the first digit must be a six, the second digit can be either a three or a four, and that the last two digits can be anything from zero to nine. You can also use ranges within square brackets. For example, [1-468] would match a single digit from one through four or six or eight. It does not match any number from one to four hundred sixty-eight! Within Asterisk patterns, we can also use a couple of other characters to represent ranges of numbers. The period character ( .) at the end of a pattern matches one or more remaining characters. You put it at the end of a pattern when you want to match extensions of an indeterminate length. As an example, the pattern _9876. would match any number that began with 9876 and had at least one more character or digit. The exclamation mark (!) character is similar to the period and matches zero or more remaining characters. It is used in overlap dialing to dial through Asterisk. For example, _9876! would match any number that began with 9876 including 9876, and would respond that the number was complete as soon as there was an unambiguous match.
Asterisk treats a period or exclamation mark as the end of a pattern. If you want a period or exclamation mark in your pattern as a plain character you should put it into a character set: [.] or [!].
Be Careful With Wildcards in Pattern Matches Please be extremely cautious when using the period and exclamation mark characters in your pattern matches. They match more than just digits. They match on characters. If you're not careful to filter the input from your callers, a malicious caller might try to use these wildcards to bypass security boundaries on your system. For a more complete explanation of this topic and how you can protect yourself, please refer to the README-SERIOUSLY.bestpractices.txt fil e in the Asterisk source code.
Now let's show what happens when there is more than one pattern that matches the dialed number. How does Asterisk know which pattern to choose as the best match? Asterisk uses a simple set of rules to sort the extensions and patterns so that the best match is found first. The best match is simply the most specific pattern. The sorting rules are:
1. Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. 79
1. The dash (-) character is ignored in extensions and patterns except when it is used in a pattern to specify a range in a character set. It has no effect in matching or sorting extensions. 2. Non-pattern extensions are sorted in ASCII sort order before patterns. 3. Patterns are sorted by the most constrained character set per digit first. By most constrained, we mean the pattern that has the fewest possible matches for a digit. As an example, the N character has eight possible matches (two through nine), while X has ten possible matches (zero through nine) so N sorts first. 4. Character sets that have the same number of characters are sorted in ASCII sort order as if the sets were strings of the set characters. As an example, X is 0123456789 and [a-j] is abcdefghij so X sorts first. This sort ordering is important if the character sets overlap as with [0-4] and [4-8]. 5. The period (.) wildcard sorts after character sets. 6. The exclamation mark (!) wildcard sorts after the period wildcard.
Let's look at an example to better understand how this works. Let's assume Alice dials extension 6421, and she has the following patterns in her dialplan:
exten exten exten exten exten exten exten => => => => => => => _6XX1,1,SayAlpha(A) _64XX,1,SayAlpha(B) _640X,1,SayAlpha(C) _6.,1,SayAlpha(D) _64NX,1,SayAlpha(E) _6[45]NX,1,SayAlpha(F) _6[34]NX,1,SayAlpha(G)
Can you tell (without reading ahead) which one would match? Using the sorting rules explained above, the extensions sort as follows: _640X sorts before _64NX because of rule 3 at position 4. (0 before N) _64NX sorts before _64XX because of rule 3 at position 4. (N before X) _64XX sorts before _6[34]NX because of rule 3 at position 3. (4 before [34]) _6[34]NX sorts before _6[45]NX because of rule 4 at position 3. ([34] before [45]) _6[45]NX sorts before _6XX1 because of rule 3 at position 3. ([45] before X) _6XX1 sorts before _6. because of rule 5 at position 3. (X before .)
Sorted extensions
exten exten exten exten exten exten exten => => => => => => => _640X,1,SayAlpha(C) _64NX,1,SayAlpha(E) _64XX,1,SayAlpha(B) _6[34]NX,1,SayAlpha(G) _6[45]NX,1,SayAlpha(F) _6XX1,1,SayAlpha(A) _6.,1,SayAlpha(D)
When Alice dials 6421, Asterisk searches through its list of sorted extensions and uses the first matching extension. In this case _64NX is found. To verify that Asterisk actually does sort the extensions in the manner that we've shown, add the following extensions to the [users] context of your own dialplan.
exten exten exten exten exten exten exten => => => => => => => _6XX1,1,SayAlpha(A) _64XX,1,SayAlpha(B) _640X,1,SayAlpha(C) _6.,1,SayAlpha(D) _64NX,1,SayAlpha(E) _6[45]NX,1,SayAlpha(F) _6[34]NX,1,SayAlpha(G)
Reload the dialplan, and then type dialplan show 6421@users at the Asterisk CLI. Asterisk will show you all extensions that match in the [users] context. If you were to dial extension 6421 in the [users] context the first found extension will execute.
server*CLI> dialplan show 6421@users [ Context 'users' created by 'pbx_config' ] '_64NX' => 1. SayAlpha(E) '_64XX' => 1. SayAlpha(B) '_6[34]NX' => 1. SayAlpha(G) '_6[45]NX' => 1. SayAlpha(F) '_6XX1' => 1. SayAlpha(A) '_6.' => 1. SayAlpha(D) -= 6 extensions (6 priorities) in 1 context. =-
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
80
server*CLI> dialplan show users [ Context 'users' created by 'pbx_config' ] '_640X' => 1. SayAlpha(C) '_64NX' => 1. SayAlpha(E) '_64XX' => 1. SayAlpha(B) '_6[34]NX' => 1. SayAlpha(G) '_6[45]NX' => 1. SayAlpha(F) '_6XX1' => 1. SayAlpha(A) '_6.' => 1. SayAlpha(D) -= 7 extensions (7 priorities) in 1 context. =-
Be Careful with Pattern Matching Please be aware that because of the way auto-fallthrough works, if Asterisk can't find the next priority number for the current extension or pattern match, it will also look for that same priority in a less specific pattern match. Consider the following example:
exten => 6410,1,SayDigits(987) exten => _641X,1,SayDigits(12345) exten => _641X,n,SayDigits(54321)
If you were to dial extension 6410, you'd hear "nine eight seven five four three two one". We strongly recommend you make the Hangup() application be the last priority of any extension to avoid this problem, unless you purposely want to fall through to a less specific match.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
81
Include Statements
Include statements allow us to split up the functionality in our dialplan into smaller chunks, and then have Asterisk search multiple contexts for a dialed extension. Most commonly, this functionality is used to provide security boundaries between different classes of callers. It is important to remember that when calls come into the Asterisk dialplan, they get directed to a particular context by the channel driver. Asterisk then begins looking for the dialed extension in the context specified by the channel driver. By using include statements, we can include other contexts in the search for the dialed extension. Asterisk supports two different types of include statements: regular includes and time-based includes.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
82
Location of Include Statements Please note that in the example above, we placed the include statement before extensions 6001 and 6002. It could have just as well come after. Asterisk will always try to find a matching extension in the current context first, and only follow the include statement to a new context if there isn't anything that matches in the current context.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
83
Numbering Plans The examples in this section use patterns designed for the North American Number Plan, and may not fit your individual circumstances. Feel free to use this example as a guide as you build your own dialplan. In these examples, we're going to assuming that a seven-digit number that does not begin with a zero or a one is a local (non-toll) call. Ten-digit numbers (where neither the first or fourth digits begin with zero or one) are also treated as local calls. A one, followed by ten digits (where neither the first or fourth digits begin with zero or one) is considered a long-distance (toll) call. Again, feel free to modify these examples to fit your own particular circumstances.
Outbound dialing These examples assume that you have a SIP provider named provider configured in sip.conf. The examples dial out through this SIP provider using the SIP/provider/number syntax. Obviously, these examples won't work unless you setup a SIP provider for outbound calls, or replace this syntax with some other type of outbound connection. For more information on configuring a SIP provider, see Section 420. The SIP Protocol. For analog connectivity information, see Section 441. Analog Telephony with DAHDI. For more information on connectivity via digital circuits, see Section 450. Basics of Digital Telephony
[local] ; seven-digit local numbers exten => _NXXXXXX,1,Dial(SIP/provider/${EXTEN}) ; ten-digit local numbers exten => _NXXNXXXXXX,1,Dial(SIP/provider/${EXTEN}) ; emergency services (911), and other three-digit services exten => NXX,1,Dial(SIP/provider/${EXTEN}) ; if you don't find a match in this context, look in [users] include => users
Remember that the variable ${EXTEN} will get replaced with the dialed extension. For example, if Bob dials 5551212 in the local context, Asterisk will execute the Dial application with SIP/provider/5551212 as the first parameter. (This syntax means "Dial out to the account named provider using the SIP channel driver, and dial the number 5551212.) Next, we'll build a long-distance context, and link it back to the local context with an include statement. This way, if you dial a local number and your phone's channel driver sends the call to the longdistance context, Asterisk will search the local context if it doesn't find a matching pattern in the longdist ance context.
[longdistance] ; 1+ ten digit long-distance numbers exten => _1NXXNXXXXXX,1,Dial(SIP/provider/${EXTEN}) ; if you don't find a match in this context, look in [local] include => local
Last but not least, let's add an [docs:international] context. In North America, you dial 011 to signify that you're going to dial an international number.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
84
[international] ; 1+ ten digit long-distance numbers exten => _011.,1,Dial(SIP/provider/${EXTEN}) ; if you don't find a match in this context, look in [longdistance] include => longdistance
And there we have it -- a simple chain of contexts going from most privileged (international calls) down to lease privileged (local calling). At this point, you may be asking yourself, "What's the big deal? Why did we need to break them up into contexts, if they're all going out the same outbound connection?" That's a great question! The primary reason for breaking the different classes of calls into separate contexts is so that we can enforce some security boundaries. Do you remember what we said earlier, that the channel drivers point inbound calls at a particular context? In this case, if we point a phone at the [docs:lo cal] context, it could only make local and internal calls. On the other hand, if we were to point it at the [docs:international] context, it could make international and long-distance and local and internal calls. Essentially, we've created different classes of service by chaining contexts together with include statements, and using the channel driver configuration files to point different phones at different contexts along the chain. Many people find it instructive to look at a visual diagram at this point, so let's draw ourselves a map of the contexts we've created so far. Insert graphic showing chain of includes from international through long-distance to local and to users and features In this graphic, we've illustrated the various contexts and how they work together. We've also shown that Alice's phone is pointed at the [docs:internationa l] context, while Bob's phone is only pointed at the [docs:local] context. Please take the next few minutes and implement a series of chained contexts into your own dialplan, similar to what we've explained above. You can then change the configuration for Alice and Bob (in sip.conf, since they're SIP phones) to point to different contexts, and see what happens when you attempt to make various types of calls from each phone.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
85
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
86
What to Download?
On a typical system, you'll want to download three components:
Why is DAHDI split into different pieces? DAHDI has been split into two pieces (the Linux drivers and the tools) as third parties have begun porting the DAHDI drivers to other operating systems, such as FreeBSD. Eventually, we may have dahdi-linux, dahdi-freebsd, and so on.
The current version of libpri, DAHDI, and Asterisk can be downloaded from http://downloads.digium.com/pub/telephony/.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
87
System Requirements
In order to compile and install Asterisk, you'll need to install a C compiler and a number of system libraries on your system.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
88
Compiler
The compiler is a program that takes source code (the code written in the C programming language in the case of Asterisk) and turns it into a program that can be executed. While any C compiler should be able to compile the Asterisk code, we strongly recommend that you use the GCC compiler. Not only is it the most popular free C compiler on Linux and Unix systems, but it's also the compiler that the Asterisk developers are using. If the GCC compiler isn't already installed on your machine, simply use appropriate package management system on your machine to install it. You'll also want to install the C++ portion of GCC as well, as certain Asterisk modules will use it.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
89
System Libraries
In addition to the C compiler, you'll also need a set of system libraries. These libraries are used by Asterisk and must be installed before you can compile Asterisk. On most operating systems, you'll need to install both the library and it's corresponding development package.
Development libraries For most operating systems, the development packages will have -dev or -devel on the end of the name. For example, on a Red Hat Linux system, you'd want to install both the "openssl" and "openssl-devel" packages.
OpenSSL ncurses newt libxml2 Kernel headers (for building DAHDI drivers)
We recommend you use the package management system of your operating system to install these libraries before compiling and installing libpri, DAHDI, and Asterisk.
Help Finding the Right Libraries If you're installing Asterisk 1.6.1.0 or later, it comes with a shell script called install_prereq.sh in the contrib/scripts sub-directory. If you run install_prereq test, it will give you the exact commands to install the necessary system libraries on your operating system. If you run install_prereq install, it will attempt to download and install the prerequisites automatically.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
90
Next, let's extract the source code from each tarball using the tar command. The -zxvf parameters to the tar command tell it what we want to do with the file. The z option tells the system to unzip the file before continuing, the x option tells it to extract the files from the tarball, the v option tells it to be verbose (write out the name of every file as it's being extracted, and the f option tells the tar command that we're extracting the file from a tarball file, and not from a tape.
[root@server src]# tar -zxvf libpri-1.X.Y.tar.gz [root@server src]# tar -zxvf dahdi-linux-complete-2.X.Y+2.X.Y.tar.gz [root@server src]# tar -zxvf asterisk-1.8.X.Y.tar.gz
You should now notice that a new sub-directory was created for each of the tarballs, each containing the extracted files from the corresponding tarball. We can now compile and install each of the components.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
91
LibPRI 1.4.13 and later source code depends on DAHDI include files. So, as a change from older versions, one must install DAHDI before installing libPRI.
Now we can continue the installation on the Asterisk system using the steps below.
[root@server src]# cd dahdi-linux-complete-2.X.Y+2.X.Y [root@server dahdi-linux-complete-2.X.Y+2.X.Y]# cd linux/drivers/dahdi/firmware [root@server firmware]# for tarball in $(ls dahdi-fw-*.tar.gz); do tar -zxf $tarball; done; [root@server firmware]# cd [root@server dahdi-linux-complete-2.X.Y+2.X.Y]# make [root@server dahdi-linux-complete-2.X.Y+2.X.Y]# make install [root@server dahdi-linux-complete-2.X.Y+2.X.Y]# make config
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
92
This command compiles the libpri source code into a system library.
[root@server libpri-1.X.Y]# make install
This command installs the libpri library into the proper system library directory
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
93
Next, we'll run a command called ./configure, which will perform a number of checks on the operating system, and get the Asterisk code ready to compile on this particular server.
[root@server asterisk-1.8.X.Y]# ./configure
This will run for a couple of minutes, and warn you of any missing system libraries or other dependencies. If you have missing dependencies then you should install them now and then run configure again to make sure they are recognized. A helpful way to install most of the dependencies you need is to use the install_prereq script included in the contrib/scripts/ directory of your Asterisk source. It's quite straightforward to use, but may not work on all systems. Run the script with no arguments to see the usage help. Upon completion of ./configure, you should see a message that looks similar to the one shown below. (Obviously, your host CPU type may be different than the below.)
.$$$$$$$$$$$$$$$=.. .$7$7.. .7$$7:. .$7$7.. .7$$7:. .$$:. ,$7.7 .$7. 7$$$$ .$$77 ..$$. $$$$$ .$$$7 ..7$ .?. $$$$$ .?. 7$$$. $.$. .$$$7. $$$$7 .7$$$. .$$$. .777. .$$$$$$77$$$77$$$$$7. $$$, $$$~ .7$$$$$$$$$$$$$7. .$$$. .$$7 .7$$$$$$$7: ?$$$. $$$ ?7$$$$$$$$$$I .$$$7 $$$ .7$$$$$$$$$$$$$$$$ :$$$. $$$ $$$$$$7$$$$$$$$$$$$ .$$$. $$$ $$$ 7$$$7 .$$$ .$$$. $$$$ $$$$7 .$$$. 7$$$7 7$$$$ 7$$$ $$$$$ $$$ $$$$7. $$ (TM) $$$$$$$. .7$$$$$$ $$ $$$$$$$$$$$$7$$$$$$$$$.$$$$$$ $$$$$$$$$$$$$$$$. configure: configure: configure: configure: configure: Package configured for: OS type : linux-gnu Host CPU : x86_64 build-cpu:vendor:os: x86_64 : unknown : linux-gnu : host-cpu:vendor:os: x86_64 : unknown : linux-gnu :
Cached Data The ./configure command caches certain data to speed things up if it's invoked multiple times. To clear all the cached data, you can use the following command to completely clear out any cached data from the Asterisk build system.
[root@server asterisk-1.8.X.Y]# make distclean
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
94
Terminal Window Your terminal window size must be at least eighty characters wide and twenty-one lines high, or menuselect will not work. Instead, you'll get an error message stating
Terminal must be at least 80 x 21.
Asterisk 1.8+
Terminal must be at least 80 x 27.
The menuselect menu should look like the screen-shot below. On the left-hand side, you have a list of categories, such as Applications, Channel Drivers, and PBX Modules. On the right-hand side, you'll see a list of modules that correspond with the select category. At the bottom of the screen you'll see two buttons. You can use the Tab key to cycle between the various sections, and press the Enter key to select or unselect a particular module. If you see [docs:] next to a module name, it signifies that the module has been selected. If you see *XXX next to a module name, it signifies that the select module cannot be built, as one of its dependencies is missing. In that case, you can look at the bottom of the screen for the line labeled Depends upon: for a description of the missing dependency. When you're first learning your way around Asterisk on a test system, you'll probably want to stick with the default settings in menuselect. If you're building a production system, however, you may not wish to build all of the various modules, and instead only build the modules that your system is using.
Easier Debugging of Asterisk Crashes If you're finding that Asterisk is crashing on you, there's a setting in menuselect that will help provide additional information to the Asterisk developers. Go into menuselect, select the the Compiler Flags section (you'll need to scroll down in the left-hand list), and select the DONT_OPTIMIZE setting. Then rebuild Asterisk as shown below. While the Asterisk application will be slightly larger, it will provide additional debugging symbols in the event of a crash.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
95
We should also inform people that the sound prompts are selected in menuselect as well When you are finished selecting the modules and options you'd like in menuselect, press F12 to save and exit, or highlight the Save and Exit button and press enter.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
96
The compiling step will take several minutes, and you'll see the various file names scroll by as they are being compiled. Once Asterisk has finished compiling, you'll see a message that looks like:
+--------- Asterisk Build Complete ---------+ + Asterisk has successfully been built, and + + can be installed by running: + + + + make install + +-------------------------------------------+ +--------- Asterisk Build Complete ---------+
As the message above suggests, our next step is to install the compiled Asterisk program and modules. To do this, use the make install command.
[root@server asterisk-1.8.X.Y]# make install
Security Precautions As the message above suggests, we very strongly recommend that you read the security documentation before continuing with your Asterisk installation. Failure to read and follow the security documentation can leave your system vulnerable to a number of security issues, including toll fraud. If you installed Asterisk from a tarball (as shown above), the security information is located in a PDF file named asterisk.pdfin the tex/ sub-directory of the source code. If that file doesn't exist, please install the rubber application on your system, and then type:
[root@server asterisk-1.8.X.Y]# make pdf
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
97
Any existing sample files which have been modified will be given a .old file extension. For example, if you had an existing file named extensions.conf, it would be renamed to extensions.conf.old and the sample dialplan would be installed as extensions.conf.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
98
As your Asterisk system runs, it will generate logfiles. It is recommended to install the logrotation script in order to compress and rotate those files, to save disk space and to make searching them or cataloguing them easier. To do this, use the make install-logrotate command.
[root@server asterisk-1.8.X.Y]# make install-logrotate
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
99
If the command returns nothing, then DAHDI has not been started. Start DAHDI by running:
[root@server asterisk-1.8.X.Y]# /etc/init.d/dadhi start
Different Methods for Starting Initscripts Many Linux distributions have different methods for starting initscripts. On most Red Hat based distributions (such as Red Hat Enterprise Linux, Fedora, and CentOS) you can run:
[root@server asterisk-1.8.X.Y]# service dahdi start
Distributions based on Debian (such as Ubuntu) have a similar command, though it's not commonly used:
[root@server asterisk-1.8.X.Y]# invoke-rc.d dahdi start
If you have DAHDI running, the output of lsmod | grep dahdi should look something like the output below. (The exact details may be different, depending on which DAHDI modules have been built, and so forth.)
[root@server asterisk-1.8.X.Y]# lsmod | grep dahdi dahdi_dummy 4288 0 dahdi_transcode 7928 1 wctc4xxp dahdi_voicebus 40464 2 wctdm24xxp,wcte12xp dahdi 196544 12 dahdi_dummy,wctdm24xxp,wcte11xp,wct1xxp,wcte12xp,wct4xxp crc_ccitt 2096 1 dahdi
Now that DAHDI is running, you can run dahdi_hardware to list any DAHDI-compatible devices in your system. You can also run the dahdi_tool utility to show the various DAHDI-compatible devices, and their current state. To check if Asterisk is running, you can use the Asterisk initscript.
[root@server asterisk-1.8.X.Y]# /etc/init.d/asterisk status asterisk is stopped
To start Asterisk, we'll use the initscript again, this time giving it the start action:
[root@server asterisk-1.8.X.Y]# /etc/init.d/asterisk start Starting asterisk:
When Asterisk starts, it runs as a background service (or daemon), so you typically won't see any response on the command line. We can check the status of Asterisk and see that it's running using the command below. (The process identifier, or pid, will obviously be different on your system.)
[root@server asterisk-1.8.X.Y]# /etc/init.d/asterisk status asterisk (pid 32117) is running...
And there you have it! You've compiled and installed Asterisk, DAHDI, and libpri from source code.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
100
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
101
The -r parameter tells the system that you want to re-connect to the Asterisk service. If the reconnection is successful, you'll see something like this:
[root@server ~]# asterisk -r Asterisk version, Copyright (C) 1999 - 2010 Digium, Inc. and others. Created by Mark Spencer <[email protected]> Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. This is free software, with components licensed under the GNU General Public License version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'core show license' for details. ========================================================================= Connected to Asterisk version currently running on server (pid = 11187) server*CLI>
Notice the *CLI> text? That's your Asterisk command-line prompt. All of the Asterisk CLI commands take the form of module action parameters.... For example, type core show uptime to see how long Asterisk has been running.
server*CLI> core show uptime System uptime: 1 hour, 34 minutes, 17 seconds Last reload: 1 hour, 34 minutes, 17 seconds
You can use the built-in help to get more information about the various commands. Simply type core show help at the Asterisk prompt for a full list of commands, or core show help command for help on a particular command. If you'd like to exit the Asterisk console and return to your shell, just use the quit command from the CLI. Such as:
server*CLI> quit
Executing Command Outside Of CLI You can execute an Asterisk command from outside the CLI:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
102
1. core stop now - This command stops the Asterisk service immediately, ending any calls in progress. 2. core stop gracefully - This command prevents new calls from starting up in Asterisk, but allows calls in progress to continue. When all the calls have finished, Asterisk stops. 3. core stop when convenient - This command waits until Asterisk has no calls in progress, and then it stops the service. It does not prevent new calls from entering the system.
There are three related commands for restarting Asterisk as well.
1. core restart now - This command restarts the Asterisk service immediately, ending any calls in progress. 2. core restart gracefully - This command prevents new calls from starting up in Asterisk, but allows calls in progress to continue. When all the calls have finished, Asterisk restarts. 3. core restart when convenient - This command waits until Asterisk has no calls in progress, and then it restarts the service. It does not prevent new calls from entering the system.
There is also a command if you change your mind.
core abort shutdown - This command aborts a shutdown or restart which was previously initiated with the gracefully or when convenient options.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
103
You can also increase (but not decrease) the verbosity level when you connect to the Asterisk CLI from the Linux prompt, by using one or more -v paramet ers to the asterisk application. For example, this would connect to the Asterisk CLI and set the verbosity to three (if it wasn't already three or higher), because we added three -v parameters:
[root@server ~]# asterisk -vvvr
The second class of system messages is known as debug messages. These messages are intended for Asterisk developers, to give information about what's happening in the Asterisk program itself. They're often used by developers when trying to track down problems in the code, or to understand why Asterisk is behaving in a certain manner. To change the debugging level, use the CLI command core set debug, as shown below:
server*CLI> core set debug 4 Core debug was 0 and is now 4
You can also increase (but not decrease) the debugging level when you connect to the Asterisk CLI from the Linux prompt. Simply add one or more -d para meters to the asterisk application.
[root@server ~]# asterisk \-ddddr
Verbose and Debug Levels Please note that the verbose and debug levels are global settings, and apply to all of Asterisk, not just your command-line interface. We recommend that you set your verbosity level to three while learning Asterisk, so that you can get a feel for what is happening as calls are processed. On a busy production system, however, you'll want to set the verbosity level lower. We also recommend that you use debug messages sparingly, as they tend to be quite verbose and can affect call volume on busy systems.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
104
Now press the r key, and press tab again. This time Asterisk completes the word for you, as core is the only command that begins with cor. This trick also works with sub-commands. For example, type core show and press tab. (You may have to press tab twice, if you didn't put a space after the word show.) Asterisk will show you all the sub-commands that start with core show.
server*CLI> core show [Tab] application applications channels channeltype codecs config functions help image license switches sysinfo translation uptime server*CLI> core show
Another trick you can use on the CLI is to cycle through your previous commands. Asterisk stores a history of the commands you type and you can press the up arrow key to cycle through the history. If you type an exclamation mark at the Asterisk CLI, you will get a Linux shell. When you exit the Linux shell (by typing exit or pressing Ctrl+D), you return to the Asterisk CLI. You can also type an exclamation mark and a Linux command, and the output of that command will be shown to you, and then you'll be returned to the Asterisk CLI.
server*CLI> !whoami root server*CLI>
As you can see, there's a wealth of information available from the Asterisk command-line interface, and we've only scratched the surface. In later sections, we'll go into more details about how to use the command-line interface for other purposes.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
105
Troubleshooting
If you're able to get the command-line examples above working, feel free to skip this section. Otherwise, let's look at troubleshooting connections to the Asterisk CLI. The most common problem that people encounter when learning the Asterisk command-line interface is that sometimes they're not able to connect to the Asterisk service running in the background. For example, let's say that Fred starts the Asterisk service, but then isn't able to connect to it with the CLI:
[root@server ~]# service asterisk start Starting asterisk: [ OK ] [root@server ~]# asterisk -r Asterisk version, Copyright (C) 1999 - 2010 Digium, Inc. and others. Created by Mark Spencer <[email protected]> ========================================================================= Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)
What does this mean? It most likely means that Asterisk did not remain running between the time that the service was started and the time Fred tried to connect to the CLI (even if it was only a matter of a few seconds.) This could be caused by a variety of things, but the most common is a broken configuration file. To diagnose Asterisk start-up problems, we'll start Asterisk in a special mode, known as console mode. In this mode, Asterisk does not run as a background service or daemon, but instead runs directly in the console. To start Asterisk in console mode, pass the -c parameter to the asterisk applicatio n. In this case, we also want to turn up the verbosity, so we can see any error messages that might indicate why Asterisk is unable to start.
[root@server ~]# asterisk -vvvc Asterisk version, Copyright (C) 1999 - 2010 Digium, Inc. and others. Created by Mark Spencer <[email protected]> Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. This is free software, with components licensed under the GNU General Public License version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'core show license' for details. ========================================================================= == Parsing '/etc/asterisk/asterisk.conf': == Found == Parsing '/etc/asterisk/extconfig.conf': == Found == Parsing '/etc/asterisk/logger.conf': == Found == Parsing '/etc/asterisk/asterisk.conf': == Found Asterisk Dynamic Loader Starting: == Parsing '/etc/asterisk/modules.conf': == Found ...
Carefully look for any errors or warnings that are printed to the CLI, and you should have enough information to solve whatever problem is keeping Asterisk from starting up.
Running Asterisk in Console Mode We don't recommend you use Asterisk in console mode on a production system, but simply use it for debugging, especially when debugging start-up problems. On production systems, run Asterisk as a background service.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
106
Asterisk Architecture
From an architectural standpoint, Asterisk is made up of many different modules. This modularity gives you an almost unlimited amount of flexibility in the design of an Asterisk-based system. As an Asterisk administrator, you have the choice on which modules to load. Each module that you loads provides different capabilities to the system. For example, one module might allow your Asterisk system to communicate with analog phone lines, while another might add call reporting capabilities. In this section, we'll discuss the various types of modules and the capabilities they provide.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
107
Channel Drivers
At the top of the diagram, we show channel drivers. Channel drivers communicate with devices outside of Asterisk, and translate that particular signaling or protocol to the core.
Dialplan Applications
Applications provide call functionality to the system. An application might answer a call, play a sound prompt, hang up a call, and so forth.
Dialplan Functions
Functions are used to retrieve or set various settings on a call. A function might be used to set the Caller ID on an outbound call, for example.
Resources
As the name suggests, resources provide resources to Asterisk. Common examples of resources include music on hold and call parking.
CODECs
A CODEC (which is an acronym for COder/DECoder) is a module for encoding or decoding audio or video. Typically codecs are used to encode media so that it takes less bandwidth.
Bridge Drivers
Bridge drivers are used by the bridging architecture in Asterisk, and provide various methods of bridging call media between participants in a call. Now let's go into more detail on each of the module types.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
108
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
109
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
110
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
111
Resource Modules
Resources provide functionality to Asterisk that may be called upon at any time during a call, even while another application is running on the channel. Resources are typically used of asynchronous events such as playing hold music when a call gets placed on hold, or performing call parking. Resource modules have file names that looks like res_xxxxx.so, such as res_musiconhold.so.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
112
Codec Modules
CODEC modules have file names that look like codec_xxxxx.so, such as codec_alaw.so and codec_ulaw.so. CODECs represent mathematical algorithms for encoding (compressing) and decoding (decompression) media streams. Asterisk uses CODEC modules to both send and recieve media (audio and video). Asterisk also uses CODEC modules to convert (or transcode) media streams between different formats. CODEC modules have file names that look like codec_xxxxx.so, such as codec_alaw.so and codec_ulaw.so. Asterisk is provided with CODEC modules for the following media types:
ADPCM, 32kbit/s G.711 alaw, 64kbit/s G.711 ulaw, 64kbit/s G.722, 64kbit/s G.726, 32kbit/s GSM, 13kbit/s LPC-10, 2.4kbit/s
If the Speex (www.speex.org) development libraries are detected on your system when Asterisk is built, a CODEC module for Speex will also be installed. If the iLBC (www.ilbcfreeware.org) development libraries are detected on your system when Asterisk is built, a CODEC module for iLBC will also be installed. Support for the patent-encumbered G.729A or G.723.1 CODECs is provided by Digium on a commercial basis through both software and hardware products. For more information about purchasing licenses or hardware to use the G.729A or G.723.1 CODECs with Asterisk, please see Digium's website. Support for Polycom's patent-encumbered but free G.722.1 Siren7 and G.722.1C Siren14 CODECs, or for Skype's SILK CODEC, can be enabled in Asterisk by downloading the binary CODEC modules from Digium's website. For more detailed information on CODECs, see CODECs.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
113
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
114
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
115
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
116
Bridging Modules
Beginning in Asterisk 1.6.2, Asterisk introduced a new method for bridging calls together. It relies on various bridging modules to control how the media streams should be mixed for the participants on a call. The new bridging methods are designed to be more flexible and more efficient than earlier methods. Bridging modules have file names that look like bridge_xxxxx.so, such as bridge_simple.so and bridge_multiplexed.so.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
117
1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
Alice dials extension 6002, which is Bob's extension on the Asterisk system. A SIP message goes from Alice's phone to the SIP channel driver in Asterisk The SIP channel driver authenticates the call. If Alice's phone does not provide the proper credentials, Asterisk rejects the call. At this point, we have Alice's phone communicating with Asterisk. Now the call goes from the SIP channel driver into the core of Asterisk. Asterisk looks for a set of instructions to follow for extension 6002 in the dialplan. Extension 6002 in the dialplan tells Asterisk to call Bob's phone Asterisk makes a call out through the SIP channel driver to Bob's phone. Bob answers his phone. Now we have two independent calls on the Asterisk system: one from Alice, and to Bob. Asterisk now bridges the audio between these two calls (known as channels in Asterisk parlance). When one channel hangs up, Asterisk signals the other channel to hang up.
And there we have it! We've shown how calls flow from external devices, through the channel drivers to the core of Asterisk, and back out through the channel drivers to external devices.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
118
Asterisk Architecture We need to add CEL and Bridge modules to this picture, and take CLI and Manager out for now The heart of any Asterisk system is the core. The PBX core is the essential component that takes care of bridging calls. The core also takes care of other items like reading the configuration files and loading the other modules. We'll talk more about the core below, but for now just remember that all the other modules connect to it. From a logistical standpoint, these modules are typically files with a .so file extension, which live in the Asterisk modules directory (which is typically /usr/li b/asterisk/modules). When Asterisk starts up, it loads these files and adds their functionality to the system.
A Plethora of Modules Take just a minute and go look at the Asterisk modules directory on your system. You should find a wide variety of modules. A typical Asterisk system has over one hundred fifty different modules!
The core also contains the dialplan, which is the logic of any Asterisk system. The dialplan contains a list of instructions that Asterisk should follow to know how to handle incoming and outgoing calls on the system. Asterisk modules which are part of the core have a file name that look like pbx_xxxxx.so.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
119
Audiohooks
Overview
Certain applications and functions are capable of attaching what is known as an audiohook to a channel. In order to understand what this means and how to handle these applications and functions, it is useful to understand a little of the architecture involved with attaching them.
In this simple example, a SIP phone has dialed into Asterisk and its channel has invoked a function (pitch_shift) which has been set to cause all audio sent and received to have its pitch shifted higher (i.e. if the audio is voice, the voices will sound squeaky sort of like obnoxious cartoon chipmunks). The following dialplan provides a more concrete usage:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
120
Below is an illustrated example of how the masquerade process impacts an audiohook (in the case of the example, PITCH_SHIFT)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
121
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
122
Inheritance of audiohooks can be turned off in the same way by setting AUDIOHOOK_INHERIT(source)=no.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
123
Audiohook Sources
Audiohooks have a source name and can come from a number of sources. An up to date list of possible sources should always be available from the documentation for AUDIOHOOK_INHERIT.
Chanspy - from app_chanspy MixMonitor - app_mixmonitor.c Volume - func_volume.c Mute - res_mutestream.c Speex - func_speex.c pitch_shift - func_pitchshift.c JACK_HOOK - app_jack.c
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
124
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
125
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
126
Asterisk on (Open)Solaris
Asterisk on Solaris 10 and OpenSolaris
On this page
Asterisk on Solaris 10 and OpenSolaris Digium's Support Status Build Notes Prerequisites LDAP dependencies Makefile layouts FAX support with SpanDSP Gotchas Runtime issues Build issues
SUNWlibm (math library) gcc-dev (compiler and several dependencies) SUNWflexlex (GNU flex) SUNWggrp (GNU grep) SUNWgsed (GNU sed) SUNWdoxygen (optional; needed for "make progdocs") SUNWopenldap (optional; needed for res_config_ldap; see below) SUNWgnu-coreutils (optional; provides GNU install; see below)
Caution: installing SUNW gnu packages will change the default application run when the user types 'sed' and 'grep' from /usr/bin/sed to /usr/gnu/bin/sed. Just be aware of this change, as there are differences between the Sun and GNU versions of these utilities.
LDAP dependencies
Because OpenSolaris ships by default with Sun's LDAP libraries, you must install the SUNWopenldap package to provide OpenLDAP libraries. Because of namespace conflicts, the standard LDAP detection will not work. There are two possible solutions:
1. Port res_config_ldap to use only the RFC-specified API. This should allow it to link against Sun's LDAP libraries. The problem is centered around the use of the OpenLDAP-specific ldap_initialize() call. 2. Change the detection routines in configure to use OpenSolaris' layout of OpenLDAP. This seems doubtful simply because the filesystem layout of SUNWopenldap is so non-standard.
Despite the above two possibilities, there is a workaround to make Asterisk compile with res_config_ldap.
Modify the "configure" script, changing all instances of "-lldap" to "-lldap-2.4". At the time of this writing there are only 4 instances. This alone will make configure properly detect LDAP availability. But it will not compile. When running make, specify the use of the OpenLDAP headers like this:
"make LDAP_INCLUDE=-I/usr/include/openldap"
Makefile layouts
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
127
This has been fixed in Asterisk 1.8 and is no longer an issue. In Asterisk 1.6 the Makefile overrides any usage of --prefix. I suspect the assumptions are from back before configure provided the ability to set the installation prefix. Regardless, if you are building on OpenSolaris, be aware of this behavior of the Makefile! If you want to alter the install locations you will need to hand-edit the Makefile. Search for the string "SunOS" to find the following section:
# Define standard directories for various platforms # These apply if they are not redefined in asterisk.conf ifeq ($(OSARCH),SunOS) ASTETCDIR=/etc/asterisk ASTLIBDIR=/opt/asterisk/lib ASTVARLIBDIR=/var/opt/asterisk ASTDBDIR=$(ASTVARLIBDIR) ASTKEYDIR=$(ASTVARLIBDIR) ASTSPOOLDIR=/var/spool/asterisk ASTLOGDIR=/var/log/asterisk ASTHEADERDIR=/opt/asterisk/include/asterisk ASTBINDIR=/opt/asterisk/bin ASTSBINDIR=/opt/asterisk/sbin ASTVARRUNDIR=/var/run/asterisk ASTMANDIR=/opt/asterisk/man else
Note that, despite the comment, these definitions have build-time and run-time implications. Make sure you make these changes BEFORE you build!
Build issues
bootstrap.sh does not correctly detect OpenSolaris build tools (see Ticket 16341) Console documentation is not properly loaded at startup (see Ticket 16688) Solaris sed does not properly create AEL parser files (see Ticket 16696; workaround is to install GNU sed with SUNWgsed) Asterisk's provided install script, install-sh, is not properly referenced in the makeopts file that is generated during the build. One workaround is to install GNU install from the SUNWgnu-coreutils package. (See Ticket 16781)
Finally, Solaris memory allocation seems far more sensitive than Linux. This has resulted in the discovery of several previously unknown bugs related to uninitialized variables that Linux handled silently. Note that this means, until these bugs are found and fixed, you may get segfaults. At the time of this writing I have had a server up and running reasonably stable. However, there are large sections of Asterisk's codebase I do not use and likely contain more of these uninitialized variable problems and associated potential segfaults.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
128
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
129
Asterisk Calendaring
The Asterisk Calendaring API aims to be a generic interface for integrating Asterisk with various calendaring technologies. The goal is to be able to support reading and writing of calendar events as well as allowing notification of pending events through the Asterisk dialplan. There are three calendaring modules that ship with Asterisk that provide support for iCalendar, CalDAV, and Microsoft Exchange Server calendars. All three modules support event notification. Both CalDAV and Exchange support reading and writing calendars, while iCalendar is a read-only format.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
130
[calendar_joe] type = ical url = https://example.com/home/jdoe/Calendar user = jdoe secret = mysecret refresh = 15 timeframe = 600 autoreminder = 10 channel = SIP/joe context = calendar_event_notify extension = s waittime = 30
Module-independent settings
The settings related to calendar event notification are handled by the core calendaring API. These settings are:
autoreminder - This allows the overriding of any alarms that may or may not be set for a calendar event. It is specified in minutes. refresh - How often to refresh the calendar data; specified in minutes. timeframe - How far into the future each calendar refresh should look. This is the amount of data that will be visible to queries from the dialplan. This setting should always be greater than or equal to the refresh setting or events may be missed. It is specified in minutes. channel - The channel that should be used for making the notification attempt. waittime - How long to wait, in seconds, for the channel to answer a notification attempt. There are two ways to specify how to handle a notification. One option is providing a context and extension, while the other is providing an application and the arguments to that application. One (and only one) of these options should be provided. context - The context of the extension to connect to the notification channel extension - The extension to connect to the notification. Note that the priority will always be 1. app - The dialplan application to execute upon the answer of a notification appdata - The data to pass to the notification dialplan application
Module-dependent settings
Connection-related options are specific to each module. Currently, all modules take a url, user, and secret for configuration and no other module-specific settings have been implemented. At this time, no support for HTTP redirects has been implemented, so it is important to specify the correct URL-paying attention to any trailing slashes that may be necessary.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
131
summary - A short summary of the event description - The full description of the event organizer - Who organized the event location - Where the event is located calendar - The name of the calendar from calendar.conf uid - The unique identifier associated with the event start - The start of the event in seconds since Unix epoch end - The end of the event in seconds since Unix epoch busystate - The busy state 0=Free, 1=Tentative, 2=Busy attendees - A comma separated list of attendees as stored in the event and may include prefixes such as "mailto:".
When an event notification is sent to the dial plan, the CALENDAR_EVENT function may be used to return the information about the event that is causing the notification. The fields that can be returned are the same as those from CALENDAR_QUERY_RESULT.
Write functions
To write an event to a calendar, the CALENDAR_WRITE function is used. This function takes a calendar name and also uses the same fields as CALENDAR_QUERY_RESULT. As a write function, it takes a set of comma-separated values that are in the same order as the specified fields. For example:
CALENDAR_WRITE(mycalendar,summary,organizer,start,end,busystate)= "My event","mailto:[email protected]",228383580,228383640,1)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
132
[incoming] exten => 5555551212,1,Answer same => n,GotoIf(${CALENDAR_BUSY(officehours)}?closed:attendant,s,1) same => n(closed),Set(id=${CALENDAR_QUERY(office,${EPOCH},${EPOCH})}) same => n,Set(soundfile=${CALENDAR_QUERY_RESULT(${id},description)}) same => n,Playback($[${ISNULL(soundfile)} ? generic-closed :: ${soundfile}]) same => n,Hangup
Meeting reminders
One useful application of Asterisk Calendaring is the ability to execute dialplan logic based on an event notification. Most calendaring technologies allow a user to set an alarm for an event. If these alarms are set on a calendar that Asterisk is monitoring and the calendar is set up for event notification via calendar.conf, then Asterisk will execute notify the specified channel at the time of the alarm. If an overrided notification time is set with the autoreminder setting, then the notification would happen at that time instead. The following example demonstrates the set up for a simple event notification that plays back a generic message followed by the time of the upcoming meeting. calendar.conf.
[calendar_joe] type = ical url = https://example.com/home/jdoe/Calendar user = jdoe secret = mysecret refresh = 15 timeframe = 600 autoreminder = 10 channel = SIP/joe context = calendar_event_notify extension = s waittime = 30
extensions.conf :
[calendar_event_notify] exten => s,1,Answer same => n,Playback(you-have-a-meeting-at) same => n,SayUnixTime(${CALENDAR_EVENT(start)}) same => n,Hangup
Writing an event
Both CalDAV and Exchange calendar servers support creating new events. The following example demonstrates writing a log of a call to a calendar.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
133
[incoming] exten => 6000,1,Set(start=${EPOCH}) exten => 6000,n,Dial(SIP/joe) exten => h,1,Set(end=${EPOCH}) exten => h,n,Set(CALENDAR_WRITE(calendar_joe,summary,start,end)=Call from ${CALLERID(all)},${start},${end})
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
134
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
135
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
136
Why IAX2?
The first question most people are thinking at this point is "Why do you need another VoIP protocol? Why didn't you just use SIP or H.323?" Well, the answer is a fairly complicated one, but in a nutshell it's like this... Asterisk is intended as a very flexible and powerful communications tool. As such, the primary feature we need from a VoIP protocol is the ability to meet our own goals with Asterisk, and one with enough flexibility that we could use it as a kind of laboratory for inventing and implementing new concepts in the field. Neither H.323 or SIP fit the roles we needed, so we developed our own protocol, which, while not standards based, provides a number of advantages over both SIP and H.323, some of which are:
Interoperability with NAT/PAT/Masquerade firewalls - IAX2 seamlessly interoperates through all sorts of NAT and PAT and other firewalls, including the ability to place and receive calls, and transfer calls to other stations. High performance, low overhead protocol When running on low-bandwidth connections, or when running large numbers of calls, optimized bandwidth utilization is imperative. IAX2 uses only 4 bytes of overhead. Internationalization support IAX2 transmits language information, so that remote PBX content can be delivered in the native language of the calling party. Remote dialplan polling IAX2 allows a PBX or IP phone to poll the availability of a number from a remote server. This allows PBX dialplans to be centralized. Flexible authentication IAX2 supports cleartext, MD5, and RSA authentication, providing flexible security models for outgoing calls and registration services. Multimedia protocol IAX2 supports the transmission of voice, video, images, text, HTML, DTMF, and URL's. Voice menus can be presented in both audibly and visually. Call statistic gathering IAX2 gathers statistics about network performance (including latency and jitter), as well as providing end-to-end latency measurement. Call parameter communication Caller*ID, requested extension, requested context, etc. are all communicated through the call. Single socket design IAX2's single socket design allows up to 32768 calls to be multiplexed.
While we value the importance of standards based (i.e. SIP) call handling, hopefully this will provide a reasonable explanation of why we developed IAX2 rather than starting with SIP.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
137
Introduction to IAX2
This section is intended as an introduction to the Inter-Asterisk eXchange v2 (or simply IAX2) protocol. It provides both a theoretical background and practical information on its use.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
138
IAX2 Configuration
For examples of a configuration, please see the iax.conf.sample in the /configs directory of your source code distribution.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
139
IAX2 Jitterbuffer
The new jitterbuffer You must add jitterbuffer=yes to either the [general] part of iax.conf, or to a peer or a user. (just like the old jitterbuffer). Also, you can set max jitterbuffer=n, which puts a hard-limit on the size of the jitterbuffer of "n milliseconds". It is not necessary to have the new jitterbuffer on both sides of a call; it works on the receive side only. PLC The new jitterbuffer detects packet loss. PLC is done to try to recreate these lost packets in the codec decoding stage, as the encoded audio is translated to slinear. PLC is also used to mask jitterbuffer growth. This facility is enabled by default in iLBC and speex, as it has no additional cost. This facility can be enabled in adpcm, alaw, g726, gsm, lpc10, and ulaw by setting genericplc = true in the plc section of codecs.conf. Trunk Timestamps To use this, both sides must be using Asterisk v1.2 or later. Setting trunktimestamps=yes in iax.conf will cause your box to send 16-bit timestamps for each trunked frame inside of a trunk frame. This will enable you to use jitterbuffer for an IAX2 trunk, something that was not possible in the old architecture. The other side must also support this functionality, or else, well, bad things will happen. If you don't use trunk timestamps, there's lots of ways the jitterbuffer can get confused because timestamps aren't necessarily sent through the trunk correctly. Communication with Asterisk v1.0.x systems You can set up communication with v1.0.x systems with the new jitterbuffer, but you can't use trunks with trunktimestamps in this communication. If you are connecting to an Asterisk server with earlier versions of the software (1.0.x), do not enable both jitterbuffer and trunking for the involved peers/users in order to be able to communicate. Earlier systems will not support trunktimestamps. You may also compile chan_iax2.c without the new jitterbuffer, enabling the old backwards compatible architecture. Look in the source code for instructions. Testing and monitoring You can test the effectiveness of PLC and the new jitterbuffer's detection of loss by using the new CLI command iax2 test losspct n. This will simulate n percent packet loss coming in to chan_iax2. You should find that with PLC and the new JB, 10 percent packet loss should lead to just a tiny amount of distortion, while without PLC, it would lead to silent gaps in your audio. iax2 show netstats shows you statistics for each iax2 call you have up. The columns are "RTT" which is the round-trip time for the last PING, and then a bunch of stats for both the local side (what you're receiving), and the remote side (what the other end is telling us they are seeing). The remote stats may not be complete if the remote end isn't using the new jitterbuffer. The stats shown are:
Jit: The jitter we have measured (milliseconds) Del: The maximum delay imposed by the jitterbuffer (milliseconds) Lost: The number of packets we've detected as lost. %: The percentage of packets we've detected as lost recently. Drop: The number of packets we've purposely dropped (to lower latency). OOO: The number of packets we've received out-of-order Kpkts: The number of packets we've received / 1000.
Reporting problems There's a couple of things that can make calls sound bad using the jitterbuffer: The JB and PLC can make your calls sound better, but they can't fix everything. If you lost 10 frames in a row, it can't possibly fix that. It really can't help much more than one or two consecutive frames.
Bad timestamps: If whatever is generating timestamps to be sent to you generates nonsensical timestamps, it can confuse the jitterbuffer. In particular, discontinuities in timestamps will really upset it: Things like timestamps sequences which go 0, 20, 40, 60, 80, 34000, 34020, 34040, 34060... It's going to think you've got about 34 seconds of jitter in this case, etc.. The right solution to this is to find out what's causing the sender to send us such nonsense, and fix that. But we should also figure out how to make the receiver more robust in cases like this.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
140
chan_iax2 will actually help fix this a bit if it's more than 3 seconds or so, but at some point we should try to think of a better way to detect this kind of thing and resynchronize. Different clock rates are handled very gracefully though; it will actually deal with a sender sending 20% faster or slower than you expect just fine. Really strange network delays: If your network "pauses" for like 5 seconds, and then when it restarts, you are sent some packets that are 5 seconds old, we are going to see that as a lot of jitter. We already throw away up to the worst 20 frames like this, though, and the "maxjitterbuffer" parameter should put a limit on what we do in this case.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
141
mISDN
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
142
Introduction to mISDN
This package contains the mISDN Channel Driver for the Asterisk PBX. It supports every mISDN Hardware and provides an interface for Asterisk.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
143
mISDN Features
NT and TE mode PP and PMP mode BRI and PRI (with BNE1 and BN2E1 Cards) Hardware bridging DTMF detection in HW+mISDNdsp Display messages on phones (on those that support it) app_SendText HOLD/RETRIEVE/TRANSFER on ISDN phones : ) Allow/restrict user number presentation Volume control Crypting with mISDNdsp (Blowfish) Data (HDLC) callthrough Data calling (with app_ptyfork +pppd) Echo cancellation Call deflection Some others
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
144
That's all! Follow the instructions in the mISDN Package for how to load the Kernel Modules. Also install process described in http://www.misdn.org/index.php/Installi ng_mISDN
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
145
mISDN Pre-Requisites
To compile and install this driver, you'll need at least one mISDN Driver and the mISDNuser package. Chan_misdn works with both, the current release version and the development (svn trunk) version of Asterisk. You should use Kernels = 2.6.9
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
146
mISDN Configuration
First of all you must configure the mISDN drivers, please follow the instructions in the mISDN package to do that, the main config file and config script is:
/etc/init.d/misdn-init and /etc/misdn-init.conf
Now you will want to configure the misdn.conf file which resides in the Asterisk config directory (normally /etc/asterisk). misdn.conf: [general] subsection The misdn.conf file contains a "general" subsection, and user subsections which contain misdn port settings and different Asterisk contexts. In the general subsection you can set options that are not directly port related. There is for example the very important debug variable which you can set from the Asterisk cli (command line interface) or in this configuration file, bigger numbers will lead to more debug output. There's also a trace file option, which takes a path+filename where debug output is written to. misdn.conf: [default] subsection The default subsection is another special subsection which can contain all the options available in the user/port subsections. The user/port subsections inherit their parameters from the default subsection. misdn.conf: user/port subsections The user subsections have names which are unequal to "general". Those subsections contain the ports variable which mean the mISDN Ports. Here you can add multiple ports, comma separated. Especially for TE-Mode Ports there is a msns option. This option tells the chan_misdn driver to listen for incoming calls with the given msns, you can insert a '' as single msn, which leads to getting every incoming call. If you want to share on PMP TE S0 with Asterisk and a phone or ISDN card you should insert here the msns which you assign to Asterisk. Finally a context variable resides in the user subsections, which tells chan_misdn where to send incoming calls to in the Asterisk dial plan (extension.conf).* Dial and Options String The dial string of chan_misdn got more complex, because we added more features, so the generic dial string looks like:
mISDN/<port>[:bchannel]|g:<group>/<extension>[/<OPTIONSSTRING>]
The Optionsstring looks Like:
:<optchar><optarg>:<optchar><optarg>...
The ":" character is the delimiter. The available options are:
a - Have Asterisk detect DTMF tones on called channel c - Make crypted outgoing call, optarg is keyindex d - Send display text to called phone, text is the optarg e - Perform echo cancelation on this channel, takes taps as optarg (32,64,128,256) e! - Disable echo cancelation on this channel f - Enable fax detection h - Make digital outgoing call h1 - Make HDLC mode digital outgoing call i - Ignore detected DTMF tones, don't signal them to Asterisk, they will be transported inband. jb - Set jitter buffer length, optarg is length jt - Set jitter buffer upper threshold, optarg is threshold jn - Disable jitter buffer n - Disable mISDN DSP on channel. Disables: echo cancel, DTMF detection, and volume control. p - Caller ID presentation, optarg is either 'allowed' or 'restricted' s - Send Non-inband DTMF as inband vr - Rx gain control, optarg is gain vt - Tx gain control, optarg is gain
chan_misdn registers a new dial plan application "misdn_set_opt" when loaded. This application takes the Optionsstring as argument. The Syntax is:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
147
misdn_set_opt(<OPTIONSSTRING>)
When you set options in the dialstring, the options are set in the external channel. When you set options with misdn_set_opt, they are set in the current incoming channel. So if you like to use static encryption, the scenario looks as follows:
Phone1 --> * Box 1 --> PSTN_TE PSTN_TE --> * Box 2 --> Phone2
The encryption must be done on the PSTN sides, so the dialplan on the boxes are:
Box 1:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
148
clean -> pid (cleans a broken call, use with care, leads often to a segmentation fault) send -> display (sends a Text Message to a Asterisk channel, this channel must be an misdn channel) set -> debug (sets debug level) show -> config (shows the configuration options) channels (shows the current active misdn channels) channel (shows details about the given misdn channels) stacks (shows the current ports, their protocols and states) fullstacks (shows the current active and inactive misdn channels) restart -> port (restarts given port (L2 Restart) ) - reload (reloads misdn.conf)
You can only use "misdn send display" when an Asterisk channel is created and isdn is in the correct state. "correct state" means that you have established a call to another phone (must not be isdn though). Then you use it like this:
misdn send display mISDN/1/101 "Hello World!"
where 1 is the Port of the Card where the phone is plugged in, and 101 is the msn (callerid) of the Phone to send the text to.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
149
mISDN Variables
mISDN Exports/Imports a few Variables:
MISDN_ADDRESS_COMPLETE : Is either set to 1 from the Provider, or you can set it to 1 to force a sending complete.*
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
150
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
151
mISDN Examples
Here are some examples of how to use chan_misdn in the dialplan (extensions.conf):
[globals] OUT_PORT=1 ; The physical Port of the Card OUT_GROUP=ExternE1 ; The Group of Ports defined in misdn.conf [misdnIn] exten => _X.,1,Dial(mISDN/${OUT_PORT}/${EXTEN}) exten => _0X.,1,Dial(mISDN/g:${OUT_GROUP}/${EXTEN:1}) exten => _1X.,1,Dial(mISDN/g:${OUT_GROUP}/${EXTEN:1}/:dHello) exten => _1X.,1,Dial(mISDN/g:${OUT_GROUP}/${EXTEN:1}/:dHello Test:n)
On the last line, you will notice the last argument (Hello); this is sent as Display Message to the Phone.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
152
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
153
Local Channel
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
154
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
155
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
156
[devices] exten => 201,1,Verbose(2,Dial another part of the dialplan via the Local chan) exten => 201,n,Verbose(2,Outside channel: ${CHANNEL}) exten => 201,n,Dial(Local/201@extensions) exten => 201,n,Hangup() [extensions] exten => 201,1,Verbose(2,Made it to the Local channel) exten => 201,n,Verbose(2,Inside channel: ${CHANNEL}) exten => 201,n,Dial(SIP/some-named-extension,30) exten => 201,n,Hangup()
The output of the dialplan would look something like the following. The output has been broken up with some commentary to explain what we're looking at.
Executing [201@devices:1] Verbose("SIP/my_desk_phone-00000014", "2,Dial another part of the dialplan via the Local chan") in new stack == Dial another part of the dialplan via the Local chan
We dial extension 201 from SIP/my_desk_phone which has entered the [devices] context. The first line simply outputs some information via the Verbose() application.
Executing [201@devices:2] Verbose("SIP/my_desk_phone-00000014", "2,Outside channel: SIP/my_desk_phone-00000014") in new stack == Outside channel: SIP/my_desk_phone-00000014
The next line is another Verbose() application statement that tells us our current channel name. We can see that the channel executing the current dialplan is a desk phone (aptly named 'my_desk_phone').
Executing [201@devices:3] Dial("SIP/my_desk_phone-00000014", "Local/201@extensions") in new stack Called 201@extensions
Now the third step in our dialplan executes the Dial() application which calls extension 201 in the [extensions] context of our dialplan. There is no requirement that we use the same extension number - we could have just as easily used a named extension, or some other number. Remember that we're dialing another channel, but instead of dialing a device, we're "dialing" another part of the dialplan.
Executing [201@extensions:1] Verbose("Local/201@extensions-7cf4;2", "2,Made it to the Local channel") in new stack == Made it to the Local channel
Now we've verified we've dialed another part of the dialplan. We can see the channel executing the dialplan has changed to Local/201@extensions-7cf4;2. The part '-7cf4;2' is just the unique identifier, and will be different for you.
Executing [201@extensions:2] Verbose("Local/201@extensions-7cf4;2", "2,Inside channel: Local/201@extensions-7cf4;2") in new stack == Inside channel: Local/201@extensions-7cf4;2
Here we use the Verbose() application to see what our current channel name is. As you can see the current channel is a Local channel which we created from our SIP channel.
Executing [201@extensions:3] Dial("Local/201@extensions-7cf4;2", "SIP/some-named-extension,30") in new stack
And from here, we're using another Dial() application to call a SIP device configured in sip.conf as [some-named-extension]. Now that we understand a simple example of calling the Local channel, let's expand upon this example by using Local channels to call two devices at the same time, but delay calling one of the devices.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
157
[devices] exten => 201,1,Verbose(2,Call desk phone and cellphone but with delay) exten => 201,n,Dial(Local/deskphone-201@extensions&Local/cellphone-201@extensions,30) exten => 201,n,Voicemail(201@default,${IF($[${DIALSTATUS} = BUSY]?b:u)}) exten => 201,n,Hangup() [extensions] ; Dial the desk phone exten => deskphone-201,1,Verbose(2,Dialing desk phone of extension 201) exten => deskphone-201,n,Dial(SIP/0004f2040001) ; SIP device with MAC address ; of 0004f2040001 ; Dial the cellphone exten => cellphone-201,1,Verbose(2,Dialing cellphone of extension 201) exten => cellphone-201,n,Verbose(2,-- Waiting 6 seconds before dialing) exten => cellphone-201,n,Wait(6) exten => cellphone-201,n,Dial(DAHDI/g0/14165551212)
When someone dials extension 201 in the [devices] context, it will execute the Dial() application, and call two Local channels at the same time:
Local/deskphone-201@extensions Local/cellphone-201@extensions
It will then ring both of those extensions for 30 seconds before rolling over to the Voicemail() application and playing the appropriate voicemail recording depending on whether the ${DIALSTATUS} variable returned BUSY or not. When reaching the deskphone-201 extension, we execute the Dial() application which calls the SIP device configured as '0004f204001' (the MAC address of the device). When reaching the cellphone-201 extension, we dial the cellphone via the DAHDI channel using group zero (g0) and dialing phone number 1-416-555-1212.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
158
[devices] exten => 201,1,NoOp() exten => 201,n,Dial(Local/201@internal&Local/201@external,30) exten => 201,n,Voicemail(201@default,${IF($[${DIALSTATUS} = BUSY]?b:u)}) exten => 201,n,Hangup() [internal] exten => 201,1,Verbose(2,Placing internal call for extension 201) exten => 201,n,Set(CALLERID(name)=From Sales) exten => 201,n,Dial(SIP/0004f2040001,30) [external] exten => 201,1,Verbose(2,Placing external call for extension 201) exten => 201,n,Set(CALLERID(name)=Acme Cleaning) exten => 201,n,Dial(DAHDI/g0/14165551212)
With the dialplan above, we've sent two different callerIDs to the destinations:
"From Sales" was sent to the local device SIP/0004f2040001 "Acme Cleaning" was sent to the remote number 1-416-555-1212 via DAHDI
Because each of the channels is independent from the other, you could perform any other call manipulation you need. Perhaps the 1-416-555-1212 number is a cell phone and you know you can only ring that device for 18 seconds before the voicemail would pick up. You could then limit the length of time the external number is dialed, but still allow the internal device to be dialed for a longer period of time.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
159
Add the callfile information to a file such as 'callfile.new' or some other appropriately named file. Our dialplan will perform a lookup in the AstDB to determine which device to call, and will then call the device, and upon answer, Playback() the silence/1 (1 second of silence) and the tt-weasels sound files. Before looking at our dialplan, lets put some data into AstDB that we can then lookup from the dialplan. From the Asterisk CLI, run the following command:
*CLI> database put phones 201/device SIP/0004f2040001
We've now put the device destination (SIP/0004f2040001) into the 201/device key within the phones family. This will allow us to lookup the device location for extension 201 from the database. We can then verify our entry in the database using the 'database show' CLI command:
*CLI> database show /phones/201/device : SIP/0004f2040001
Now lets create the dialplan that will allow us to call SIP/0004f2040001 when we request extension 201 from the extensions context via our Local channel.
[devices] exten => 201,1,NoOp() exten => 201,n,Set(DEVICE=${DB(phones/${EXTEN}/device)}) exten => 201,n,GotoIf($[${ISNULL(${DEVICE})}]?hangup) ; if nothing returned, ; then hangup exten => 201,n,Dial(${DEVICE},30) exten => 201,n(hangup(),Hangup()
Then, we can perform a call to our device using the callfile by moving it into the /var/spool/asterisk/outgoing/ directory.
mv callfile.new /var/spool/asterisks/outgoing*
Then after a moment, you should see output on your console similar to the following, and your device ringing. Information about what is going on during the output has also been added throughout.
Attempting call on Local/201@devices for application Playback(silence/1&tt-weasels) (Retry 1)
You'll see the line above as soon as Asterisk gets the request from the callfile.
Executing [201@devices:1] NoOp("Local/201@devices-ecf0;2", "") in new stack Executing [201@devices:2] Set("Local/201@devices-ecf0;2", "DEVICE=SIP/0004f2040001") in new stack
This is where we performed our lookup in the AstDB. The value of SIP/0004f2040001 was then returned and saved to the DEVICE channel variable.
Executing [201@devices:3] GotoIf("Local/201@devices-ecf0;2", "0?hangup") in new stack
We perform a check to make sure ${DEVICE} isn't NULL. If it is, we'll just hangup here.
Executing [201@devices:4] Dial("Local/201@devices-ecf0;2", "SIP/0004f2040001,30") in new stack Called 000f2040001 SIP/0004f2040001-00000022 is ringing
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
160
At this point we now see the Local channel has been optimized out of the call path. This is important as we'll see in examples later. By default, the Local channel will try to optimize itself out of the call path as soon as it can. Now that the call has been established and audio is flowing, it gets out of the way.
<SIP/0004f2040001-00000022> Playing 'tt-weasels.ulaw' (language 'en') [Mar 1 13:35:23] NOTICE[16814]: pbx_spool.c:349 attempt_thread: Call completed to Local/201@devices
We can now see the tt-weasels file is played directly to the destination (instead of through the Local channel which was optimized out of the call path) and then a NOTICE stating the call was completed.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
161
1. 2. 3. 4. 5. 6. 7.
SIP device PHONE_A calls Asterisk via a SIP INVITE Asterisk accepts the INVITE and then starts processing dialplan logic in the [internal] context Our dialplan calls Dial(Local/2@services) - notice no /n The Local channel then executes dialplan at extension 2 within the [services] context Extension 2 within [services] then performs Dial() to PHONE_B with the line: Dial(SIP/PHONE_B,,L(60000:45000:15000)) SIP/PHONE_B then answers the call Even though the L option was given when dialing the SIP device, the L information is stored in the channel that is doing the Dial() which is the Local channel, and not the endpoint SIP channel. 8. The Local channel in the middle, containing the information for tracking the time allowance of the call, is then optimized out of the call path, losing all information about when to terminate the call. 9. SIP/PHONE_A and SIP/PHONE_B then continue talking indefinitely.
Now, if we were to add /n to our dialplan at step three (3) then we would force the Local channel to stay in the call path, and the L() option associated with the Dial() from the Local channel would remain, and our warning sounds and timing would work as expected. There are two workarounds for the above described scenario:
1. Use what we just described, Dial(Local/2@services/n) to cause the Local channel to remain in the call path so that the L() option used inside the Local channel is not discarded when optimization is performed. 2. Place the L() option at the outermost part of the path so that when the middle is optimized out of the call path, the information required to make L() work is associated with the outside channel. The L information will then be stored on the calling channel, which is PHONE_A. For example:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
162
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
163
'n' - Adding "/n" at the end of the string will make the Local channel not do a native transfer (the "n" stands for "n"o release) upon the remote end answering the line. This is an esoteric, but important feature if you expect the Local channel to handle calls exactly like a normal channel. If you do not have the "no release" feature set, then as soon as the destination (inside of the Local channel) answers the line and one audio frame passes, the variables and dial plan will revert back to that of the original call, and the Local channel will become a zombie and be removed from the active channels list. This is desirable in some circumstances, but can result in unexpected dialplan behavior if you are doing fancy things with variables in your call handling. 'j' - Adding "/j" at the end of the string allows you to use the generic jitterbuffer on incoming calls going to Asterisk applications. For example, this would allow you to use a jitterbuffer for an incoming SIP call to Voicemail by putting a Local channel in the middle. The 'j' option must be used in conjunction with the 'n' option to make sure that the Local channel does not get optimized out of the call. This option is available starting in the Asterisk 1.6.0 branch. 'm' - Using the "/m" option will cause the Local channel to forward music on hold (MoH) start and stop requests. Normally the Local channel acts on them and it is started or stopped on the Local channel itself. This options allows those requests to be forwarded through the Local channel. This option is available starting in the Asterisk 1.4 branch. 'b' - The "/b" option causes the Local channel to return the actual channel that is behind it when queried. This is useful for transfer scenarios as the actual channel will be transferred, not the Local channel.
This option is available starting in the Asterisk 1.6.0 branch.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
164
Mobile Channel
chan_mobile pages
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
165
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
166
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
167
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
168
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
169
Configuring chan_mobile
The configuration file for chan_mobile is /etc/asterisk/mobile.conf. It is a normal Asterisk config file consisting of sections and key=value pairs. See configs/mobile.conf.sample for an example and an explanation of the configuration.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
170
Using chan_mobile
chan_mobile.so must be loaded either by loading it using the Asterisk CLI, or by adding it to /etc/asterisk/modules.conf Search for your bluetooth devices using the CLI command 'mobile search'. Be patient with this command as it will take 8 - 10 seconds to do the discovery. This requires a free adapter. Headsets will generally have to be put into 'pairing' mode before they will show up here. This will return something like the following :*CLI> mobile search Address Name Usable Type Port 00:12:56:90:6E:00 LG TU500 Yes Phone 4 00:80:C8:35:52:78 Toaster No Headset 0 00:0B:9E:11:74:A5 Hello II Plus Yes Headset 1 00:0F:86:0E:AE:42 Daves Blackberry Yes Phone 7
This is a list of all bluetooth devices seen and whether or not they are usable with chan_mobile. The Address field contains the 'bd address' of the device. This is like an ethernet mac address. The Name field is whatever is configured into the device as its name. The Usable field tells you whether or not the device supports the Bluetooth Handsfree Profile or Headset profile. The Type field tells you whether the device is usable as a Phone line (FXO) or a headset (FXS) The Port field is the number to put in the configuration file. Choose which device(s) you want to use and edit /etc/asterisk/mobile.conf. There is a sample included with the Asterisk-addons source under configs/mobile.conf.sample. Be sure to configure the right bd address and port number from the search. If you want inbound calls on a device to go to a specific context, add a context= line, otherwise the default will be used. The 'id' of the device [bitinbrackets] can be anything you like, just make it unique. If you are configuring a Headset be sure to include the type=headset line, if left out it defaults to phone. The CLI command 'mobile show devices' can be used at any time to show the status of configured devices, and whether or not the device is capable of sending / receiving SMS via bluetooth.
*CLI> mobile show devices ID Address Group Adapter Connected State SMS headset 00:0B:9E:11:AE:C6 0 blue No Init No LGTU550 00:E0:91:7F:46:44 1 dlink No Init No
As each phone is connected you will see a message on the Asterisk console :Loaded chan_mobile.so => (Bluetooth Mobile Device Channel Driver) Bluetooth Device blackberry has connected. Bluetooth Device dave has connected.
To make outbound calls, add something to you Dialplan like the following :- (modify to suit)
This will call your headset, once you answer, Asterisk will call NNNNN at context context
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
171
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
172
MobileStatus Application
chan_mobile also registers an application named MobileStatus. You can use this in your Dialplan to determine the 'state' of a device. For example, suppose you wanted to call dave's extension, but only if he was in the office. You could test to see if his mobile phone was attached to Asterisk, if it is dial his extension, otherwise dial his mobile phone.
1 = Disconnected. i.e. Device not in range of Asterisk, or turned off etc etc 2 = Connected and Not on a call. i.e. Free 3 = Connected and on a call. i.e. Busy
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
173
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
174
[incoming-mobile] exten => sms,1,Verbose(Incoming SMS from ${SMSSRC} ${SMSTXT}) exten => sms,n,Hangup()
The above will just print the message on the console. If you use res_jabber, you could do something like this :-
[incoming-mobile] exten => sms,1,JabberSend(transport,[email protected],SMS from ${SMSRC} ${SMSTXT}) exten => sms,2,Hangup()
To send an SMS, use the application MobileSendSMS like the following :-
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
175
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
176
Unistim
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
177
1. You need to append /r to the dial string. 2. The first digit must be from 0 to 7 (inclusive). It's the 'melody' selection. 3. The second digit (optional) must be from 0 to 3 (inclusive). It's the ring volume. 0 still produce a sound.
Select the ring style #1 and the default volume :
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
178
Country code
You can use the following codes for country= (used for dial tone) - us fr au nl uk fi es jp no at nz tw cl se be sg il br hu lt pl za pt ee mx in de ch dk cn If you want a correct ring, busy and congestion tone, you also need a valid entry in indications.conf and check if res_indications.so is loaded. language= is also supported but it's only used by Asterisk (for more information see http://www.voip-info.org/wiki/view/Asterisk+multi-lang uage ). The end user interface of the phone will stay in english.
Bookmarks, Softkeys Layout
|--------------------| | 5 2 | | 4 1 | | 3 0 |
When the second letter of bookmark= is @, then the first character is used for positioning this entry If this option is omitted, the bookmark will be added to the next available sofkey Also work for linelabel (example : linelabel="5@Line 123") You can change a softkey programmatically with SendText(@position@icon@label@extension) ex: SendText(@1@55@Stop Forwd@908)
Autoprovisioning
This feature must only be used on a trusted network. It's very insecure : all unistim phones will be able to use your asterisk pbx. You must add an entry called template. Each new phones will be based on this profile. You must set a least line=>. This value will be incremented when a new phone is registered. device= must not be specified. By default, the phone will asks for a number. It will be added into the dialplan. Add extension=line for using the generated line number instead.
Example :
If a first phone have a mac = 006038abcdef, a new device named USTM/100@006038abcdef will be created. If a second phone have a mac = 006038000000, it will be named USTM/101@006038000000 and so on. When autoprovisioning=tn, new phones will ask for a tn, if this number match a tn= entry in a device, this phone will be mapped into.
Example:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
179
Use the two keys located in the middle of the Fixed feature keys row (on the bottom of the phone) to enter call history. By default, chan_unistim add any incoming and outgoing calls in files (/var/log/asterisk/unistimHistory). It can be a privacy issue, you can disable this feature by adding callhistory=0. If history files were created, you also need to delete them. callhistory=0 will NOT disable normal asterisk CDR logs.
Forward
Billing - accountcode amaflags Call Group - callgroup pickupgroup (untested) Music On Hold - musiconhold Language - language (see section Coutry Code) RTP NAT - nat (control ast_rtp_setnat, default = 0. Obscure behaviour)
Trunking
It's not possible to connect a Nortel Succession/Meridian/BCM to Asterisk via chan_unistim. Use either E1/T1 trunks, or buy UTPS (UNISTIM Terminal Proxy Server) from Nortel.
Wiki, Additional infos, Comments :
http://www.voip-info.org/wiki-Asterisk+UNISTIM+channels
*BSD :
Comment #define HAVE_IP_PKTINFO in chan_unistim.c Set public_ip with an IP of your computer Check if unistim.conf is in the correct directory
Issues
As always, NAT can be tricky. If a phone is behind a NAT, you should port forward UDP 5000 (or change general port= in unistim.conf) and UDP 10000 (or change yourphone rtp_port=) Only one phone per public IP (multiple phones behind the same NAT don't work). You can either : Setup a VPN Install asterisk inside your NAT. You can use IAX2 trunking if you're master asterisk is outside. If asterisk is behind a NAT, you must set general public_ip= with your public IP. If you don't do that or the bindaddr is invalid (or no longer valid, eg dynamic IP), phones should be able to display messages but will be unable to send/receive RTP packets (no sound) Don't forget : this work is based entirely on a reverse engineering, so you may encounter compatibility issues. At this time, I know three ways to establish a RTP session. You can modify yourphone rtp_method= with 0, 1, 2 or 3. 0 is the default method, should work. 1 can be used on new firmware (black i2004) and 2 on old violet i2004. 3 can be used on black i2004 with chrome. If you have difficulties, try unistim debug and set verbose 3 on the asterisk CLI. For extra debug, uncomment #define DUMP_PACKET 1 and recompile chan_unistim.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
180
Protocol information
Protocol versions
31 October 2008 UNIStim Firmware Release 3.1 for IP Phones, includes:
0604DCG for Phase II IP Phones (2001, 2002 2004), 0621C6H for IP Phone 2007, 0623C6J, 0624C6J, 0625C6J and 0627C6J for IP Phone 1110, 1120E,1140E and 1150E respectively 062AC6J for IP Phone 1210, 1220, and 1230
27 February 2009 UNIStim Firmware Release 3.2 for IP Phones, including:
0604DCJ for Phase II IP Phones (2001, 2002 & 2004), 0621C6M for IP Phone 2007, 0623C6N, 0624C6N, 0625C6N and 0627C6N for IP Phone 1110, 1120E,1140E and 1150E respectively 062AC6N for IP Phone 1210, 1220, and 1230
30 June 2009 UNIStim Firmware Release 3.3 for IP Phones:
0604DCL for Phase II IP Phones (2001, 2002 & 2004), 0621C6P for IP Phone 2007, 0623C6R, 0624C6R, 0625C6R and 0627C6R for IP Phone 1110, 1120E,1140E and 1150E respectively 062AC6R for IP Phone 1210, 1220, and 1230
27 November 2009 UNIStim Software Release 4.0 for IP Phones, includes:
0621C7A for IP Phone 2007, 0623C7F, 0624C7F, 0625C7F and 0627C7F for IP Phone 1110, 1120E,1140E and 1150E respectively 062AC7F for IP Phone 1210, 1220, and 1230
28 February 2010 UNIStim Software Release 4.1 IP Deskphone Software
0621C7D / 2007 IP Deskphone 0623C7J / 1110 IP Deskphone 0624C7J / 1120E IP Deskphone 0625C7J / 1140E IP Deskphone 0627C7J / 1150E IP Deskphone 0626C7J / 1165E IP Deskphone 062AC7J / 1210 IP Deskphone 062AC7J / 1220 IP Deskphone 062AC7J / 1230 IP Deskphone
29 2010 UNIStim Software Release 4.2 IP Deskphone Software
0621C7G / 2007 IP Deskphone 0623C7M / 1110 IP Deskphone 0624C7M / 1120E IP Deskphone 0625C7M / 1140E IP Deskphone 0627C7M / 1150E IP Deskphone 0626C7M / 1165E IP Deskphone 062AC7M / 1210 IP Deskphone 062AC7M / 1220 IP Deskphone 062AC7M / 1230 IP Deskphone
Protocol description
Query Audio Manager (16 xx 00 xx)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
181
Note: Ensure that the handshake commands 1A 04 01 08 1A 07 07 01 23 45 67 are sent to i2004 before sending the commands in column 2. (Requests attributes of the Audio manager) 16 05 00 01 00 Note: Last byte can contain any value. The message length should be 5. If the length is wrong it is ignored e.g. send 16 04 00 01 16 06 00 01 00 03 (Requests options setting of the Audio manager) 16 05 00 02 03 Note: Last byte can contain any value. The message length should be 5. If the length is wrong it is ignored. (Requests Alerting selection) 16 05 00 04 0F Note: Last byte can contain any value. The message length should be 5. If the length is wrong it is ignored. (Requests adjustable Rx volume information command) 16 05 00 08 00 Note: Last byte can contain any value. The message length should be 5. If the length is wrong it is ignored. (Requests the i2004 to send the APB's Default Rx Volume command. The APB Number or stream based tone is provided in the last byte of the command below) 16 05 00 10 00 (none) 16 05 00 10 01 (Audio parameter bank 1, NBHS) 16 05 00 10 02 (Audio parameter bank 2, NBHDS) 16 05 00 10 03 (Audio parameter bank 3, NBHF) 16 05 00 10 04 (Audio parameter bank 4, WBHS) 16 05 00 10 05 (Audio parameter bank 5, WBHDS) 16 05 00 10 06 (Audio parameter bank 6, WBHF) 16 05 00 10 07 (Audio parameter bank 7,) 16 05 00 10 08 (Audio parameter bank 8,) 16 05 00 10 09 (Audio parameter bank 9,) 16 05 00 10 0A (Audio parameter bank 0xA,) 16 05 00 10 0B (Audio parameter bank 0xB,) 16 05 00 10 0C (Audio parameter bank 0xC,) 16 05 00 10 0D (Audio parameter bank 0xD,) 16 05 00 10 0E (Audio parameter bank 0xE,) 16 05 00 10 0F (Audio parameter bank 0xF,) 16 05 00 10 10 (Alerting tone) 16 05 00 10 11 (Special tones) 16 05 00 10 12 (Paging tones) 16 05 00 10 13 (Not Defined) 16 05 00 10 1x (Not Defined) (Set the volume range in configuration message for each of the APBs and for alerting, paging and special tones (see below) and then send the following commands) (Requests handset status, when NBHS is 1) connected 2) disconnected) 16 05 00 40 09 Note: Last byte can contain any value. The message length should be 5. If the length is wrong it is ignored (Requests headset status, when HDS is disconnected) 16 05 00 80 0A (Requests headset status, when HDS is connected) 16 05 00 80 0A Note: Last byte can contain any value. The message length should be 5. If the length is wrong it is ignored (Requests handset and headset status when NBHS and HDS are disconnected) 16 05 00 C0 05
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
182
(Requests handset and headset status when NBHS and HDS are connected) 16 05 00 C0 05 (Send an invalid message) 16 03 00 (Send an invalid message. Is this an invalid msg??) 16 06 00 22 22 22 Query Supervisory headset status (16 03 01) 16 03 01 Audio Manager Options (16 04 02 xx) (Maximum tone volume is one level lower than physical maximum Volume level adjustments are not performed locally in the i2004 Adjustable Rx volume reports not sent to the NI when volume keys are pressed Single tone frequency NOT sent to HS port while call in progress. Single tone frequency NOT sent to HD port while call in progress. Automatic noise squelching disabled. HD key pressed command sent when i2004 receives make/break sequence.) 16 04 02 00 (Maximum tone volume is set to the physical maximum) 16 04 02 01 then requests options setting of the Audio manager by sending 16 04 00 02) (Volume level adjustments are performed locally in the i2004) 16 04 02 02 (then requests options setting of the Audio manager by sending 16 04 00 02) (Adjustable Rx volume reports sent to the NI when volume keys are pressed) 16 04 02 04 (then requests options setting of the Audio manager by sending 16 04 00 02) (Single tone frequency sent to HS port while call in progress) 16 04 02 08 (then requests options setting of the Audio manager by sending 16 04 00 02) (Single tone frequency sent to HD port while call in progress) 16 04 02 10 (then requests options setting of the Audio manager by sending 16 04 00 02) (Automatic noise squelching enabled.) 16 04 02 20 (then requests options setting of the Audio manager by sending 16 04 00 02) (Headset Rfeature Key Pressed command sent when i2004 receives make/break sequence.) 16 04 02 40 (then requests options setting of the Audio manager by sending 16 04 00 02) (In this case both bit 1 and bit 3 are set, hence Volume level adjustments are performed locally in the i2004 and Single tone frequency sent to HS port while call in progress.) 16 04 02 0A Mute/un-mute (16 xx 04 xx...) (In this case two phones are conneted. Phone 1 is given the ID 47.129.31.35 and phone 2 is given the ID 47.129.31.36. Commands are sent to phone 1 ) (TX is muted on stream ID 00) 16 05 04 01 00 (TX is un-muted on stream ID 00) 16 05 04 00 00 (RX is muted on stream ID 00) 16 05 04 03 00 (RX is un-muted on stream ID 00) 16 05 04 02 00 (TX is muted on stream ID 00, Rx is un-muted on stream ID 00) 16 07 04 01 00 02 00 (TX is un-muted on stream ID 00, Rx is muted on stream ID 00)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
183
16 07 04 00 00 03 00 (TX is un-muted on stream ID 00, Rx is un-muted on stream ID 00) 16 07 04 00 00 02 00 Transducer Based tone on (16 04 10 xx) (Alerting on) 16 04 10 00 (Special tones on, played at down loaded tone volume level) 16 04 10 01 (paging on) 16 04 10 02 (not defined) 16 04 10 03 (Alerting on, played at two steps lower than down loaded tone volume level) 16 04 10 08 (Special tones on, played at two steps lower than down loaded tone volume level) 16 04 10 09 Transducer Based tone off (16 04 10 xx) 16 04 11 00 (Alerting off) 16 04 11 01 (Special tones off) 16 04 11 02 (paging off) 16 04 11 03 (not defined) Alerting tone configuration (16 05 12 xx xx) (Note: Volume range is set here for all tones. This should be noted when testing the volume level message) (HF speaker with different warbler select values, tone volume range set to max) 16 05 12 10 00 16 05 12 11 0F 16 05 12 12 0F 16 05 12 13 0F 16 05 12 14 0F 16 05 12 15 0F 16 05 12 16 0F 16 05 12 17 0F (HF speaker with different cadence select values, tone volume range set to max) 16 05 12 10 0F 16 05 12 10 1F 16 05 12 10 2F 16 05 12 10 3F 16 05 12 10 4F 16 05 12 10 5F 16 05 12 10 6F 16 05 12 10 7F (configure cadence with alerting tone cadence download message before sending this message) (HS speaker with different warbler select values, tone volume level set to max) 16 05 12 00 0F 16 05 12 01 0F 16 05 12 02 0F 16 05 12 03 0F 16 05 12 04 0F 16 05 12 05 0F 16 05 12 06 0F 16 05 12 07 0F (HS speaker with different cadence select values, tone volume range set to max) 16 05 12 00 0F 16 05 12 00 1F 16 05 12 00 2F 16 05 12 00 3F 16 05 12 00 4F 16 05 12 00 5F
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
184
16 05 12 00 6F 16 05 12 00 7F (configure cadence with alerting tone cadence download message before sending this message) (HD speaker with different warbler select values, tone volume range set to max) 16 05 12 08 0F 16 05 12 09 0F 16 05 12 0A 0F 16 05 12 0B 0F 16 05 12 0C 0F 16 05 12 0D 0F 16 05 12 0E 0F 16 05 12 0F 0F (HD speaker with different cadence select values, tone volume level set to max) 16 05 12 08 0F 16 05 12 08 1F 16 05 12 08 2F 16 05 12 08 3F 16 05 12 08 4F 16 05 12 08 5F 16 05 12 08 6F 16 05 12 08 7F (configure cadence with alerting tone cadence download message before sending this message) Special tone configuration (16 06 13 xx xx) (Note: Volume range is set here for all tones. This should be noted when testing the volume level message) (HF speaker with different tones, tone volume range is varied) 16 06 13 10 00 01 16 06 13 10 01 01 16 06 13 10 08 01 16 06 13 10 02 07 16 06 13 10 03 07 16 06 13 10 04 11 16 06 13 10 05 11 16 06 13 10 06 18 16 06 13 10 07 18 16 06 13 10 08 1F (HF speaker with different cadences and tones; tone volume level is varied) 16 06 13 10 00 01 16 06 13 10 10 01 16 06 13 10 20 07 16 06 13 10 30 07 16 06 13 10 40 11 16 06 13 10 50 11 16 06 13 10 60 18 16 06 13 10 70 18 (configure cadence with special tone cadence download message before sending this message) (HS speaker with different tones, tone volume range is varied) 16 06 13 00 00 01 16 06 13 00 01 01 16 06 13 00 02 07 16 06 13 00 03 07 16 06 13 00 04 11 16 06 13 00 05 11 16 06 13 00 06 18 16 06 13 00 07 18 (HS speaker with different cadences and tones; tone volume range is varied) 16 06 13 00 00 01 16 06 13 00 10 01 16 06 13 00 20 07 16 06 13 00 30 07 16 06 13 00 40 11 16 06 13 00 50 11 16 06 13 00 60 18
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
185
16 06 13 00 70 18 (configure cadence with special tone cadence download message before sending this message) (HD speaker with different tones, tone volume range is varied) 16 06 13 08 00 01 16 06 13 08 01 01 16 06 13 08 02 07 16 06 13 08 03 07 16 06 13 08 04 11 16 06 13 08 05 11 16 06 13 08 06 18 16 06 13 08 07 18 (HD speaker with different cadences and tones; tone volume range is varied) 16 06 13 08 00 01 16 06 13 08 10 01 16 06 13 08 20 07 16 06 13 08 30 07 16 06 13 08 40 11 16 06 13 08 50 11 16 06 13 08 60 18 16 06 13 08 70 18 (configure cadence with special tone cadence download message before sending this message) Paging tone configuration (16 05 14 xx xx) (Note: Volume range is set here for all tones. This should be noted when testing the volume level message) (HF speaker with different cadence select values, tone volume range set to max) 16 05 14 10 0F 16 05 14 10 1F 16 05 14 10 2F 16 05 14 10 3F 16 05 14 10 4F 16 05 14 10 5F 16 05 14 10 6F 16 05 14 10 7F (configure cadence with paging tone cadence download message before sending this message) (HS speaker with different cadence select values, tone volume range set to max) 16 05 14 00 0F 16 05 14 00 1F 16 05 14 00 2F 16 05 14 00 3F 16 05 14 00 4F 16 05 14 00 5F 16 05 14 00 6F 16 05 14 00 7F (configure cadence with paging tone cadence download message before sending this message) (HD speaker with different cadence select values, tone volume level set to max) 16 05 14 08 0F 16 05 14 08 1F 16 05 14 08 2F 16 05 14 08 3F 16 05 14 08 4F 16 05 14 08 5F 16 05 14 08 6F 16 05 14 08 7F (configure cadence with paging tone cadence download message before sending this message) Alerting Tone Cadence Download (16 xx 15 xx xx...) 16 08 15 00 0A 0f 14 1E (.5 sec on, 0.75 sec off; 1 sec on 1.5 sec off, cyclic) 16 0C 15 01 0A 0f 14 1E 05 0A 0A 14 (.5 sec on, 0.75 sec off; 1 sec on 1.5 sec off; 0.25sec on, 0.5sec off; 0.5 sec on, 1 sec off , one shot)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
186
Special Tone Cadence Download (16 xx 16 xx xx...) 16 05 16 0A 10 (125ms on, 200 ms off) 16 09 16 0A 10 14 1E (125ms on, 200 ms off; 250ms on, 375ms off ) Paging Tone Cadence Download (16 xx 17 xx xx...) 16 06 17 01 0A 10 (125ms on, 200 ms off, 250HZ) 16 06 17 04 05 10 (62.5ms on, 200 ms off, 500 Hz) 16 09 17 01 0A 10 10 14 1E (125ms on, 200 ms off; 250ms on, 375ms off, 250 Hz, 100Hz ) 16 0C 17 01 0A 10 04 14 1E 10 0A 10 (125ms on, 200 ms off; 250ms on, 375ms off; 125ms on, 200 ms off, 250Hz, 1000Hz, 500 Hz ) 16 0C 17 01 1E 10 12 3c 1E 10 28 10 (375ms on, 200 ms off; 750ms on, 375ms off; 500ms on, 200 ms off, 250Hz, (333Hz,1000Hz), 500 Hz ) Transducer Based Tone Volume Level (16 04 18 xx) (Ensure that the volume range is set properly in the alerting, special and paging tone configuration e.g if the volume range is set to zero, this message will always output max volume) (Different volume level for alerting tone. Note: Send the command below and then send the alerting on command and alerting off commands) 16 04 18 00 16 04 18 10 16 04 18 20 16 04 18 30 16 04 18 40 16 04 18 50 16 04 18 60 16 04 18 70 16 04 18 80 16 04 18 90 16 04 18 F0 (HF:Volume range for alerting tone is changed here using these commands) 16 05 12 10 0F 16 05 12 10 00 16 05 12 10 04 (HD:Volume range for alerting tone is changed here using these commands) 16 05 12 08 0F 16 05 12 08 00 16 05 12 08 04 (Different volume level for special tone) 16 04 18 01 16 04 18 11 16 04 18 21 16 04 18 31 16 04 18 41 16 04 18 51 16 04 18 61 16 04 18 71 16 04 18 81 16 04 18 91 16 04 18 A1 16 04 18 B1 16 04 18 C1 16 04 18 D1
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
187
16 04 18 E1 16 04 18 F1 (HF:Volume range for special tone is changed here using these commands) 16 06 13 10 20 07 16 06 13 10 25 07 16 06 13 10 2F 07 (HD:Volume range for special tone is changed here using these commands) 16 06 13 08 20 07 16 06 13 08 25 07 16 06 13 08 2F 07 (Different volume level for paging tone) 16 04 18 02 16 04 18 12 16 04 18 22 16 04 18 32 16 04 18 42 16 04 18 52 16 04 18 62 16 04 18 72 16 04 18 82 16 04 18 92 16 04 18 F2 (HF:Volume range for paging tone is changed here using these commands) 16 05 14 10 0F 16 06 14 10 00 16 06 14 10 04 (HD:Volume range for paging tone is changed here using these commands) 16 06 14 08 0F 16 06 14 08 00 16 06 14 08 04 Alerting Tone Test (16 04 19 xx) (tones 667Hz, duration 50 ms and 500Hz duration 50 ms) 16 04 19 00 (tones 333Hz, duration 50 ms and 250Hz duration 50 ms) 16 04 19 01 (tones 333 Hz + 667 Hz duration 87.5 ms and 500Hz + 1000Hz duration 87.5 ms) 16 04 19 02 (tones 333 Hz, duration 137.5 ms; 500Hz duration 75 ms; 667Hz duration 75 ms) 16 04 19 03 (tones 500Hz, duration 100 ms and 667Hz duration 100 ms) 16 04 19 04 (tones 500Hz, duration 400 ms and 667Hz duration 400 ms) 16 04 19 05 (tones 250Hz, duration 100 ms and 333Hz duration 100 ms) 16 04 19 06 (tones 250Hz, duration 400 ms and 333 Hz, duration 400ms) 16 04 19 07 Visual Transducer Based Tones Enable (16 04 1A xx) Visual tone enabled 16 04 1A 01 (Visual tone disabled) 16 04 1A 00 Stream Based Tone On (16 06 1B xx xx xx) (Dial tone is summed with data on Rx stream 00 at volume level -3dBm0) 16 06 1B 00 00 08 (Dial tone replaces the voice on Rx stream 00 at volume level -6dBm0) 16 06 1B 80 00 10 (Dial tone is summed with voice on Tx stream 00 at volume level -3dBm0) 16 06 1B 40 00 08
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
188
(Dial tone replaces the voice on Tx stream 00 at volume level -3dBm0) 16 06 1B C0 00 08 (Line busy tone is summed with data on Rx stream 00 at volume level -3dBm0) 16 06 1B 02 00 08 (Line busy tone replaces the voice on Rx stream 00 at volume level -6dBm0) 16 06 1B 82 00 10 (Line busy tone is summed with voice on Tx stream 00 at volume level -3dBm0) 16 06 1B 42 00 08 (Line busy tone replaces the voice on Tx stream 00 at volume level -3dBm0) 16 06 1B C2 00 08 (ROH tone is summed with data on Rx stream 00 at volume level -3dBm0) 16 06 1B 05 00 08 (ROH tone replaces the voice on Rx stream 00 at volume level -6dBm0) 16 06 1B 85 00 10 (ROH tone is summed with voice on Tx stream 00 at volume level -3dBm0) 16 06 1B 45 00 08 (ROH tone replaces the voice on Tx stream 00 at volume level -3dBm0) 16 06 1B C5 00 08 (Recall dial tone is summed with data on Rx stream 00 at volume level -3dBm0) 16 06 1B 01 00 08 (Recall dial tone replaces the voice on Rx stream 00 at volume level -6dBm0) 16 06 1B 81 00 10 (Reorder tone is summed with data on Rx stream 00 at volume level -3dBm0) 16 06 1B 03 00 08 (Reorder dial tone replaces the voice on Rx stream 00 at volume level -6dBm0) 16 06 1B 83 00 10 (Audible Ringing tone is summed with data on Rx stream 00 at volume level -3dBm0) 16 06 1B 04 00 08 (Audible Ringing tone replaces the voice on Rx stream 00 at volume level -6dBm0) 16 06 1B 84 00 10 (Stream based tone ID 06 is summed with data on Rx stream 00 at volume level -3dBm0; Tone ID 06 is downloaded using both the frequency and cadence down load commands) 16 06 1B 06 00 08 (Stream based tone ID 06 replaces the voice on Rx stream 00 at volume level -6dBm0) 16 06 1B 86 00 10 (Stream based tone ID 0F is summed with data on Rx stream 00 at volume level -3dBm0; Tone ID 0x0F is downloaded using both the frequency and cadence down load commands) 16 06 1B 0F 00 08 (Stream based tone ID 0F replaces the voice on Rx stream 00 at volume level -6dBm0) 16 06 1B 8F 00 10 Stream Based Tone Off (16 05 1C xx xx) (Dial tone is turned off on Rx stream 00) 16 05 1C 00 00 (Dial tone is turned off on Tx stream 00) 16 05 1C 40 00 (Line busy tone is turned off on Rx stream 00) 16 05 1C 02 00 (Line busy tone is turned off on Tx stream 00) 16 05 1C 42 00 (ROH tone is turned off on Rx stream 00) 16 05 1C 05 00
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
189
(ROH tone is turned off on Tx stream 00) 16 05 1C 45 00 (Recall dial tone is turned off on Rx stream 00) 16 05 1C 01 00 (Reorder tone is turned off on Rx stream 00) 16 05 1C 03 00 (Audible Ringing tone is turned off on Rx stream 00) 16 05 1C 04 00 (Stream based tone ID 06 is turned off on Rx stream 00) 16 05 1C 06 00 (Stream based tone ID 0F is turned off on Rx stream 00) 16 05 1C 0F 00 Stream Based Tone Frequency Component List Download (up to 4 frequencies can be specified) (16 xx 1D xx...) Note: Frequency component download and cadence download commands sent to the i2004 first. Then send the stream based tone ID on command to verify that tones are turned on. 16 06 1D 06 2C CC (1400Hz ) 16 08 1D 07 2C CC 48 51 (1400 Hz and 2250Hz) Stream Based Tone Cadence Download (up to 4 cadences can be specified) (16 xx 1E xx...) Note: Frequency component download and cadence download commands sent to the i2004 first. Then send the stream based tone ID on command to verify that tones are turned on. 16 06 1E 26 0A 0A (200 ms on and 200 ms off with tone turned off after the full sequence) 16 08 1E 07 0A 0A 14 14 (20 ms on and 20 ms off for first cycle, 400 ms on and 400 ms off fo rthe second cycle with sequence repeated) 16 05 1E 26 0A (In this case tone off period is not specified hence tone is played until stream based tone off command is received. Select Adjustable Rx Volume (16 04 20 xx) 16 04 20 01 (Audio parameter block 1) 16 04 20 03 (Audio parameter block 3) 16 04 20 08 (Alerting Rx volume) 16 04 20 09 (Special tone Rx volume) 16 04 20 0a (Paging tone Rx volume) Set APB's Rx Volume Levels (16 05 21 xx xx) 16 05 21 01 25 (? Rx volume level 5 steps louder than System RLR) 16 05 21 01 05 (? Rx volume level 5 steps quieter than System RLR) Change Adjustable Rx Volume 16 03 22 (Rx volume level is one step quieter for the APB/tones selected through Select Adjustable Rx Volume command)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
190
16 03 23 (Rx volume level is one step louder for the APB/tones selected through Select Adjustable Rx Volume command) Adjust Default Rx Volume (16 04 24 xx) 16 04 24 01 (Default Rx volume level is one step quieter for the APB 1) 16 04 25 01 (Default Rx volume level is one step louder for the APB 1) Adjust APB's Tx and/or STMR Volume Level (16 04 26 xx) (First ensure that the Tx and STMR volume level are set to maximum by repeatedly (if needed) sending the command 16 04 26 F2 to APB2. Rest of the commands are sent to i2004 individually and then the query command below is used to verify if the commands are sent correctly) (Enable both Tx Vol adj. and STMR adj; Both Tx volume and STMR volume are one step louder on APB 2) 16 04 26 F2 (Enable both Tx Vol adj. and STMR adj; Both Tx volume and STMR volume are one step quieter on APB 2) 16 04 26 A2 (Enable Tx Vol adj. and disable STMR adj; Tx volume is one step louder on APB 3) 16 04 26 C3 (Enable Tx Vol adj. and disable STMR adj; Tx volume is one step quieter on APB 3) 16 04 26 83 (Disable both Tx Vol adj. and STMR adj on APB 1) 16 04 26 01 Query APB's Tx and/or STMR Volume Level (16 04 27 XX) (Query Tx volume level and STMR volume level on APB 2) 16 04 27 32 (Query STMR volume level on APB 1) 16 04 27 11 (Query STMR volume level on APB 2) 16 04 27 12 (Query STMR volume level on APB 3) 16 04 27 13 (Query Tx volume level on APB 1) 16 04 27 21 (Query Tx volume level on APB 2) 16 04 27 22 (Query Tx volume level on APB 3) 16 04 27 23 APB Download (16 xx-1F xx...) 16 09 28 FF AA 88 03 00 00 Open Audio Stream (16 xx 30 xx...) (If Audio stream is already open it has to be closed before another open audio stream command is sent) 16 15 30 00 00 00 00 01 00 13 89 00 00 13 89 00 00 2F 81 1F 23 (Open G711 ulaw Audio stream to 2F.81.1F.9F) 16 15 30 00 00 08 08 01 00 13 89 00 00 13 89 00 00 2F 81 1F 23 (Open G711 Alaw Audio stream to 2F.81.1F.9F) 16 15 30 00 00 12 12 01 00 13 89 00 00 13 89 00 00 2F 81 1F 23
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
191
(Open G729 Audio stream to 2F.81.1F.9F) 16 15 30 00 00 04 04 01 00 13 89 00 00 13 89 00 00 2F 81 1F 23 (Open G723? ulaw Audio stream to 2F.81.1F.9F) Close Audio Stream (16 05 31 xx xx) 16 05 31 00 00 Connect Transducer (16 06 32 xx xx xx) 16 06 32 C0 11 00 (Connect the set in Handset mode with no side tone) 16 06 32 C0 01 00 (Connect the set in Handset mode with side tone) 16 06 32 C1 12 00 (Connect the set in Headset mode with no side tone) 16 06 32 C1 02 00 (Connect the set in Headset mode with side tone) 16 06 32 C2 03 00 (Connect the set in Hands free mode) Frequency Response Specification (16 xx 33 xx...) Filter Block Download 16 xx 39 xx Voice Switching debug 16 04 35 11 (Full Tx, Disable switch loss bit) 16 04 35 12 (Full Rx, Disable switch loss bit) Voice Switching Parameter Download 16 08 36 01 2D 00 00 02 (APB 1, AGC threshold index 0, Rx virtual pad 0, Tx virtual pad 0, dynamic side tone enabled) Query RTCP Statistics 16 04 37 12 (queries RTCP bucket 2, resets RTCP bucket info.) Configure Vocoder Parameters 16 0A 38 00 00 CB 00 E0 00 A0 (For G711 ulaw 20 ms, NB) 16 0A 38 00 08 CB 00 E0 00 A0 (G711 Alaw 20 ms, NB) 16 0A 38 00 00 CB 01 E0 00 A0 (For G711 ulaw 10 ms, WB) 16 0A 38 00 08 CB 01 E0 00 A0 (G711 Alaw 10 ms, WB) 16 08 38 00 12 C1 C7 C5 (For G729 VAD On, High Pass Filter Enabled, Post Filter Enabled) 16 09 38 00 04 C9 C5 C7 C1 (G723 VAD On, High Pass Filter Enabled, Post Filter Enabled at 5.3 KHz) 16 09 38 00 04 C0 C7 C5 C9 (G723 VAD Off, High Pass Filter Enabled, Post Filter Enabled at 5.3 KHz) 16 09 38 00 04 C1 C5 C7 C8 (G723 VAD On, High Pass Filter Enabled, Post Filter Enabled at 6.3 KHz) 16 09 38 00 04 C0 C7 C5 C8 (G723 VAD Off, High Pass Filter Enabled, Post Filter Enabled at 6.3 KHz) Query RTCP Bucket's SDES Information (39 XX) (The first nibble in the last byte indicates the bucket ID) 16 04 39 21 16 04 39 22 16 04 39 23 16 04 39 24 16 04 39 25 16 04 39 26 16 04 39 27 16 04 39 01 16 04 39 12 16 04 39 23 16 04 39 34 16 04 39 45
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
192
16 04 39 56 16 04 39 67
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
193
Skinny
chan_skinny stuff
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
194
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
195
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
196
Keepalives
Been doing some mucking around with cisco phones. Things found out about keepalives documented here. It appears the minimum keepalive is 10. Any setting below this reverts to the the device setting 10 seconds. Keepalive timings seem to vary by device type (and probably firmware). Device 7960 7961 7920 F/Ware 7.2(3.0) 8.5.4(1.6 4.0-3-2 Proto 6 17 5 1st KA 15 Sec As set As set Behavior w/ no response KA, KA, KA, UNREG KA, KA*2, KA*2, UNREG KA, KA, KA, KA+Reset Conn
the 7960 will UNREG in 75 sec (ka@15, ka@35, ka@55, unreg@75) (straight after registration); or the 7960 will UNREG in 80 sec (ka@20, ka@40, ka@60, unreg@80) (after 1 keepalive ack sent); the 7961 will UNREG in 120 sec (ka@20, ka@60, ka@100, unreg@120).
Other info:
Devices appear to consider themselves still registered (with no indication provided to user) until the unregister/reset conn occurs. Devices generally do not respond to keepalives or reset their own timings (see below for exception) After unregister (but no reset obviously) keepalives are still sent, further, the device now responds to keepalives with a keepalive_ack, but this doesn't affect the timing of their own keepalives.
chan_skinny impact:
need to revise keepalive timing with is currently set to unregister at 1.1 * keepalive time
Testing wifi (7920 with keepalive set to 20), immediately after a keepalive:
removed from range for 55 secs - at 58 secs 3 keepalives received, connection remains. removed from range for 65 secs - at about 80 secs, connection reset and device reloads. server set to ignore 2 keepalives - 3rd keepalive at just under 60secs, connection remains. server set to ignore 3 keepalives - 4th keepalive at just under 80secs, connection reset by device anyway. looks like timing should be about 3*keepalive (ie 60secs), maybe 5*keepalive for 7961 (v17?)
More on ignoring keepalives at the server (with the 7920) (table below)
if keepalive is odd, the time used is rounded up to the next even number (ie 15 will result in 16 secs) the first keepalive is delayed by 1 sec if keepalive is less than 30, 15 secs if less than 120, else 105 secs these two lead to some funny numbers if set to 119, the first will be at 135 secs (119 rounded up + 15), and subsequent each 120 secs if set to 120, the first will be at 225 secs (120 not rounded + 105), and subsequent each 120 secs similarly if set to 29, the first will be 31 then 30, where if set to 30 the first will be 45 then 30 only tested out to 600 secs (where the first is still delayed by 105 secs) device resets the connection 20 secs after the 3rd unreplied keepalive keepalives below 20 seem unreliable in that they do not reset the connection above 20secs and after the first keepalive, the device will reset at (TRUNC((KA+1)/2)*2)*3+20 before the first keepalive, add 1 if KA<30, add 15 if KA<120, else add 105 actually, about a second earlier. After the first missed KA, the next will be about a second early not valid for other devices
Set 20 25 26 29 First (s) 21 27 27 31 Then (s) 20 26 26 30 Packets (#) 3 3 3 3 Reset (s) 20 20 20 20
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
197
3 3 3 3 3 3
20 20 20 20 20 20
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
198
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
199
Asterisk Configuration
The top-level page for all things related to Asterisk configuration
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
200
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
201
Configuration Parser
Introduction The Asterisk configuration parser in the 1.2 version and beyond series has been improved in a number of ways. In addition to the realtime architecture, we now have the ability to create templates in configuration files, and use these as templates when we configure phones, voicemail accounts and queues. These changes are general to the configuration parser, and works in all configuration files. General syntax Asterisk configuration files are defined as follows:
[section] label1 = value1 label2 = value2 object => name label3 = value3 label2 = value4 object2 => name2
In this syntax, we create objects with the settings defined above the object creation. Note that settings are inherited from the top, so in the example above object2 has inherited the setting for "label1" from the first object. For template configurations, the syntax for defining a section is changed to:
;This is a comment label = value ;-- This is a comment -; ;- Comment --; exten=> 1000,1,dial(SIP/lisa)
Including other files In all of the configuration files, you may include the content of another file with the #include statement. The content of the other file will be included at the row that the #include statement occurred.
#include myusers.conf
You may also include the output of a program with the #exec directive, if you enable it in asterisk.conf
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
202
[options] execincludes=yes
The exec directive is used like this:
#exec /usr/local/bin/myasteriskconfigurator.sh
[foo] disallow=all allow=ulaw allow=alaw [bar] allow=gsm allow=g729 permit=192.168.2.1 [baz](foo,bar) type=friend permit=192.168.3.1 context=incoming host=bnm
The [baz] section will be processed as though it had been written in the following way:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
203
[baz] disallow=all allow=ulaw allow=alaw allow=gsm allow=g729 permit=192.168.2.1 type=friend permit=192.168.3.1 context=incoming host=bnm
It should also be noted that there are no guaranteed overriding semantics, meaning that if you define something in one template, you should not expect to be able to override it by defining it again in another template. Additional Examples (in top-level sip.conf)
[def-customer1](!,defaults) secret=this_is_not_secret context=from-customer1 callerid=Customer 1 <300> accountcode=0001 [phone1](def-customer1) mailbox=phone1@customer1 [phone2](def-customer1) mailbox=phone2@customer1
This example defines two phones - phone1 and phone2 with settings inherited from "def-customer1". The "def-customer1" is a template that inherits from "defaults", which also is a template.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
204
[directories] ; Make sure these directories have the right permissions if not ; running Asterisk as root ; Where the configuration files (except for this one) are located astetcdir => /etc/asterisk ; Where the Asterisk loadable modules are located astmoddir => /usr/lib/asterisk/modules ; Where additional 'library' elements (scripts, etc.) are located astvarlibdir => /var/lib/asterisk ; Where AGI scripts/programs are located astagidir => /var/lib/asterisk/agi-bin ; Where spool directories are located ; Voicemail, monitor, dictation and other apps will create files here ; and outgoing call files (used with pbx_spool) must be placed here astspooldir => /var/spool/asterisk ; Where the Asterisk process ID (pid) file should be created astrundir => /var/run/asterisk ; Where the Asterisk log files should be created astlogdir => /var/log/asterisk [options] ;Under "options" you can enter configuration options ;that you also can set with command line options ; Verbosity level for logging (-v) verbose = 0 ; Debug: "No" or value (1-4) debug = 3 ; Background execution disabled (-f) nofork=yes | no ; Always background, even with -v or -d (-F) alwaysfork=yes | no ; Console mode (-c) console= yes | no ; Execute with high priority (-p) highpriority = yes | no ; Initialize crypto at startup (-i) initcrypto = yes | no ; Disable ANSI colors (-n) nocolor = yes | no
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
205
; Dump core on failure (-g) dumpcore = yes | no ; Run quietly (-q) quiet = yes | no ; Force timestamping in CLI verbose output (-T) timestamp = yes | no ; User to run asterisk as (-U) NOTE: will require changes to ; directory and device permissions runuser = asterisk ; Group to run asterisk as (-G) rungroup = asterisk ; Enable internal timing support (-I) internal_timing = yes | no ; Language Options documentation_language = en | es | ru ; These options have no command line equivalent ; Cache record() files in another directory until completion cache_record_files = yes | no record_cache_dir = <dir> ; Build transcode paths via SLINEAR transcode_via_sln = yes | no ; send SLINEAR silence while channel is being recorded transmit_silence_during_record = yes | no ; The maximum load average we accept calls for maxload = 1.0 ; The maximum number of concurrent calls you want to allow maxcalls = 255 ; Stop accepting calls when free memory falls below this amount specified in MB minmemfree = 256 ; Allow #exec entries in configuration files execincludes = yes | no ; Don't over-inform the Asterisk sysadm, he's a guru dontwarn = yes | no ; System name. Used to prefix CDR uniqueid and to fill \${SYSTEMNAME} systemname = <a_string> ; Should language code be last component of sound file name or first? ; when off, sound files are searched as <path>/<lang>/<file> ; when on, sound files are search as <lang>/<path>/<file> ; (only affects relative paths for sound files) languageprefix = yes | no
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
206
; Locking mode for voicemail ; - lockfile: default, for normal use ; - flock: for where the lockfile locking method doesn't work ; eh. on SMB/CIFS mounts lockmode = lockfile | flock ; ; ; ; ; Entity ID. This is in the form of a MAC address. It should be universally unique. It must be unique between servers communicating with a protocol that uses this value. The only thing that uses this currently is DUNDi, but other things will use it in the future. entityid=00:11:22:33:44:55
[files] ; Changing the following lines may compromise your security ; Asterisk.ctl is the pipe that is used to connect the remote CLI ; (asterisk -r) to Asterisk. Changing these settings change the ; permissions and ownership of this file. ; The file is created when Asterisk starts, in the "astrundir" above. ;astctlpermissions = 0660 ;astctlowner = root
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
207
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
208
CLI Prompt
Changing the CLI Prompt The CLI prompt is set with the ASTERISK_PROMPT UNIX environment variable that you set from the Unix shell before starting Asterisk You may include the following variables, that will be replaced by the current value by Asterisk:
%d - Date (year-month-date) %s - Asterisk system name (from asterisk.conf) %h - Full hostname %H - Short hostname %t - Time %u - Username %g - Groupname %% - Percent sign %# - '#' if Asterisk is run in console mode, '' if running as remote console %Cn[;n] - Change terminal foreground (and optional background) color to specified A full list of colors may be found in include/asterisk/term.h
On systems which implement getloadavg(3), you may also use:
%l1 - Load average over past minute %l2 - Load average over past 5 minutes %l3 - Load average over past 15 minutes
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
209
s - What to do when an extension context is entered (unless overridden by the low level channel interface) This is used in macros, and some special cases. "s" is not a generic catch-all wildcard extension. i - What to do if an invalid extension is entered h - The hangup extension, executed at hangup t - What to do if nothing is entered in the requisite amount of time. T - This is the extension that is executed when the 'absolute' timeout is reached. See "core show function TIMEOUT" for more information on setting timeouts. e - This extension will substitute as a catchall for any of the 'i', 't', or 'T' extensions, if any of them do not exist and catching the error in a single routine is desired. The function EXCEPTION may be used to query the type of exception or the location where it occurred.
And finally, the extension context "default" is used when either a) an extension context is deleted while an extension is in use, or b) a specific starting extension handler has not been defined (unless overridden by the low level channel interface).
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
210
IP Quality of Service
Introduction
Asterisk supports different QoS settings at the application level for various protocols on both signaling and media. The Type of Service (TOS) byte can be set on outgoing IP packets for various protocols. The TOS byte is used by the network to provide some level of Quality of Service (QoS) even if the network is congested with other traffic. Asterisk running on Linux can also set 802.1p CoS marks in VLAN packets for the VoIP protocols it uses. This is useful when working in a switched environment. In fact Asterisk only set priority for Linux socket. For mapping this priority and VLAN CoS mark you need to use this command:
chan_pjsip
Table 2.2: Other ToS Settings
Audio
Video
Text
IP TOS values The allowable values for any of the tos parameters are: CS0, CS1, CS2, CS3, CS4, CS5, CS6, CS7, AF11, AF12, AF13, AF21, AF22, AF23, AF31, AF32, AF33, AF41, AF42, AF43 and ef (expedited forwarding),* The tos parameters also take numeric values.* Note that on a Linux system, Asterisk must be compiled with libcap in order to use the ef tos setting if Asterisk is not run as root. The lowdelay, throughput, reliability, mincost, and none values have been removed in current releases. 802.1p CoS values Because 802.1p uses 3 bits of the VLAN header, this parameter can take integer values from 0 to 7. Recommended values The recommended values shown below are also included in sample configuration files: Table 2.3: Recommended QoS Settings tos Signaling cs3 cos 3
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
211
ef af41 af41 ef
5 4 3
IAX2 In iax.conf, there is a "tos" parameter that sets the global default TOS for IAX packets generated by chan_iax2. Since IAX connections combine signalling, audio, and video into one UDP stream, it is not possible to set the TOS separately for the different types of traffic. In iaxprov.conf, there is a "tos" parameter that tells the IAXy what TOS to set on packets it generates. As with the parameter in iax.conf, IAX packets generated by an IAXy cannot have different TOS settings based upon the type of packet. However different IAXy devices can have different TOS settings. SIP In sip.conf, there are four parameters that control the TOS settings: "tos_sip", "tos_audio", "tos_video" and "tos_text". tos_sip controls what TOS SIP call signaling packets are set to. tos_audio, tos_video and tos_text control what TOS values are used for RTP audio, video, and text packets, respectively. There are four parameters to control 802.1p CoS: "cos_sip", "cos_audio", "cos_video" and "cos_text". The behavior of these parameters is the same as for the SIP TOS settings described above. Other RTP channels chan_mgcp, chan_h323, chan_skinny and chan_unistim also support TOS and CoS via setting tos and cos parameters in their corresponding configuration files. Naming style and behavior are the same as for chan_sip. Reference IEEE 802.1Q Standard: http://standards.ieee.org/getieee802/download/802.1Q-1998.pdfRelated protocols: IEEE 802.3, 802.2, 802.1D, 802.1Q RFC 2474 - "Definition of the Differentiated Services Field (DS field) in the IPv4 and IPv6 Headers", Nichols, K., et al, December 1998. IANA Assignments, DSCP registry Differentiated Services Field Codepoints http://www.iana.org/assignments/dscp-registry To get the most out of setting the TOS on packets generated by Asterisk, you will need to ensure that your network handles packets with a TOS properly. For Cisco devices, see the previously mentioned "Enterprise QoS Solution Reference Network Design Guide". For Linux systems see the "Linux Advanced Routing & Traffic Control HOWTO" at http://www.lartc.org/. For more information on Quality of Service for VoIP networks see the "Enterprise QoS Solution Reference Network Design Guide" version 3.3 from Cisco at: http://www.cisco.com/application/pdf/en/us/guest/netsol/ns432/c649/ccmigration_09186a008049b062.pdf
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
212
MP3 Support
MP3 Music On Hold
Use of the mpg123 for your music on hold is no longer recommended and is now officially deprecated. You should now use one of the native formats for your music on hold selections. However, if you still need to use mp3 as your music on hold format, a format driver for reading MP3 audio files is available in the asterisk-addons SVN repository on svn.digium.com or in the asterisk-addons release at http://downloads.asterisk.org/pub/telephony/asterisk/.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
213
ICES
The advent of icecast into Asterisk allows you to do neat things like have a caller stream right into an ice-cast stream as well as using chan_local to place things like conferences, music on hold, etc. into the stream. You'll need to specify a config file for the ices encoder. An example is included in contrib/asterisk-ices.xml.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
214
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
215
Introduction
The Asterisk Realtime Architecture is a new set of drivers and functions implemented in Asterisk. The benefits of this architecture are many, both from a code management standpoint and from an installation perspective. The ARA is designed to be independent of storage. Currently, most drivers are based on SQL, but the architecture should be able to handle other storage methods in the future, like LDAP. The main benefit comes in the database support. In Asterisk v1.0 some functions supported MySQL database, some PostgreSQL and other ODBC. With the ARA, we have a unified database interface internally in Asterisk, so if one function supports database integration, all databases that has a realtime driver will be supported in that function. Currently there are three realtime database drivers:
1. ODBC: Support for UnixODBC, integrated into Asterisk The UnixODBC subsystem supports many different databases, please check www.unixodbc.org for more information. 2. MySQL: Native support for MySQL, integrated into Asterisk 3. PostgreSQL: Native support for Postgres, integrated into Asterisk
Two modes: Static and Realtime The ARA realtime mode is used to dynamically load and update objects. This mode is used in the SIP and IAX2 channels, as well as in the voicemail system. For SIP and IAX2 this is similar to the v1.0 MYSQL_FRIENDS functionality. With the ARA, we now support many more databases for dynamic configuration of phones. The ARA static mode is used to load configuration files. For the Asterisk modules that read configurations, there's no difference between a static file in the file system, like extensions.conf, and a configuration loaded from a database. You just have to always make sure the var_metric values are properly set and ordered as you expect in your database server if you're using the static mode with ARA (either sequentially or with the same var_metric value for everybody). If you have an option that depends on another one in a given configuration file (i.e, 'musiconhold' depending on 'agent' from agents.conf) but their var_metric are not sequential you'll probably get default values being assigned for those options instead of the desired ones. You can still use the same var_metric for all entries in your DB, just make sure the entries are recorded in an order that does not break the option dependency. That doesn't happen when you use a static file in the file system. Although this might be interpreted as a bug or limitation, it is not.
To use static realtime with certain core configuration files (e.g. features.conf, cdr.conf, cel.conf, indications.conf, etc.) the realtime backend you wish to use must be preloaded in modules.conf.
[modules] preload => res_odbc.so preload => res_config_odbc.so
Realtime SIP friends The SIP realtime objects are users and peers that are loaded in memory when needed, then deleted. This means that Asterisk currently can't handle voicemail notification and NAT keepalives for these peers. Other than that, most of the functionality works the same way for realtime friends as for the ones in static configuration. With caching, the device stays in memory for a specified time. More information about this is to be found in the sip.conf sample file. If you specify a separate family called "sipregs" SIP registration data will be stored in that table and not in the "sippeers" table. Realtime H.323 friends
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
216
Like SIP realtime friends, H.323 friends also can be configured using dynamic realtime objects. New function in the dial plan: The Realtime Switch The realtime switch is more than a port of functionality in v1.0 to the new architecture, this is a new feature of Asterisk based on the ARA. The realtime switch lets your Asterisk server do database lookups of extensions in realtime from your dial plan. You can have many Asterisk servers sharing a dynamically updated dial plan in real time with this solution. Note that this switch does NOT support Caller ID matching, only extension name or pattern matching. Capabilities The realtime Architecture lets you store all of your configuration in databases and reload it whenever you want. You can force a reload over the AMI, Asterisk Manager Interface or by calling Asterisk from a shell script with
sippeers, sipusers - SIP peers and users sipregs - SIP registrations iaxpeers, iaxusers - IAX2 peers and users voicemail - Voicemail accounts extensions - Realtime extensions (switch) meetme - MeetMe conference rooms queues - Queues queue_members - Queue members musiconhold - Music On Hold classes queue_log - Queue logging
Voicemail storage with the support of ODBC described in ODBC Voicemail Storage. Limitations Currently, realtime extensions do not support realtime hints. There is a workaround available by using func_odbc. See the sample func_odbc.conf for more information. FreeTDS supported with connection pooling In order to use a FreeTDS-based database with realtime, you need to turn connection pooling on in res_odbc.conf. This is due to a limitation within the FreeTDS protocol itself. Please note that this includes databases such as MS SQL Server and Sybase. This support is new in the current release. You may notice a performance issue under high load using UnixODBC. The UnixODBC driver supports threading but you must specifically enable threading within the UnixODBC configuration file like below for each engine:
Threading = 2
This will enable the driver to service many requests at a time, rather than serially. Notes on use of the sipregs family The community provided some additional recommendations on the JIRA issue ASTERISK-21315:
It is a good idea to avoid using sipregs altogether by NOT enabling it in extconfig. Using a writable sipusers table should be enough. If
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
217
you cannot write to your base sipusers table because it is readonly, you could consider making a separate sipusers view that joins the readonly table with a writable sipregs table.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
218
FreeTDS
The cdr_tds module now works with most modern release versions of FreeTDS (from at least 0.60 through 0.82). Although versions of FreeTDS prior to 0.82 will work, we recommend using the latest available version for performance and stability reasons. *The latest release of FreeTDS is available from http://www.freetds.org/*
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
219
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
220
`mohsuggest` varchar(40) DEFAULT NULL, `parkinglot` varchar(40) DEFAULT NULL, `hasvoicemail` enum('yes','no') DEFAULT NULL, `subscribemwi` enum('yes','no') DEFAULT NULL, `vmexten` varchar(40) DEFAULT NULL, `autoframing` enum('yes','no') DEFAULT NULL, `rtpkeepalive` int(11) DEFAULT NULL, `call-limit` int(11) DEFAULT NULL, `g726nonstandard` enum('yes','no') DEFAULT NULL, `ignoresdpversion` enum('yes','no') DEFAULT NULL, `allowtransfer` enum('yes','no') DEFAULT NULL, `dynamic` enum('yes','no') DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), KEY `ipaddr` (`ipaddr`,`port`),
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
221
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
222
Privacy Configuration
So, you want to avoid talking to pesky telemarketers/charity seekers/poll takers/magazine renewers/etc?
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
223
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
224
Fighting Autodialers
Zapateller detects if callerid is present, and if not, plays the da-da-da tones that immediately precede messages like, "I'm sorry, the number you have called is no longer in service." Most humans, even those with unlisted/callerid-blocked numbers, will not immediately slam the handset down on the hook the moment they hear the three tones. But autodialers seem pretty quick to do this. I just counted 40 hangups in Zapateller over the last year in my CDR's. So, that is possibly 40 different telemarketers/charities that have hopefully slashed my back-waters, out-of-the-way, humble home phone number from their lists. I highly advise Zapateller for those seeking the nirvana of "privacy".
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
225
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
226
[homeline] exten => s,1,Answer exten => s,2,SetVar,repeatcount=0 exten => s,3,Zapateller,nocallerid exten => s,4,PrivacyManager ;; do this if they don't enter a number to Privacy Manager exten => s,5,GotoIf($[ "${PRIVACYMGRSTATUS}" = "FAILED" ]?s,105) exten => s,6,GotoIf($[ "${CALLERID(num)}" = "7773334444" & "${CALLERID(name)}" : "Privacy Manager" ]?callerid-liar,s,1:s,7) exten => s,7,Dial(SIP/yourphone) exten => s,105,Background(tt-allbusy) exten => s,106,Background(tt-somethingwrong) exten => s,107,Background(tt-monkeysintro) exten => s,108,Background(tt-monkeys) exten => s,109,Background(tt-weasels) exten => s,110,Hangup
I suggest using Zapateller at the beginning of the context, before anything else, on incoming calls.This can be followed by the PrivacyManager App. Make sure, if you do the PrivacyManager app, that you take care of the error condition! or their non-compliance will be rewarded with access to the system. In the above, if they can't enter a 10-digit number in 3 tries, they get the humorous "I'm sorry, but all household members are currently helping other telemarketers...", "something is terribly wrong", "monkeys have carried them away...", various loud monkey screechings, "weasels have...", and a hangup. There are plenty of other paths to my torture scripts, I wanted to have some fun. In nearly all cases now, the telemarketers/charity-seekers that usually get thru to my main intro, hang up. I guess they can see it's pointless, or the average telemarketer/charity-seeker is instructed not to enter options when encountering such systems. Don't know.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
227
603890zzzz - hung up telemarket options. "Integrated Sale" - called a couple times. hung up in telemarket options "UNITED STATES GOV" - maybe a military recruiter, trying to lure one of my sons. 800349zzzz - hung up in charity intro 800349zzzz - hung up in charity choices, intro, about the only one who actually travelled to the bitter bottom of the scripts! 216377zzzz - hung up the magazine section 626757zzzz = "LIR " (pronounced "Liar"?) hung up in telemarket intro, then choices 757821zzzz - hung up in new magazine subscription options.
That averages out to maybe 1 a month. That puts into question whether the ratio of the amount of labor it took to make the scripts versus the benefits of lower call volumes was worth it, but, well, I had fun, so what the heck. But, that's about it. Not a whole lot. But I haven't had to say "NO" or "GO AWAY" to any of these folks for about a year now ...!
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
228
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
229
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
230
Introductions
Unless instructed to not save introductions (see the 'n' option above), the screening modes will save the recordings of the caller's names in the directory /var/lib/asterisk/sounds/priv-callerintros, if they have a CallerID. Just the 10-digit callerid numbers are used as filenames, with a ".gsm" at the end. Having these recordings around can be very useful, however... First of all, if a callerid is supplied, and a recorded intro for that number is already present, the caller is spared the inconvenience of having to supply their name, which shortens their call a bit. Next of all, these intros can be used in voicemail, played over loudspeakers, and perhaps other nifty things. For instance:
[home-introduction] exten => s,1,Background(intro-options) ;; Script: ;; To hear your Introduction, dial 1. ;; to record a new introduction, dial 2. ;; to return to the main menu, dial 3. ;; to hear what this is all about, dial 4. exten => 1,1,Playback,priv-callerintros/${CALLERID(num)} exten => 1,2,Goto(s,1) exten => 2,1,Goto(home-introduction-record,s,1) exten => 3,1,Goto(homeline,s,7) exten => 4,1,Playback(intro-intro) ;; Script: ;; This may seem a little strange, but it really is a neat ;; thing, both for you and for us. I've taped a short introduction ;; for many of the folks who normally call us. Using the Caller ID ;; from each incoming call, the system plays the introduction ;; for that phone number over a speaker, just as the call comes in. ;; This helps the folks ;; here in the house more quickly determine who is calling. ;; and gets the right ones to gravitate to the phone. ;; You can listen to, and record a new intro for your phone number ;; using this menu. exten => 4,2,Goto(s,1) exten => t,1,Goto(s,1) exten => i,1,Background(invalid) exten => i,2,Goto(s,1) exten => o,1,Goto(s,1) [home-introduction-record]
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
231
exten => s,1,Background(intro-record-choices) ;; Script: ;; If you want some advice about recording your ;; introduction, dial 1. ;; otherwise, dial 2, and introduce yourself after ;; the beep. exten => 1,1,Playback(intro-record) ;; Your introduction should be short and sweet and crisp. ;; Your introduction will be limited to 4 seconds. ;; This is NOT meant to be a voice mail message, so ;; please, don't say anything about why you are calling. ;; After we are done making the recording, your introduction ;; will be saved for playback. ;; If you are the only person that would call from this number, ;; please state your name. Otherwise, state your business ;; or residence name instead. For instance, if you are ;; friend of the family, say, Olie McPherson, and both ;; you and your kids might call here a lot, you might ;; say: "This is the distinguished Olie McPherson Residence!" ;; If you are the only person calling, you might say this: ;; "This is the illustrious Kermit McFrog! Pick up the Phone, someone!! ;; If you are calling from a business, you might pronounce a more sedate introduction, like, ;; "Fritz from McDonalds calling.", or perhaps the more original introduction: ;; "John, from the Park County Morgue. You stab 'em, we slab 'em!". ;; Just one caution: the kids will hear what you record every time ;; you call. So watch your language! ;; I will begin recording after the tone. ;; When you are done, hit the # key. Gather your thoughts and get ;; ready. Remember, the # key will end the recording, and play back ;; your intro. Good Luck, and Thank you!" exten => 1,2,Goto(2,1) exten => 2,1,Background(intro-start) ;; OK, here we go! After the beep, please give your introduction. exten => 2,2,Background(beep) exten => 2,3,Record(priv-callerintros/${CALLERID(num)}:gsm,4) exten => 2,4,Background(priv-callerintros/${CALLERID(num)}) exten => 2,5,Goto(home-introduction,s,1) exten => t,1,Goto(s,1) exten => i,1,Background(invalid)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
232
In the above, you'd most likely reword the messages to your liking, and maybe do more advanced things with the 'error' conditions (i,o,t priorities), but I hope it conveys the idea.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
233
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
234
Introduction to AEL
AEL is a specialized language intended purely for describing Asterisk dial plans. The current version was written by Steve Murphy, and is a rewrite of the original version. This new version further extends AEL, and provides more flexible syntax, better error messages, and some missing functionality. AEL is really the merger of 4 different 'languages', or syntaxes:
1. The first and most obvious is the AEL syntax itself. A BNF is provided near the end of this document. 2. The second syntax is the Expression Syntax, which is normally handled by Asterisk extension engine, as expressions enclosed in $[...]. The right hand side of assignments are wrapped in $[ ... ] by AEL, and so are the if and while expressions, among others. 3. The third syntax is the Variable Reference Syntax, the stuff enclosed in ${..} curly braces. It's a bit more involved than just putting a variable name in there. You can include one of dozens of 'functions', and their arguments, and there are even some string manipulation notation in there. 4. The last syntax that underlies AEL, and is not used directly in AEL, is the Extension Language Syntax. The extension language is what you see in extensions.conf, and AEL compiles the higher level AEL language into extensions and priorities, and passes them via function calls into Asterisk. Embedded in this language is the Application/AGI commands, of which one application call per step, or priority can be made. You can think of this as a "macro assembler" language, that AEL will compile into.
Any programmer of AEL should be familiar with its syntax, of course, as well as the Expression syntax, and the Variable syntax.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
235
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
236
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
237
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
238
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
239
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
240
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
241
AEL Debugging
Right at this moment, the following commands are available, but do nothing:
If things are going wrong in your dialplan, you can use the following facilities to debug your file:
1. The messages log in /var/log/asterisk. (from the checks done at load time). 2. The "show dialplan" command in asterisk 3. The standalone executable, "aelparse" built in the utils/ dir in the source.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
242
About "aelparse"
You can use the "aelparse" program to check your extensions.ael file before feeding it to asterisk. Wouldn't it be nice to eliminate most errors before giving the file to asterisk? aelparse is compiled in the utils directory of the asterisk release. It isn't installed anywhere (yet). You can copy it to your favorite spot in your PATH. aelparse has two optional arguments:
1. -d - Override the normal location of the config file dir, (usually /etc/asterisk), and use the current directory instead as the config file dir. Aelparse will then expect to find the file "./extensions.ael" in the current directory, and any included files in the current directory as well. 2. -n - Don't show all the function calls to set priorities and contexts within asterisk. It will just show the errors and warnings from the parsing and semantic checking phases.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
243
or:
if(${x}=1) { NoOp(hello!); goto s,3; } else { NoOp(Goodbye!); goto s,12; }
or:
if (${x}=1) { NoOp(hello!); goto s,3; } else { NoOp(Goodbye!); goto s,12; }
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
244
AEL Keywords
The AEL keywords are case-sensitive. If an application name and a keyword overlap, there is probably good reason, and you should consider replacing the application call with an AEL statement. If you do not wish to do so, you can still use the application, by using a capitalized letter somewhere in its name. In the Asterisk extension language, application names are NOT case-sensitive. The following are keywords in the AEL language:
abstract context macro globals ignorepat switch if ifTime else random goto jump local return break continue regexten hint for while case pattern default NOTE: the "default" keyword can be used as a context name, for those who would like to do so. catch switches eswitches includes
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
245
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
246
<macro> :== 'macro' <word> '(' <arglist> ')' '{' <macro_statements> '}' | 'macro' <word> '(' <arglist> ')' '{' '}' | 'macro' <word> '(' ')' '{' <macro_statements> '}' | 'macro' <word> '(' ')' '{' '}' <globals> :== 'globals' '{' <global_statements> '}' | 'globals' '{' '}' <global_statements> :== <global_statement> | <global_statements> <global_statement>
<global_statement> :== <word> '=' <collected-word> ';' <arglist> :== <word> | <arglist> ',' <word> <elements> :== <element> | <elements> <element> <element> :== <extension> | <includes> | <switches> | <eswitches> | <ignorepat> | <word> '=' <collected-word> ';' | 'local' <word> '=' <collected-word> ';' | ';'
<ignorepat> :== 'ignorepat' '=>' <word> ';' <extension> :== <word> '=>' <statement> | 'regexten' <word> '=>' <statement> | 'hint' '(' <word3-list> ')' <word> '=>' <statement> | 'regexten' 'hint' '(' <word3-list> ')' <word> '=>' <statement> <statements> :== <statement> | <statements> <statement> <if_head> :== 'if' '(' <collected-word> ')' <random_head> :== 'random' '(' <collected-word> ')' <ifTime_head> :== 'ifTime' '(' <word3-list> ':' <word3-list> ':' <word3-list> '|' <word3-list> '|' <word3-list> '|' <word3-list> ')' | 'ifTime' '(' <word> '|' <word3-list> '|' <word3-list> '|' <word3-list> ')' <word3-list> :== <word> | <word> <word> | <word> <word> <word> <switch_head> :== 'switch' '(' <collected-word> ')' '{' <statement> :== '{' <statements> '}' | <word> '=' <collected-word> ';' | 'local' <word> '=' <collected-word> ';' | 'goto' <target> ';' | 'jump' <jumptarget> ';'
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
247
| | | | | | | | | | | | | | | | | | <target> | | | | | |
<word> ':' 'for' '(' <collected-word> ';' <collected-word> ';' <collected-word> ')' <statement> 'while' '(' <collected-word> ')' <statement> <switch_head> '}' <switch_head> <case_statements> '}' '&' macro_call ';' <application_call> ';' <application_call> '=' <collected-word> ';' 'break' ';' 'return' ';' 'continue' ';' <random_head> <statement> <random_head> <statement> 'else' <statement> <if_head> <statement> <if_head> <statement> 'else' <statement> <ifTime_head> <statement> <ifTime_head> <statement> 'else' <statement> ';' :== <word> <word> '|' <word> <word> '|' <word> '|' <word> 'default' '|' <word> '|' <word> <word> ',' <word> <word> ',' <word> ',' <word> 'default' ',' <word> ',' <word>
<jumptarget> :== <word> | <word> | <word> | <word> | <word> | <word> <macro_call> :== <word> | <word> '(' ')'
<word> <word> '@' <word> <word> <word> '@' 'default' 'default' <eval_arglist> ')'
<application_call_head> :== <word> '(' <application_call> :== <application_call_head> <eval_arglist> ')' | <application_call_head> ')' <eval_arglist> :== <collected-word> | <eval_arglist> ',' <collected-word> | /* nothing */ | <eval_arglist> ',' /* nothing */ <case_statements> :== <case_statement> | <case_statements> <case_statement> <case_statement> :== 'case' <word> ':' <statements> | 'default' ':' <statements> | 'pattern' <word> ':' <statements> | 'case' <word> ':' | 'default' ':' | 'pattern' <word> ':' <macro_statements> :== <macro_statement> | <macro_statements> <macro_statement> <macro_statement> :== <statement> | 'catch' <word> '{' <statements> '}' <switches> :== 'switches' '{' <switchlist> '}' | 'switches' '{' '}' <eswitches> :== 'eswitches' '{' <switchlist> '}' | 'eswitches' '{' '}' <switchlist> :== <word> ';' | <switchlist> <word> ';' <includeslist> :== <includedname> ';' | <includedname> '|' <word3-list> ':' <word3-list> ':' <word3-list> '|' <word3-list> '|' <word3-list> '|' <word3-list> ';' | <includedname> '|' <word> '|' <word3-list> '|' <word3-list> '|' <word3-list> ';' | <includeslist> <includedname> ';' | <includeslist> <includedname> '|' <word3-list> ':' <word3-list> ':' <word3-list> '|' <word3-list> '|' <word3-list> '|' <word3-list> ';' | <includeslist> <includedname> '|' <word> '|' <word3-list> '|' <word3-list> '|' <word3-list> ';' <includedname> :== <word> | 'default'
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
248
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
249
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
250
AEL Comments
Comments begin with // and end with the end of the line. Comments are removed by the lexical scanner, and will not be recognized in places where it is busy gathering expressions to wrap in $[] , or inside application call argument lists. The safest place to put comments is after terminating semicolons, or on otherwise empty lines.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
251
AEL Context
Contexts in AEL represent a set of extensions in the same way that they do in extensions.conf.
context default { }
A context can be declared to be "abstract", in which case, this declaration expresses the intent of the writer, that this context will only be included by another context, and not "stand on its own". The current effect of this keyword is to prevent "goto " statements from being checked.
abstract context longdist { _1NXXNXXXXXX => NoOp(generic long distance dialing actions in the US); }
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
252
AEL Extensions
To specify an extension in a context, the following syntax is used. If more than one application is be called in an extension, they can be listed in order inside of a block.
context default { 1234 => Playback(tt-monkeys); 8000 => { NoOp(one); NoOp(two); NoOp(three); }; _5XXX => NoOp(it's a pattern!); }
Two optional items have been added to the AEL syntax, that allow the specification of hints, and a keyword, regexten, that will force the numbering of priorities to start at 2. The ability to make extensions match by CID is preserved in AEL; just use '/' and the CID number in the specification. See below.
context default { regexten _5XXX => NoOp(it's a pattern!); } context default { hint(Sip/1) _5XXX => NoOp(it's a pattern!); } context default { regexten hint(Sip/1) _5XXX => NoOp(it's a pattern!); }
The regexten must come before the hint if they are both present. CID matching is done as with the extensions.conf file. Follow the extension name/number with a slash and the number to match against the Caller ID:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
253
AEL Includes
Contexts can be included in other contexts. All included contexts are listed within a single block.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
254
#include "/etc/asterisk/testfor.ael"
An interesting property of the #include, is that you can use it almost anywhere in the .ael file. It is possible to include the contents of a file in a macro, context, or even extension. The #include does not have to occur at the beginning of a line. Included files can include other files, up to 50 levels deep. If the path provided in quotes is a relative path, the parser looks in the config file directory for the file (usually /etc/asterisk).
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
255
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
256
AEL Ignorepat
ignorepat can be used to instruct channel drivers to not cancel dialtone upon receipt of a particular pattern. The most commonly used example is '9'.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
257
AEL Variables
Variables in Asterisk do not have a type, so to define a variable, it just has to be specified with a value. Global variables are set in their own block.
context foo { 555 => { x=5; y=blah; divexample=10/2 NoOp(x is ${x} and y is ${y} !); } }
NOTE: AEL wraps the right hand side of an assignment with $[ ] to allow expressions to be used If this is unwanted, you can protect the right hand side from being wrapped by using the Set() application. Read the README.variables about the requirements and behavior of $[ ] expressions. NOTE: These things are wrapped up in a $[ ] expression: The while() test; the if() test; the middle expression in the for( x; y; z) statement (the y expression); Assignments - the right hand side, so a = b - Set(a=$[b]) Writing to a dialplan function is treated the same as writing to a variable.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
258
Macro myroutine(firstarg, secondarg) { local Myvar=1; NoOp(Myvar is set to ${Myvar}, and firstarg is ${firstarg}, and secondarg is ${secondarg}); }
In the above example, Myvar, firstarg, and secondarg are all local variables, and will not be visible to the calling code, be it an extension, or another Macro. If you need to make a local variable within the Set() application, you can do it this way:
Macro myroutine(firstarg, secondarg) { Set(LOCAL(Myvar)=1); NoOp(Myvar is set to ${Myvar}, and firstarg is ${firstarg}, and secondarg is ${secondarg}); }
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
259
AEL Conditionals
AEL supports if and switch statements, like AEL, but adds ifTime, and random. Unlike the original AEL, though, you do NOT need to put curly braces around a single statement in the "true" branch of an if(), the random(), or an ifTime() statement. The if(), ifTime(), and random() statements allow optional else clause.
context conditional { _8XXX => { Dial(SIP/${EXTEN}); if ("${DIALSTATUS}" = "BUSY") { NoOp(yessir); Voicemail(${EXTEN},b); } else Voicemail(${EXTEN},u); ifTime (14:00-25:00,sat-sun,,) Voicemail(${EXTEN},b); else { Voicemail(${EXTEN},u); NoOp(hi, there!); } random(51) NoOp(This should appear 51% of the time); random( 60 ) { NoOp( This should appear 60% of the time ); } else { random(75) { NoOp( This should appear 30% of the time! ); } else { NoOp( This should appear 10% of the time! ); } } } _777X => { switch (${EXTEN}) { case 7771: NoOp(You called 7771!); break; case 7772: NoOp(You called 7772!); break; case 7773: NoOp(You called 7773!); // fall thrupattern 777[4-9]: NoOp(You called 777 something!); default: NoOp(In the default clause!); } } }
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
260
The conditional expression in if() statements (the "${DIALSTATUS}" = "BUSY" above) is wrapped by the compiler in $[] for evaluation.
Neither the switch nor case values are wrapped in $[ ]; they can be constants, or ${var} type references only.
AEL generates each case as a separate extension. case clauses with no terminating 'break', or 'goto', have a goto inserted, to the next clause, which creates a 'fall thru' effect.
AEL introduces the ifTime keyword/statement, which works just like the if() statement, but the expression is a time value, exactly like that used by the application GotoIfTime(). See Asterisk cmd GotoIfTime
The pattern statement makes sure the new extension that is created has an '_' preceding it to make sure asterisk recognizes the extension name as a pattern.
Every character enclosed by the switch expression's parenthesis are included verbatim in the labels generated. So watch out for spaces!
NEW: Previous to version 0.13, the random statement used the "Random()" application, which has been deprecated. It now uses the RAND() function instead, in the GotoIf application.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
261
context gotoexample { s => { begin: NoOp(Infinite Loop! yay!); Wait(1); goto begin; // go to label in same extension } 3 => { goto s, begin; // go to label in different extension } 4 => { goto gotoexample,s,begin; // overkill go to label in same context } } context gotoexample2 { s => { end: goto gotoexample,s,begin; // go to label in different context } }
You can use the special label of "1" in the goto and jump statements. It means the "first" statement in the extension. I would not advise trying to use numeric labels other than "1" in goto's or jumps, nor would I advise declaring a "1" label anywhere! As a matter of fact, it would be bad form to declare a numeric label, and it might conflict with the priority numbers used internally by asterisk. The syntax of the jump statement is: jump extension[,priority][@context] If priority is absent, it defaults to "1". If context is not present, it is assumed to be the same as that which contains the "jump".
context gotoexample { s => { begin: NoOp(Infinite Loop! yay!); Wait(1); jump s; // go to first extension in same extension } 3 => { jump s,begin; // go to label in different extension } 4 => { jump s,begin@gotoexample; // overkill go to label in same context } } context gotoexample2 { s => { end: jump s@gotoexample; // go to label in different context } }
Goto labels follow the same requirements as the Goto() application, except the last value has to be a label. If the label does not exist, you will have run-time errors. If the label exists, but in a different extension, you have to specify both the extension name and label in the goto, as in: goto s,z; if the label is in a different context, you specify context,extension,label. There is a note about using goto's in a switch statement below...
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
262
AEL introduces the special label "1", which is the beginning context number for most extensions.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
263
AEL Macros
A macro is defined in its own block like this. The arguments to the macro are specified with the name of the macro. They are then referred to by that same name. A catch block can be specified to catch special extensions.
macro std-exten( ext , dev ) { Dial(${dev}/${ext},20); switch(${DIALSTATUS}) { case BUSY: Voicemail(${ext},b); break; default: Voicemail(${ext},u); } catch a { VoiceMailMain(${ext}); return; } }
A macro is then called by preceding the macro name with an ampersand. Empty arguments can be passed simply with nothing between commas.
context example { _5XXX => &std-exten(${EXTEN}, "IAX2"); _6XXX => &std-exten(, "IAX2"); _7XXX => &std-exten(${EXTEN},); _8XXX => &std-exten(,); }
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
264
AEL Loops
AEL has implementations of 'for' and 'while' loops.
context loops { 1 => { for (x=0; ${x} < 3; x=${x} + 1) { Verbose(x is ${x} !); } } 2 => { y=10; while (${y} >= 0) { Verbose(y is ${y} !); y=${y}-1; } } }
NOTE: The conditional expression (the "${y} = 0" above) is wrapped in $[ ] so it can be evaluated. NOTE: The for loop test expression (the "$x 3" above) is wrapped in $[ ] so it can be evaluated.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
265
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
266
AEL Examples
context demo { s => { Wait(1); Answer(); TIMEOUT(digit)=5; TIMEOUT(response)=10; restart: Background(demo-congrats); instructions: for (x=0; ${x} < 3; x=${x} + 1) { Background(demo-instruct); WaitExten(); } } 2 => { Background(demo-moreinfo); goto s,instructions; } 3 => { LANGUAGE()=fr; goto s,restart; } 500 => { Playback(demo-abouttotry); Dial(IAX2/[email protected]); Playback(demo-nogo); goto s,instructions; } 600 => { Playback(demo-echotest); Echo(); Playback(demo-echodone); goto s,instructions; } # => { hangup: Playback(demo-thanks); Hangup(); } t => goto #,hangup; i => Playback(invalid); }
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
267
Macro calls to non-existent macros. Macro calls to contexts. Macro calls with argument count not matching the definition. application call to macro. (missing the '&') application calls to "GotoIf", "GotoIfTime", "while", "endwhile", "Random", and "execIf", will generate a message to consider converting the call to AEL goto, while, etc. constructs. goto a label in an empty extension. goto a non-existent label, either a within-extension, within-context, or in a different context, or in any included contexts. Will even check "sister" context references. All the checks done on the time values in the dial plan, are done on the time values in the ifTime() and includes times: o the time range has to have two times separated by a dash; o the times have to be in range of 0 to 24 hours. o The weekdays have to match the internal list, if they are provided; o the day of the month, if provided, must be in range of 1 to 31; o the month name or names have to match those in the internal list. (0.5) If an expression is wrapped in $[ ... ], and the compiler will wrap it again, a warning is issued. (0.5) If an expression had operators (you know, +,-,,/,issued. Maybe someone forgot to wrap a variable name?* (0.12) check for duplicate context names. (0.12) check for abstract contexts that are not included by any context. (0.13) Issue a warning if a label is a numeric value.
There are a subset of checks that have been removed until the proposed AAL (Asterisk Argument Language) is developed and incorporated into Asterisk. These checks will be:
(if the application argument analyzer is working: the presence of the 'j' option is reported as error. if options are specified, that are not available in an application. if you specify too many arguments to an application. a required argument is not present in an application call. Switch-case using "known" variables that applications set, that does not cover all the possible values. (a "default" case will solve this problem. Each "unhandled" value is listed. a Switch construct is used, which is uses a known variable, and the application that would set that variable is not called in the same extension. This is a warning only... Calls to applications not in the "applist" database (installed in /var/lib/asterisk/applist" on most systems). In an assignment statement, if the assignment is to a function, the function name used is checked to see if it one of the currently known functions. A warning is issued if it is not.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
268
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
269
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
270
Applications: See Asterisk - documentation of application commands Functions: Functions were implemented inside ${ .. } variable references, and supply many useful capabilities. Expressions: An expression evaluation engine handles items wrapped inside $[...]. This includes some string manipulation facilities, arithmetic expressions, etc. Application Gateway Interface: Asterisk can fork external processes that communicate via pipe. AGI applications can be written in any language. Very powerful applications can be added this way. Variables: Channels of communication have variables associated with them, and asterisk provides some global variables. These can be manipulated and/or consulted by the above mechanisms.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
271
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
272
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
273
Action: An action requested by the CLIENT to the Asterisk SERVER. Only one "Action" may be outstanding at any time. Response: A response to an action from the Asterisk SERVER to the CLIENT. Event: An event reported by the Asterisk SERVER to the CLIENT
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
274
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
275
AMI Examples
Login - Log a user into the manager interface.
Action: Originate Channel: sip/12345 Exten: 1234 Context: default Async: yes
Redirect with ExtraChannel: Attempted goal: Have a 'robot' program Redirect both ends of an already-connected call to a meetme room using the ExtraChannel feature through the management interface.
Action: Redirect Channel: DAHDI/1-1 ExtraChannel: SIP/3064-7e00 (varies) Exten: 680 Priority: 1
*Where 680 is an extension that sends you to a MeetMe room. There are a number of GUI tools that use the manager interface, please search the mailing list archives and the documentation page on the http://www.ast erisk.org web site for more information.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
276
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
277
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
278
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
279
Hint: Extension hint Incominglimit: SIP Peer incoming limit Key: Key: ASTdb Database key LastApplication: Last application executed (cdr_manager) LastCall: <num> Last call in queue LastData: Data for last application (cdr_manager) Link: (Status) ListItems: <number> Number of items in Eventlist (Optionally sent in "end" packet) Location: Interface (whatever that is -maybe tech/name in app_queue ) Loginchan: Login channel for agent Logintime: <number> Login time for agent Mailbox: VM Mailbox (id@vmcontext) (mailboxstatus, mailboxcount) MD5SecretExist: <Y | N> Whether secret exists in MD5 format Membership: <string> "Dynamic" or "static" member in queue Message: <text> Text message in ACKs, errors (explanation) Mix: <bool> Boolean parameter (monitor) MOHSuggest: Suggested music on hold class for peer (mohsuggest) NewMessages: <count> Count of new Mailbox messages (mailboxcount) Newname: ObjectName: Name of object in list OldName: Something in Rename (channel.c) OldMessages: <count> Count of old mailbox messages (mailboxcount) Outgoinglimit: SIP Peer outgoing limit Paused: <num> Queue member paused status Peer: <tech/name> "channel" specifier PeerStatus: <tech/name> Peer status code "Unregistered", "Registered", "Lagged", "Reachable" Penalty: <num> Queue penalty Priority: Extension priority Privilege: <privilege> AMI authorization class (system, call, log, verbose, command, agent, user) Pickupgroup: Pickup group for peer Position: <num> Position in Queue Queue: Queue name Reason: "Autologoff" Reason: "Chanunavail" Response: <response> response code, like "200 OK" "Success", "Error", "Follows" Restart: "True", "False" RegExpire: SIP registry expire RegExpiry: SIP registry expiry Reason: Originate reason code Seconds: Seconds (Status) Secret: <password> Authentication secret (for login) SecretExist: <Y | N> Whether secret exists Shutdown: "Uncleanly", "Cleanly" SIP-AuthInsecure: SIP-FromDomain: Peer FromDomain SIP-FromUser: Peer FromUser SIP-NatSupport: SIPLastMsg: Source: Source of call (dial event, cdr_manager) SrcUniqueID: UniqueID of source (dial event) StartTime: Start time of call (cdr_manager) State: Channel state State: <1 | 0> Mute flag Status: Registration status (Registry events SIP) Status: Extension status (Extensionstate) Status: Peer status (if monitored) ** Will change name ** "unknown", "lagged", "ok" Status: <num> Queue Status Status: DND status (DNDState) Time: <sec> Roundtrip time (latency) Timeout: Parking timeout time Timeout: Timeout for call setup (Originate)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
280
Timeout: <seconds> Timeout for call Uniqueid: Channel Unique ID Uniqueid1: Channel 1 Unique ID (Link event) Uniqueid2: Channel 2 Unique ID (Link event) User: Username (SIP registry) UserField: CDR userfield (cdr_manager) Val: Value to set/read in ASTdb Variable: Variable AND value to set (multiple separated with | in Originate) Variable: <name> For channel variables Value: <value> Value to set VoiceMailbox: VM Mailbox in SIPpeers Waiting: Count of mailbox messages (mailboxstatus)
Please try to re-use existing headers to simplify manager message parsing in clients.*
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
281
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
282
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
283
http://localhost:8088/asterisk/manager?action=login&username=foo&secret=bar
This logs you into the manager interface's "HTML" view. Once you're logged in, Asterisk stores a cookie on your browser (valid for the length of httptimeout) which is used to connect to the same session.
http://localhost:8088/asterisk/rawman?action=status
Assuming you've already logged into manager, this URI will give you a "raw" manager output for the "status" command.
http://localhost:8088/asterisk/mxml?action=status
This will give you the same status view but represented as AJAX data, theoretically compatible with RICO ( http://www.openrico.org).
http://localhost:8088/asterisk/static/ajamdemo.html
If you have enabled static content support and have done a make install, Asterisk will serve up a demo page which presents a live, but very basic, "astman" like interface. You can login with your username/secret for manager and have a basic view of channels as well as transfer and hangup calls. It's only tested in Firefox, but could probably be made to run in other browsers as well. A sample library (astman.js) is included to help ease the creation of manager HTML interfaces.
For the demo, there is no need for any external web server.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
284
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
285
Asterisk Queues
Pardon, but the dialplan in this tutorial will be expressed in AEL, the new Asterisk Extension Language. If you are not used to its syntax, we hope you will find it to some degree intuitive. If not, there are documents explaining its syntax and constructs.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
286
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
287
Using queues.conf
First of all, set up call queues in queue.conf Here is an example: queues.conf
; Cool Digium Queues [general] persistentmembers = yes ; General sales queue [sales-general] music=default context=sales strategy=ringall joinempty=strict leavewhenempty=strict ; Customer service queue [customerservice] music=default context=customerservice strategy=ringall joinempty=strict leavewhenempty=strict ; Support dispatch queue [dispatch] music=default context=dispatch strategy=ringall joinempty=strict leavewhenempty=strict
In the above, we have defined 3 separate calling queues: sales-general, customerservice, and dispatch. Please note that the sales-general queue specifies a context of "sales", and that customerservice specifies the context of "customerservice", and the dispatch queue specifies the context "dispatch". These three contexts must be defined somewhere in your dialplan. We will show them after the main menu below. In the [general] section, specifying the persistentmembers=yes, will cause the agent lists to be stored in astdb, and recalled on startup. The strategy=ringall will cause all agents to be dialed together, the first to answer is then assigned the incoming call. "joinempty" set to "strict" will keep incoming callers from being placed in queues where there are no agents to take calls. The Queue() application will return, and the dial plan can determine what to do next. If there are calls queued, and the last agent logs out, the remaining incoming callers will immediately be removed from the queue, and the Queue() call will return, IF the "leavewhenempty" is set to "strict".
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
288
context mainmenu { includes { digium; queues-loginout; } 0 => goto dispatch,s,1; 2 => goto sales,s,1; 3 => goto customerservice,s,1; 4 => goto dispatch,s,1; s => { Ringing(); Wait(1); Set(attempts=0); Answer(); Wait(1); Background(digium/ThankYouForCallingDigium); Background(digium/YourOpenSourceTelecommunicationsSupplier); WaitExten(0.3); repeat: Set(attempts=$[${attempts} + 1]); Background(digium/IfYouKnowYourPartysExtensionYouMayDialItAtAnyTime); WaitExten(0.1); Background(digium/Otherwise); WaitExten(0.1); Background(digium/ForSalesPleasePress2); WaitExten(0.2); Background(digium/ForCustomerServicePleasePress3); WaitExten(0.2); Background(digium/ForAllOtherDepartmentsPleasePress4); WaitExten(0.2); Background(digium/ToSpeakWithAnOperatorPleasePress0AtAnyTime); if( ${attempts} < 2 ) { WaitExten(0.3); Background(digium/ToHearTheseOptionsRepeatedPleaseHold); } WaitExten(5); if( ${attempts} < 2 ) goto repeat; Background(digium/YouHaveMadeNoSelection); Background(digium/ThisCallWillBeEnded); Background(goodbye); Hangup(); } }
The Contexts referenced from the queues.conf file
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
289
context sales { 0 => goto dispatch,s,1; 8 => Voicemail(${SALESVM}); s => { Ringing(); Wait(2); Background(digium/ThankYouForContactingTheDigiumSalesDepartment); WaitExten(0.3); Background(digium/PleaseHoldAndYourCallWillBeAnsweredByOurNextAvailableSalesRepresentativ e); WaitExten(0.3); Background(digium/AtAnyTimeYouMayPress0ToSpeakWithAnOperatorOr8ToLeaveAMessage); Set(CALLERID(name)=Sales); Queue(sales-general,t); Set(CALLERID(name)=EmptySalQ); goto dispatch,s,1; Playback(goodbye); Hangup(); } }
Please note that there is only one attempt to queue a call in the sales queue. All sales agents that are logged in will be rung.
context customerservice { 0 => { SetCIDName(CSVTrans); goto dispatch|s|1; } 8 => Voicemail(${CUSTSERVVM}); s => { Ringing(); Wait(2); Background(digium/ThankYouForCallingDigiumCustomerService); WaitExten(0.3); notracking: Background(digium/PleaseWaitForTheNextAvailableCustomerServiceRepresentative); WaitExten(0.3); Background(digium/AtAnyTimeYouMayPress0ToSpeakWithAnOperatorOr8ToLeaveAMessage); Set(CALLERID(name)=Cust Svc); Set(QUEUE_MAX_PENALTY=10); Queue(customerservice,t); Set(QUEUE_MAX_PENALTY=0); Queue(customerservice,t); Set(CALLERID(name)=EmptyCSVQ); goto dispatch,s,1; Background(digium/NoCustomerServiceRepresentativesAreAvailableAtThisTime); Background(digium/PleaseLeaveAMessageInTheCustomerServiceVoiceMailBox); Voicemail(${CUSTSERVVM}); Playback(goodbye); Hangup(); } }
Note that calls coming into customerservice will first be try to queue calls to those agents with a QUEUE_MAX_PENALTY of 10, and if none are available, then all agents are rung.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
290
context dispatch { s => { Ringing(); Wait(2); Background(digium/ThankYouForCallingDigium); WaitExten(0.3); Background(digium/YourCallWillBeAnsweredByOurNextAvailableOperator); Background(digium/PleaseHold); Set(QUEUE_MAX_PENALTY=10); Queue(dispatch|t); Set(QUEUE_MAX_PENALTY=20); Queue(dispatch|t); Set(QUEUE_MAX_PENALTY=0); Queue(dispatch|t); Background(digium/NoOneIsAvailableToTakeYourCall); Background(digium/PleaseLeaveAMessageInOurGeneralVoiceMailBox); Voicemail(${DISPATCHVM}); Playback(goodbye); Hangup(); } }
And in the dispatch context, first agents of priority 10 are tried, then 20, and if none are available, all agents are tried. Notice that a common pattern is followed in each of the three queue contexts: First, you set QUEUE_MAX_PENALTY to a value, then you call Queue(queue-name,option,...) (see the Queue application documetation for details) In the above, note that the "t" option is specified, and this allows the agent picking up the incoming call the luxury of transferring the call to other parties. The purpose of specifying the QUEUE_MAX_PENALTY is to develop a set of priorities amongst agents. By the above usage, agents with lower number priorities will be given the calls first, and then, if no-one picks up the call, the QUEUE_MAX_PENALTY will be incremented, and the queue tried again. Hopefully, along the line, someone will pick up the call, and the Queue application will end with a hangup. The final attempt to queue in most of our examples sets the QUEUE_MAX_PENALTY to zero, which means to try all available agents.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
291
context queues-loginout { 6092 => { Answer(); Read(AGENT_NUMBER,agent-enternum); VMAuthenticate(${AGENT_NUMBER}@default,s); Set(queue-announce-success=1); goto queues-manip,I${AGENT_NUMBER},1; } 6093 => { Answer(); Read(AGENT_NUMBER,agent-enternum); Set(queue-announce-success=1); goto queues-manip,O${AGENT_NUMBER},1; } }
In the above contexts, the agents dial 6092 to log into their queues, and they dial 6093 to log out of their queues. The agent is prompted for their agent number, and if they are logging in, their passcode, and then they are transferred to the proper extension in the queues-manip context. The queues-manip context does all the actual work:
context queues-manip { // Raquel Squelch _[IO]6121 => { &queue-addremove(dispatch,10,${EXTEN}); &queue-success(${EXTEN}); } // Brittanica Spears _[IO]6165 => { &queue-addremove(dispatch,20,${EXTEN}); &queue-success(${EXTEN}); } // Rock Hudson _[IO]6170 => { &queue-addremove(sales-general,10,${EXTEN}); &queue-addremove(customerservice,20,${EXTEN}); &queue-addremove(dispatch,30,${EXTEN}); &queue-success(${EXTEN}); } // Saline Dye-on _[IO]6070 => { &queue-addremove(sales-general,20,${EXTEN}); &queue-addremove(customerservice,30,${EXTEN}); &queue-addremove(dispatch,30,${EXTEN}); &queue-success(${EXTEN}); } }
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
292
In the above extensions, note that the queue-addremove macro is used to actually add or remove the agent from the applicable queue, with the applicable priority level. Note that agents with a priority level of 10 will be called before agents with levels of 20 or 30. In the above example, Raquel will be dialed first in the dispatch queue, if she has logged in. If she is not, then the second call of Queue() with priority of 20 will dial Brittanica if she is present, otherwise the third call of Queue() with MAX_PENALTY of 0 will dial Rock and Saline simultaneously. Also note that Rock will be among the first to be called in the sales-general queue, and among the last in the dispatch queue. As you can see in main menu, the callerID is set in the main menu so they can tell which queue incoming calls are coming from. The call to queue-success() gives some feedback to the agent as they log in and out, that the process has completed.
macro queue-success(exten) { if( ${queue-announce-success} > 0 ) { switch(${exten:0:1}) { case I: Playback(agent-loginok); Hangup(); break; case O: Playback(agent-loggedoff); Hangup(); break; } } }
The queue-addremove macro is defined in this manner:
macro queue-addremove(queuename,penalty,exten) { switch(${exten:0:1}) { case I: // Login AddQueueMember(${queuename},Local/${exten:1}@agents,${penalty}); break; case O: // Logout RemoveQueueMember(${queuename},Local/${exten:1}@agents); break; case P: // Pause PauseQueueMember(${queuename},Local/${exten:1}@agents); break; case U: // Unpause UnpauseQueueMember(${queuename},Local/${exten:1}@agents); break; default: // Invalid Playback(invalid); break; } }
Basically, it uses the first character of the exten variable, to determine the proper actions to take. In the above dial plan code, only the cases I or O are used, which correspond to the Login and Logout actions.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
293
context agents { // General sales queue 8010 => { Set(QUEUE_MAX_PENALTY=10); Queue(sales-general,t); Set(QUEUE_MAX_PENALTY=0); Queue(sales-general,t); Set(CALLERID(name)=EmptySalQ); goto dispatch,s,1; } // Customer Service queue 8011 => { Set(QUEUE_MAX_PENALTY=10); Queue(customerservice,t); Set(QUEUE_MAX_PENALTY=0); Queue(customerservice,t); Set(CALLERID(name)=EMptyCSVQ); goto dispatch,s,1; } 8013 => { Dial(iax2/sweatshop/9456@from-ecstacy); Set(CALLERID(name)=EmptySupQ); Set(QUEUE_MAX_PENALTY=10); Queue(support-dispatch,t); Set(QUEUE_MAX_PENALTY=20); Queue(support-dispatch,t); Set(QUEUE_MAX_PENALTY=0); // means no max Queue(support-dispatch,t); goto dispatch,s,1; } 6121 => &callagent(${RAQUEL},${EXTEN}); 6165 => &callagent(${SPEARS},${EXTEN}); 6170 => &callagent(${ROCK},${EXTEN}); 6070 => &callagent(${SALINE},${EXTEN}); }
In the above, the variables ${RAQUEL}, etc stand for actual devices to ring that person's phone (like DAHDI/37). The 8010, 8011, and 8013 extensions are purely for transferring incoming callers to queues. For instance, a customer service agent might want to transfer the caller to talk to sales. The agent only has to transfer to extension 8010, in this case. Here is the callagent macro, note that if a person in the queue is called, but does not answer, then they are automatically removed from the queue.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
294
macro callagent(device,exten) { if( ${GROUP_COUNT(${exten}@agents)}=0 ) { Set(OUTBOUND_GROUP_ONCE=${exten}@agents); Dial(${device},300,t); switch(${DIALSTATUS}) { case BUSY: Busy(); break; case NOANSWER: Set(queue-announce-success=0); goto queues-manip,O${exten},1; default: Hangup(); break; } } else { Busy(); } }
In the callagent macro above, the ${exten} will be 6121, or 6165, etc, which is the extension of the agent. The use of the GROUP_COUNT, and OUTBOUND_GROUP follow this line of thinking. Incoming calls can be queued to ring all agents in the current priority. If some of those agents are already talking, they would get bothersome call-waiting tones. To avoid this inconvenience, when an agent gets a call, the OUTBOUND_GROUP assigns that conversation to the group specified, for instance 6171@agents. The ${GROUP_COUNT()} variable on a subsequent call should return "1" for that group. If GROUP_COUNT returns 1, then the busy() is returned without actually trying to dial the agent.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
295
[macro-screen] exten=>s,1,Wait(.25) exten=>s,2,Read(ACCEPT,screen-callee-options,1) exten=>s,3,Gotoif($[${ACCEPT} = 1] ?50) exten=>s,4,Gotoif($[${ACCEPT} = 2] ?30) exten=>s,5,Gotoif($[${ACCEPT} = 3] ?40) exten=>s,6,Gotoif($[${ACCEPT} = 4] ?30:30) exten=>s,30,Set(MACRO_RESULT=CONTINUE) exten=>s,40,Read(TEXTEN,custom/screen-exten,) exten=>s,41,Gotoif($[${LEN(${TEXTEN})} = 3]?42:45) exten=>s,42,Set(MACRO_RESULT=GOTO:from-internal^${TEXTEN}^1) exten=>s,45,Gotoif($[${TEXTEN} = 0] ?46:4) exten=>s,46,Set(MACRO_RESULT=CONTINUE) exten=>s,50,Playback(after-the-tone) exten=>s,51,Playback(connected) exten=>s,52,Playback(beep)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
296
Queue Caveats
In the above examples, some of the possible error checking has been omitted, to reduce clutter and make the examples clearer.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
297
Queue Logs
In order to properly manage ACD queues, it is important to be able to keep track of details of call setups and teardowns in much greater detail than traditional call detail records provide. In order to support this, extensive and detailed tracing of every queued call is stored in the queue log, located (by default) in /var/log/asterisk/queue_log.
ABANDON(position|origposition|waittime) - The caller abandoned their position in the queue. The position is the caller's position in the queue when they hungup, the origposition is the original position the caller was when they first entered the queue, and the waittime is how long the call had been waiting in the queue at the time of disconnect. ADDMEMBER - A member was added to the queue. The bridged channel name will be populated with the name of the channel added to the queue. AGENTDUMP - The agent dumped the caller while listening to the queue announcement. AGENTLOGIN(channel) - The agent logged in. The channel is recorded. AGENTCALLBACKLOGIN(exten@context) - The callback agent logged in. The login extension and context is recorded. AGENTLOGOFF(channel|logintime) - The agent logged off. The channel is recorded, along with the total time the agent was logged in. AGENTCALLBACKLOGOFF(exten@context|logintime|reason) - The callback agent logged off. The last login extension and context is recorded, along with the total time the agent was logged in, and the reason for the logoff if it was not a normal logoff (e.g., Autologoff, Chanunavail) COMPLETEAGENT(holdtime|calltime|origposition) - The caller was connected to an agent, and the call was terminated normally by the agent. The caller's hold time and the length of the call are both recorded. The caller's original position in the queue is recorded in origposition. COMPLETECALLER(holdtime|calltime|origposition) - The caller was connected to an agent, and the call was terminated normally by the caller. The caller's hold time and the length of the call are both recorded. The caller's original position in the queue is recorded in origposition. CONFIGRELOAD - The configuration has been reloaded (e.g. with asterisk -rx reload) CONNECT(holdtime|bridgedchanneluniqueid|ringtime) - The caller was connected to an agent. Hold time represents the amount of time the caller was on hold. The bridged channel unique ID contains the unique ID of the queue member channel that is taking the call. This is useful when trying to link recording filenames to a particular call in the queue. Ringtime represents the time the queue members phone was ringing prior to being answered. ENTERQUEUE(url|callerid) - A call has entered the queue. URL (if specified) and Caller*ID are placed in the log. EXITEMPTY(position|origposition|waittime) - The caller was exited from the queue forcefully because the queue had no reachable members and it's configured to do that to callers when there are no reachable members. The position is the caller's position in the queue when they hungup, the origposition is the original position the caller was when they first entered the queue, and the waittime is how long the call had been waiting in the queue at the time of disconnect. EXITWITHKEY(key|position|origposition|waittime) - The caller elected to use a menu key to exit the queue. The key and the caller's
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
298
position in the queue are recorded. The caller's entry position and amoutn of time waited is also recorded. EXITWITHTIMEOUT(position|origposition|waittime) - The caller was on hold too long and the timeout expired. The position in the queue when the timeout occurred, the entry position, and the amount of time waited are logged. QUEUESTART - The queueing system has been started for the first time this session. REMOVEMEMBER - A queue member was removed from the queue. The bridge channel field will contain the name of the member removed from the queue. RINGNOANSWER(ringtime) - After trying for ringtime ms to connect to the available queue member, the attempt ended without the member picking up the call. Bad queue member! SYSCOMPAT - A call was answered by an agent, but the call was dropped because the channels were not compatible. TRANSFER(extension|context|holdtime|calltime|origposition) - Caller was transferred to a different extension. Context and extension are recorded. The caller's hold time and the length of the call are both recorded, as is the caller's entry position at the time of the transfer. PLEASE remember that transfers performed by SIP UA's by way of a reinvite may not always be caught by Asterisk and trigger off this event. The only way to be 100% sure that you will get this event when a transfer is performed by a queue member is to use the built-in transfer functionality of Asterisk.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
299
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
300
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
301
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
302
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
303
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
304
The part of the log entry identified by \<...\> is where the security event content resides. The security event content is a comma separated list of key value pairs. The key is the information element type, and the value is a quoted string that contains the associated meta data for that information element. Any embedded quotes within the content are escaped with a backslash. INFORMATION_ELEMENT_1="IE1 content",INFORMATION_ELEMENT_2="IE2 content" The following table includes potential information elements and what the associated content looks like:
IE: SecurityEvent Content: This is the security event sub-type. Values: FailedACL, InvalidAccountID, SessionLimit, MemoryLimit, LoadAverageLimit, RequestNotSupported, RequestNotAllowed, AuthMethodNotAllowed, ReqBadFormat, UnexpectedAddress, ChallengeResponseFailed, InvalidPassword IE: EventVersion Content: This is a numeric value that indicates when updates are made to the content of the event. Values: Monotonically increasing integer, starting at 1 IE: Service Content: This is the Asterisk service that generated the event. Values: TEST, SIP, AMI IE: Module Content: This is the Asterisk module that generated the event. Values: chan_sip IE: AccountID Content: This is a string used to identify the account associated with the event. In most cases, this would be a username. IE: SessionID Content: This is a string used to identify the session associated with the event. The format of the session identifier is specific to the service. In the case of SIP, this would be the Call-ID. IE: SessionTV Content: The time that the session associated with the SessionID started. Values: <seconds><microseconds> since epoch IE: ACLName Content: This is a string that identifies which named ACL is associated with this event. IE: LocalAddress Content: This is the local address that was contacted for the related event. Values: <Address Family>/<Transport>/<Address>/<Port> Examples: -> IPV4/UDP/192.168.1.1/5060 -> IPV4/TCP/192.168.1.1/5038 IE: RemoteAddress Content: This is the remote address associated with the event. Examples: -> IPV4/UDP/192.168.1.2/5060 -> IPV4/TCP/192.168.1.2/5038 IE: ExpectedAddress Content: This is the address that was expected to be the remote address. Examples: -> IPV4/UDP/192.168.1.2/5060 -> IPV4/TCP/192.168.1.2/5038 IE: EventTV Content: This is the timestamp of when the event occurred. Values: <seconds><microseconds> since epoch IE: RequestType Content: This is a service specific string that represents the invalid request IE: RequestParams
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
305
Content: This is a service specific string that represents relevant parameters given with a request that was considered invalid. IE: AuthMethod Content: This is a service specific string that represents an authentication method that was used or requested. IE: Challenge Content: This is a service specific string that represents the challenge provided to a user attempting challenge/response authentication. IE: Response Content: This is a service specific string that represents the response received from a user attempting challenge/response authentication. IE: ExpectedResponse Content: This is a service specific string that represents the response that was expected to be received from a user attempting challenge/response authentication.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
306
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
307
The sound tools are available in the subdirectory sound_tools/ which contains the following directories:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
308
audiofilter
The audiofilter application is used to "tune" the sound files in such a way that they sound good when being used while in a compressed format. The values in the scripts for creating the sound files supplied in repotools is essentially a high-pass filter that drops out audio below 100Hz (or so). (There is an ITU specification that states for 8KHz audio that is being compressed frequencies below a certain threshold should be removed because they make the resulting compressed audio sound worse than it should.) The audiofilter application is used by the 'converter' script located in the scripts subdirectory of repotools/sound_tools. The values being passed to the audiofilter application is as follows:
audiofilter -n 0.86916 -1.73829 0.86916 -d 1.00000 -1.74152 0.77536
The two options -n and -d are 'numerator' and 'denominator'. Per the author, Jean-Marc Valin, "These values are filter coefficients (-n means numerator, -d is denominator) expressed in the z-transform domain. There represent an elliptic filter that I designed with Octave such that 'the result sounds good'."
makeg722
The makeg722 application is used by the 'converters' script to generate the G.722 sound files that are shipped with Asterisk. It starts with the RAW sound files and then converts them to G.722.
scripts
The scripts folder is where all the magic happens. These are the scripts that the Asterisk open source team use to build the packaged audio files for the various formats that are distributed with Asterisk.
chkcore - used to check that the contents of core-sounds-lang.txt are in sync chkextra - same as above, but checks the extra sound files mkcore - script used to generate the core sounds packages mkextra - script used to generate the extra sounds packages mkmoh - script used to generate the music on hold packages converters - script used to convert the master files to various formats
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
309
What is CCSS?
Call Completion Supplementary Services (often abbreviated "CCSS" or simply "CC") allow for a caller to let Asterisk automatically alert him when a called party has become available, given that a previous call to that party failed for some reason. The two services offered are Call Completion on Busy Subscriber (CCBS) and Call Completion on No Response (CCNR). To illustrate, let's say that Alice attempts to call Bob. Bob is currently on a phone call with Carol, though, so Alice hears a busy signal. In this situation, assuming that Asterisk has been configured to allow for such activity, Alice would be able to request CCBS. Once Bob has finished his phone call, Alice will be alerted. Alice can then attempt to call Bob again.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
310
CCSS Glossary
In this document, we will use some terms which may require clarification. Most of these terms are specific to Asterisk, and are by no means standard.
CCBS: Call Completion on Busy Subscriber. When a call fails because the recipient's phone is busy, the caller will have the opportunity to request CCBS. When the recipient's phone is no longer busy, the caller will be alerted. The means by which the caller is alerted is dependent upon the type of agent used by the caller. CCNR: Call Completion on No Response. When a call fails because the recipient does not answer the phone, the caller will have the opportun- ity to request CCNR. When the recipient's phone becomes busy and then is no longer busy, the caller will be alerted. The means by which the caller is alerted is dependent upon the type of the agent used by the caller. Agent: The agent is the entity within Asterisk that communicates with and acts on behalf of the calling party. Monitor: The monitor is the entity within Asterisk that communicates with and monitors the status of the called party. Generic Agent: A generic agent is an agent that uses protocol-agnostic methods to communicate with the caller. Generic agents should only be used for phones, and never should be used for "trunks." Generic Monitor: A generic monitor is a monitor that uses protocol- agnostic methods to monitor the status of the called party. Like with generic agents, generic monitors should only be used for phones. Native Agent: The opposite of a generic agent. A native agent uses protocol-specific messages to communicate with the calling party. Native agents may be used for both phones and trunks, but it must be known ahead of time that the device with which Asterisk is communica- ting supports the necessary signaling. Native Monitor: The opposite of a generic monitor. A native monitor uses protocol-specific messages to subscribe to and receive notification of the status of the called party. Native monitors may be used for both phones and trunks, but it must be known ahead of time that the device with which Asterisk is communicating supports the necessary signaling. Offer: An offer of CC refers to the notification received by the caller that he may request CC. Request: When the caller decides that he would like to subscribe to CC, he will make a request for CC. Furthermore, the term may refer to any outstanding requests made by callers. Recall: When the caller attempts to call the recipient after being alerted that the recipient is available, this action is referred to as a "recall."
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
311
Requesting CC
Requesting CC is done differently depending on the type of agent the caller is using. With generic agents, the CallCompletionRequest application must be called in order to request CC. There are two different ways in which this may be called. It may either be called before the caller hangs up during the initial call, or the caller may hang up from the initial call and dial an extension which calls the CallCompletionRequest application. If the second method is used, then the caller will have until the cc_offer_timer expires to request CC. With native agents, the method for requesting CC is dependent upon the technology being used, coupled with the make of equipment. It may be possible to request CC using a programmable key on a phone or by clicking a button on a console. If you are using equipment which can natively support CC but do not know the means by which to request it, then contact the equipment manufacturer for more information.
Cancelling CC
CC may be canceled after it has been requested. The method by which this is accomplished differs based on the type of agent the calling party uses. When using a generic agent, the dialplan application CallRequestCancel is used to cancel CC. When using a native monitor, the method by which CC is cancelled depends on the protocol used. Likely, this will be done using a button on a phone. Keep in mind that if CC is cancelled, it cannot be un-cancelled.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
312
Once Asterisk has determined that the calling party has become available again, Asterisk will then move back to the process used in the section "Monitoring the Called Party."
The CC recall
The calling party will make its recall to the same extension that was dialed. Asterisk will provide a channel variable, CC_INTERFACES, to be used as an argument to the Dial application for CC recalls. It is strongly recommended that you use this channel variable during a CC recall. Listed are two reasons:
1. The dialplan may be written in such a way that the dialed destintations are dynamically generated. With such a dialplan, it cannot be guaranteed that the same interfaces will be recalled. 2. For calling destinations with native CC monitors, it may be necessary to dial a special string in order to notify the channel driver that the number being dialed is actually part of a CC recall.
Even if your call gets routed through local channels, the CC_INTERFACES variable will be populated with the appropriate values for that specific extension.
When the called parties are dialed, it is expected that a called party will answer, since Asterisk had previously determined that the party was available. However, it is possible that the called party may choose not to respond to the call, or he could have become busy again. In such a situation, the calling party must re-request CC if he wishes to still be alerted when the calling party has become available.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
313
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
314
As with all Asterisk components, CC is not perfect. If you should find a bug or wish to enhance the feature, please open an issue on https ://issues.asterisk.org. If writing an enhancement, please be sure to include a patch for the enhancement, or else the issue will be closed.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
315
sip.conf
[Mark] context=phone_calls cc_agent_policy=generic cc_monitor_policy=generic ;We will accept defaults for the rest of the cc parameters ;We also are not concerned with other SIP details for this ;example [Richard] context=phone_calls cc_agent_policy=generic cc_monitor_policy=generic
Now, let's write a simple dialplan
extensions.conf
[phone_calls] exten => 1000,1,Dial(SIP/Mark,20) exten => 1000,n,Hangup exten => 2000,1,Dial(SIP/Richard,20) exten => 2000,n,Hangup exten => 30,1,CallCompletionRequest exten => 30,n,Hangup exten => 31,1,CallCompletionCancel exten => 31,n,Hangup
Scenario 1: Mark picks up his phone and dials Richard by dialing 2000. Richard is currently on a call, so Mark hears a busy signal. Mark then hangs up, picks up the phone and dials 30 to call the CallCompletionRequest application. After some time, Richard finishes his call and hangs up. Mark is automatically called back by Asterisk. When Mark picks up his phone, Asterisk will dial extension 2000 for him. Scenario 2: Richard picks up his phone and dials Mark by dialing 1000. Mark has stepped away from his desk, and so he is unable to answer the phone within the 20 second dial timeout. Richard hangs up, picks the phone back up and then dials 30 to request call completion. Mark gets back to his desk and dials somebody's number. When Mark finishes the call, Asterisk detects that Mark's phone has had some activity and has become available again and rings Richard's phone. Once Richard picks up, Asterisk automatically dials exteision 1000 for him. Scenario 3: Much like scenario 1, Mark calls Richard and Richard is busy. Mark hangs up, picks the phone back up and then dials 30 to request call completion. After a little while, Mark realizes he doesn't actually need to talk to Richard, so he dials 31 to cancel call completion. When Richard becomes free, Mark will not automatically be redialed by Asterisk. Scenario 4: Richard calls Mark, but Mark is busy. About thirty seconds later, Richard decides that he should perhaps request call completion. However, since Richard's phone has the default cc_offer_timer of 20 seconds, he has run out of time to request call completion. He instead must attempt to dial Mark again manually. If Mark is still busy, Richard can attempt to request call completion on this second call instead. Scenario 5: Mark calls Richard, and Richard is busy. Mark requests call completion. Richard does not finish his current call for another 2 hours (7200 seconds). Since Mark has the default ccbs_available_timer of 4800 seconds set, Mark will not be automatically recalled by Asterisk when Richard finishes his call. Scenario 6: Mark calls Richard, and Richard does not respond within the 20 second dial timeout. Mark requests call completion. Richard does not use his phone again for another 4 hours (144000 seconds). Since Mark has the default ccnr_available_timer of 7200 seconds set, Mark will not be automatically recalled by Asterisk when Richard finishes his call.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
316
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
317
CDR Applications
SetAccount - Set account code for billing SetAMAFlags - Sets AMA flags NoCDR - Make sure no CDR is saved for a specific call ResetCDR - Reset CDR ForkCDR - Save current CDR and start a new CDR for this call Authenticate - Authenticates and sets the account code SetCDRUserField - Set CDR user field AppendCDRUserField - Append data to CDR User field
For more information, use the "core show application application" command. You can set default account codes and AMA flags for devices in channel configuration files, like sip.conf, iax.conf etc.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
318
CDR Fields
accountcode: What account number to use, (string, 20 characters) src: Caller*ID number (string, 80 characters) dst: Destination extension (string, 80 characters) dcontext: Destination context (string, 80 characters) clid: Caller*ID with text (80 characters) channel: Channel used (80 characters) dstchannel: Destination channel if appropriate (80 characters) lastapp: Last application if appropriate (80 characters) lastdata: Last application data (arguments) (80 characters) start: Start of call (date/time) answer: Answer of call (date/time) end: End of call (date/time) duration: Total time in system, in seconds (integer), from dial to hangup billsec: Total time call is up, in seconds (integer), from answer to hangup disposition: What happened to the call: ANSWERED, NO ANSWER, BUSY amaflags: What flags to use: DOCUMENTATION, BILL, IGNORE etc, specified on a per channel basis like accountcode. user field: A user-defined field, maximum 255 characters
In some cases, uniqueid is appended:
uniqueid: Unique Channel Identifier (32 characters) This needs to be enabled in the source code at compile time
If you use IAX2 channels for your calls, and allow 'full' transfers (not media-only transfers), then when the calls is transferred the server in the middle will no longer be involved in the signaling path, and thus will not generate accurate CDRs for that call. If you can, use media-only transfers with IAX2 to avoid this problem, or turn off transfers completely (although this can result in a media latency increase since the media packets have to traverse the middle server(s) in the call).
In 1.8 and later In some CDR backends, the following fields may also be supported:
linkedid: a unique identifier based on uniqueid. Unlike uniqueid, but spreads to other channels as transfers, dials, etc are performed peeraccount: the account code of the bridged channel sequence: a field that can be combined with uniqueid and linkedid to uniquely identify a CDR
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
319
CDR Variables
If the channel has a CDR, that CDR has its own set of variables which can be accessed just like channel variables. The following builtin variables are available.
${CDR(clid)} Caller ID ${CDR(src)} Source ${CDR(dst)} Destination ${CDR(dcontext)} Destination context ${CDR(channel)} Channel name ${CDR(dstchannel)} Destination channel ${CDR(lastapp)} Last app executed ${CDR(lastdata)} Last app's arguments ${CDR(start)} Time the call started. ${CDR(answer)} Time the call was answered. ${CDR(end)} Time the call ended. ${CDR(duration)} Duration of the call. ${CDR(billsec)} Duration of the call once it was answered. ${CDR(disposition)} ANSWERED, NO ANSWER, BUSY ${CDR(amaflags)} DOCUMENTATION, BILL, IGNORE etc ${CDR(accountcode)} The channel's account code. ${CDR(uniqueid)} The channel's unique id. ${CDR(userfield)} The channels uses specified field.
In addition, you can set your own extra variables by using Set(CDR(name)=value). These variables can be output into a text-format CDR by using the cdr_custom CDR driver; see the cdr_custom.conf.sample file in the configs directory for an example of how to do this.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
320
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
321
Compile, or recompile, asterisk so that it will now add support for cdr_odbc.
make clean && ./configure --with-odbc && make update && make && make install
Setup odbc configuration files. These are working examples from my system. You will need to modify for your setup. You are not required to store usernames or passwords here. /etc/odbcinst.ini
[FreeTDS] Description = FreeTDS ODBC driver for MSSQL Driver = /usr/lib/libtdsodbc.so Setup = /usr/lib/libtdsS.so FileUsage = 1
/etc/odbc.ini
[MSSQL-asterisk] description = Asterisk ODBC for MSSQL driver = FreeTDS server = 192.168.1.25 port = 1433 database = voipdb tds_version = 7.0 language = us_english
Only install one database connector. Do not confuse asterisk by using both ODBC (cdr_odbc) and FreeTDS (cdr_tds). This command will erase the contents of cdr_tds.conf
[ -f /etc/asterisk/cdr_tds.conf ] > /etc/asterisk/cdr_tds.conf
unixODBC requires the freeTDS package, but asterisk does not call freeTDS directly.
Now set up cdr_odbc configuration files. These are working samples from my system. You will need to modify for your setup. Define your usernames and passwords here, secure file as well. /etc/asterisk/cdr_odbc.conf
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
322
Start asterisk in verbose mode. You should see that asterisk logs a connection to the database and will now record every call to the database when it's complete.
Compile, or recompile, asterisk so that it will now add support for cdr_tds.
make clean && ./configure --with-tds && make update && make && make install
Only install one database connector. Do not confuse asterisk by using both ODBC (cdr_odbc) and FreeTDS (cdr_tds). This command will erase the contents of cdr_odbc.conf
[ -f /etc/asterisk/cdr_odbc.conf ] > /etc/asterisk/cdr_odbc.conf
Setup cdr_tds configuration files. These are working samples from my system. You will need to modify for your setup. Define your usernames and passwords here, secure file as well.
/etc/asterisk/cdr_tds.conf [global] hostname=192.168.1.25 port=1433 dbname=voipdb user=voipdbuser password=voipdpass charset=BIG5
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
323
CREATE TABLE cdr ( [accountcode] [varchar] (20) NULL , [src] [varchar] (80) NULL , [dst] [varchar] (80) NULL , [dcontext] [varchar] (80) NULL , [clid] [varchar] (80) NULL , [channel] [varchar] (80) NULL , [dstchannel] [varchar] (80) NULL , [lastapp] [varchar] (80) NULL , [lastdata] [varchar] (80) NULL , [start] [datetime] NULL , [answer] [datetime] NULL , [end] [datetime] NULL , [duration] [int] NULL , [billsec] [int] NULL , [disposition] [varchar] (20) NULL , [amaflags] [varchar] (16) NULL , [uniqueid] [varchar] (150) NULL , [userfield] [varchar] (256) NULL )
Start asterisk in verbose mode. You should see that asterisk logs a connection to the database and will now record every call to the database when it's complete.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
324
Native Alternatively, there is a native MySQL CDR module. To use it, configure the module in cdr_mysql.conf. Create a table called cdr under the database name you will be using the following schema.
CREATE TABLE cdr ( calldate datetime NOT NULL default '0000-00-00 00:00:00', clid varchar(80) NOT NULL default '', src varchar(80) NOT NULL default '', dst varchar(80) NOT NULL default '', dcontext varchar(80) NOT NULL default '', channel varchar(80) NOT NULL default '', dstchannel varchar(80) NOT NULL default '', lastapp varchar(80) NOT NULL default '', lastdata varchar(80) NOT NULL default '', duration int(11) NOT NULL default '0', billsec int(11) NOT NULL default '0', disposition varchar(45) NOT NULL default '', amaflags int(11) NOT NULL default '0', accountcode varchar(20) NOT NULL default '', uniqueid varchar(32) NOT NULL default '', userfield varchar(255) NOT NULL default '' );
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
325
; Sample Asterisk config file for CDR logging to PostgresSQL [global] hostname=localhost port=5432 dbname=asterisk password=password user=postgres table=cdr
Now create a table in postgresql for your cdrs
CREATE TABLE cdr ( calldate timestamp NOT NULL , clid varchar (80) NOT NULL , src varchar (80) NOT NULL , dst varchar (80) NOT NULL , dcontext varchar (80) NOT NULL , channel varchar (80) NOT NULL , dstchannel varchar (80) NOT NULL , lastapp varchar (80) NOT NULL , lastdata varchar (80) NOT NULL , duration int NOT NULL , billsec int NOT NULL , disposition varchar (45) NOT NULL , amaflags int NOT NULL , accountcode varchar (20) NOT NULL , uniqueid varchar (150) NOT NULL , userfield varchar (255) NOT NULL );
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
326
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
327
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
328
Configuration of the Radiusclient library By default all the configuration files of the radiusclient library will be in /usr/local/etc/radiusclient-ng directory. File "radiusclient.conf" Open the file and find lines containing the following:
authserver localhost
This is the hostname or IP address of the RADIUS server used for authentication. You will have to change this unless the server is running on the same host as your Asterisk PBX.
acctserver localhost
This is the hostname or IP address of the RADIUS server used for accounting. You will have to change this unless the server is running on the same host as your Asterisk PBX. File "servers" RADIUS protocol uses simple access control mechanism based on shared secrets that allows RADIUS servers to limit access from RADIUS clients. A RADIUS server is configured with a secret string and only RADIUS clients that have the same secret will be accepted. You need to configure a shared secret for each server you have configured in radiusclient.conf file in the previous step. The shared secrets are stored in /usr/local/etc/radiusclient-ng/servers file. Each line contains hostname of a RADIUS server and shared secret used in communication with that server. The two values are separated by white spaces. Configure shared secrets for every RADIUS server you are going to use.
File "dictionary"
Asterisk uses some attributes that are not included in the dictionary of radiusclient library, therefore it is necessary to add them. A file called dictionary.digium (kept in the contrib dir) was created to list all new attributes used by Asterisk. Add to the end of the main dictionary file /usr/local/etc/radiusclient-ng/dictionary the line:
$INCLUDE /path/to/dictionary.digium
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
329
All the configuration files of FreeRADIUS server will be in /usr/local/etc/raddb directory. Configuration of the FreeRADIUS Server There are several files that have to be modified to configure the RADIUS server. These are presented next. File "clients.conf" File /usr/local/etc/raddb/clients.conf contains description of RADIUS clients that are allowed to use the server. For each of the clients you need to specify its hostname or IP address and also a shared secret. The shared secret must be the same string you configured in radiusclient library. Example:
client myhost { secret = mysecret shortname = foo }
This fragment allows access from RADIUS clients on "myhost" if they use "mysecret" as the shared secret. The file already contains an entry for localhost (127.0.0.1), so if you are running the RADIUS server on the same host as your Asterisk server, then modify the existing entry instead, replacing the default password. File "dictionary"
The following procedure brings the dictionary.digium file to previous versions of FreeRADIUS. File /usr/local/etc/raddb/dictionary contains the dictionary of FreeRADIUS server. You have to add the same dictionary file (dictionary.digium), which you added to the dictionary of radiusclient-ng library. You can include it into the main file, adding the following line at the end of file /usr/local/etc/raddb/dictionary:
$INCLUDE /path/to/dictionary.digium
That will include the same new attribute definitions that are used in radiusclient-ng library so the client and server will understand each other.
"Asterisk-Acc-Code", The account name of detail records "Asterisk-Src", "Asterisk-Dst", "Asterisk-Dst-Ctx", The destination context "Asterisk-Clid",
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
330
"Asterisk-Chan", The channel "Asterisk-Dst-Chan", (if applicable) "Asterisk-Last-App", Last application run on the channel "Asterisk-Last-Data", Argument to the last channel "Asterisk-Start-Time", "Asterisk-Answer-Time", "Asterisk-End-Time", "Asterisk-Duration", Duration is the whole length that the entire call lasted. ie. call rx'd to hangup "end time" minus "start time" "Asterisk-Bill-Sec", The duration that a call was up after other end answered which will be <= to duration "end time" minus "answer time" "Asterisk-Disposition", ANSWERED, NO ANSWER, BUSY "Asterisk-AMA-Flags", DOCUMENTATION, BILL, IGNORE etc, specified on a per channel basis like accountcode. "Asterisk-Unique-ID", Unique call identifier "Asterisk-User-Field" User field set via SetCDRUserField
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
331
Prerequisites
Asterisk communicates with Google Voice and Google Talk using the chan_motif Channel Driver and the res_xmpp Resource module. Before proceeding, please ensure that both are compiled and part of your installation. Compilation of res_xmpp and chan_motif for use with Google Talk / Voice are dependant on the iksemel library files as well as the OpenSSL development libraries presence on your system. Calling using Google Voice or via the Google Talk web client requires the use of Asterisk 11.0 or greater. Older versions of Asterisk will not work. For basic calling between Google Talk web clients, you need a Google Mail account. For calling to and from the PSTN, you will need a Google Voice account. In your Google account, you'll want to change the Chat setting from the default of "Automatically allow people that I communicate with often to chat with me and see when I'm online" to the second option of "Only allow people that I've explicitly approved to chat with me and see when I'm online." IPv6 is currently not supported. Use of IPv4 is required. Google Voice can now be used with Google Apps accounts.
RTP configuration
ICE support is required for chan_motif to operate. It is disabled by default and must be explicitly enabled in the RTP configuration file rtp.conf as follows.
[general] icesupport=yes
If this option is not enabled you will receive the following error message.
Unable to add Google ICE candidates as ICE support not available or no candidates available
Motif configuration
The Motif channel driver is configured with the motif.conf configuration file, typically located in /etc/asterisk. What follows is an example configuration for successful operation.
1. Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. 332
1. 2. 3. 4.
That calls will terminate to or originate from the incoming-motif context; context=incoming-motif That all codecs are first explicitly disallowed That G.711 ulaw is allowed The an XMPP connection called "google" is to be used
Google lists supported audio codecs on this page - https://developers.google.com/talk/open_communications Per section, 5, the supported codecs are:
1. 2. 3. 4. 5. 6.
Our experience shows this not to be the case. Rather, the codecs, supported by Asterisk, and seen in an invite from Google Chat are:
1. 2. 3. 4. 5. 6.
It should be noted that calling using Google Voice requires the G.711 ulaw codec. So, if you want to make sure Google Voice calls work, allow G.711 ulaw, at a minimum.
XMPP Configuration
The res_xmpp Resource is configured with the xmpp.conf configuration file, typically located in /etc/asterisk. What follows is an example configuration for successful operation.
The default general section does not need any modification. The google section of this configuration specifies several items.
1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
The type is set to client, as we're connecting to Google as a service; type=client The serverhost is Google's talk server; serverhost=talk.google.com Our username is configured as [email protected]; [email protected] Our password is configured using the secret option; secret=your_google_password Google's talk service operates on port 5222; port=5222 Our priority is set to 25; priority=25 TLS encryption is required by Google; usetls=yes Simple Authentication and Security Layer (SASL) is used by Google; usesasl=yes We set a status message so other Google chat users can see that we're an Asterisk server; statusmessage="I am available" We set a timeout for receiving message from Google that allows for plenty of time in the event of network delay; timeout=5
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
333
With priorities, the higher the setting value, the more any client using that value is preferred as a destination for inbound calls, in deference to any other client with a lower priority value. Known values of commonly used clients include the Gmail chat client, which maintains a priority of 20, and the Windows GTalk client, which uses a priority of 24. The maximum allowable value is 127. Thus, setting one's priority option for the XMPP peer in res_xmpp.conf to a value higher than 24 will cause inbound calls to flow to Asterisk, even while one is logged into either Gmail or the Windows GTalk client. Outbound calls are unaffected by the priority setting.
Phone configuration
Now, let's create a phone. The configuration of a SIP device for this purpose would, in sip.conf, typically located in /etc/asterisk, look something like:
[malcolm] type=peer secret=my_secure_password host=dynamic context=local
Dialplan configuration
Incoming calls
Next, let's configure our dialplan to receive an incoming call from Google and route it to the SIP phone we created. To do this, our dialplan, extensions.conf, typically located in /etc/asterisk, would look like:
[incoming-motif] exten => s,1,NoOp() same => n,Wait(1) same => n,Answer() same => n,SendDTMF(1) same => n,Dial(SIP/malcolm,20)
Did you know that the Google Chat client does this same thing; it waits, and then sends a DTMF 1. Really.
This example uses the "s" unmatched extension, because we're only configuring one client connection in this example. In this example, we're Waiting 1 second, answering the call, sending the DTMF "1" back to Google, and then dialing the call. We do this, because inbound calls from Google enable, even if it's disabled in your Google Voice control panel, call screening. Without this SendDTMF event, you'll have to confirm with Google whether or not you want to answer the call.
Using Google's voicemail Another method for accomplishing the sending of the DTMF event is to use Dial option "D." The D option tells Asterisk to send a specified DTMF string after the called party has answered. DTMF events specified before a colon are sent to the called party. DTMF events specified after a colon are sent to the calling party. In this example then, one does not need to actually answer the call first, though one should still wait at least a second for things, like STUN setup, to finish. This means that if the called party doesn't answer, Google will resort to sending the call to one's Google Voice voicemail box, instead of leaving it at Asterisk.
Filtering Caller ID The inbound CallerID from Google is going to look a bit nasty, e.g.:
[email protected]/srvres-MTAuMjE4LjIuMTk3Ojk4MzM=
Your VoIP client (SIPDroid) might not like this, so let's simplify that Caller ID a bit, and make it more presentable for your phone's display. Here's the example that we'll step through:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
334
First, we set a variable called crazygooglecid to be equal to the name field of the CALLERID function. Next, we use the CUT function to grab everything that's before the @ symbol, and save it in a new variable called stripcrazysuffix. We'll set this new variable to the CALLERID that we're going to use for our Dial. Finally, we'll actually Dial our internal destination.
Outgoing calls
Outgoing calls to Google Talk users take the form of:
exten => 100,1,Dial(Motif/google/[email protected],,r)
Where the technology is "Motif," the dialing peer is "google" as defined in xmpp.conf, and the dial string is the Google account name. We use the Dial option "r" because Google doesn't provide ringing indications. Outgoing calls made to Google Voice take the form of:
exten => _1XXXXXXXXXX,1,Dial(Motif/google/${EXTEN}@voice.google.com,,r)
Where the technology is "Motif," the dialing peer is "google" as defined in motif.conf, and the dial string is a full E.164 number, sans the plus character. Again, we use Dial option "r" because Google doesn't provide ringing indications.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
335
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
336
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
337
12:47:12","fxs.50","150","150","","","701","extension","Zap/50-1","ParkedCall","701","DOCUMENTATION","","1178736428.5","","" ;;; "EV_BRIDGE_START","2007-05-09 12:47:12","fxs.50","150","150","","","701","extension","Zap/50-1","ParkedCall","701","DOCUMENTATION","","1178736428.5","","Zap/51 -1" ;;; bridge begins between 150 and recently parked 151 (150 and 151 are conversing, then 151 hits flash) "EV_CHAN_START","2007-05-09 12:47:51","fxs.51","151","","","","s","extension","Zap/51-2","","","DOCUMENTATION","","1178736471.6","","" ;;; 39 seconds later, 51-2 channel is created. (151 flashes hook) "EV_HOOKFLASH","2007-05-09 12:47:51","","151","152","","","","extension","Zap/51-1","Bridged Call","Zap/50-1","DOCUMENTATION","","1178736378.4","","Zap/51-2" ;;; a marker to record that 151 flashed the hook "EV_BRIDGE_END","2007-05-09 12:47:51","fxs.50","150","150","","","701","extension","Zap/50-1","ParkedCall","701","DOCUMENTATION","","1178736428.5","","Zap/51 -1" ;;; bridge ends between 150 and 151 "EV_BRIDGE_START","2007-05-09 12:47:51","fxs.50","150","150","","","701","extension","Zap/50-1","ParkedCall","701","DOCUMENTATION","","1178736428.5","","Zap/51 -1" ;;; 0-second bridge from 150 to ? 150 gets no sound at all "EV_BRIDGE_END","2007-05-09 12:47:51","fxs.50","150","150","","","701","extension","Zap/50-1","ParkedCall","701","DOCUMENTATION","","1178736428.5","","Zap/51 -1" ;;; "EV_BRIDGE_START","2007-05-09 12:47:51","fxs.50","150","150","","","701","extension","Zap/50-1","ParkedCall","701","DOCUMENTATION","","1178736428.5","","Zap/51 -1" ;;; bridge start on 150 (151 has dialtone after hitting flash; dials 152) "EV_APP_START","2007-05-09 12:47:55","fxs.51","151","151","","","152","extension","Zap/51-2","Dial","Zap/52|30|TtWw","DOCUMENTATION","","1178736471.6","","" ;;; 151-2 dials 152 after 4 seconds "EV_CHAN_START","2007-05-09 12:47:55","fxs.52","152","","","","s","extension","Zap/52-1","","","DOCUMENTATION","","1178736475.7" ,"","" ;;; 152 channel created to ring 152. (152 ringing) "EV_ANSWER","2007-05-09 12:47:58","","152","151","","","152","extension","Zap/52-1","AppDial","(Outgoing Line)","DOCUMENTATION","","1178736475.7","","" ;;; 3 seconds later, 152 answers "EV_ANSWER","2007-05-09 12:47:58","fxs.51","151","151","","","152","extension","Zap/51-2","Dial","Zap/52|30|TtWw","DOCUMENTATION","","1178736471.6","","" ;;; ... and 151-2 also answers "EV_BRIDGE_START","2007-05-09 12:47:59","fxs.51","151","151","","","152","extension","Zap/51-2","Dial","Zap/52|30|TtWw","DOCUMENTATION","","1178736471.6","","Z ap/51-1" ;;; 1 second later, bridge formed betw. 151-2 and 151 (152 answers, 151 and 152 convering; 150 is listening to silence; 151 hits flash again... to start a 3way) "EV_3WAY_START","2007-05-09 12:48:58","","151","152","","","","extension","Zap/51-1","Bridged Call","Zap/50-1","DOCUMENTATION","","1178736378.4","","Zap/51-2" ;;; another hook-flash to begin a 3-way conference "EV_BRIDGE_END","2007-05-09 12:48:58","fxs.50","150","150","","","701","extension","Zap/50-1","ParkedCall","701","DOCUMENTATION","","1178736428.5","","Zap/51 -1" ;;; - almost 1 minute later, the bridge ends (151 flashes hook again) "EV_BRIDGE_START","2007-05-09 12:48:58","fxs.50","150","150","","","701","extension","Zap/50-1","ParkedCall","701","DOCUMENTATION","","1178736428.5","","Zap/51 -1" ;;; 0-second bridge at 150. (3 way conf formed) "EV_BRIDGE_END","2007-05-09 12:48:58","fxs.50","150","150","","","701","extension","Zap/50-1","ParkedCall","701","DOCUMENTATION","","1178736428.5","","Zap/51 -1" ;;; "EV_BRIDGE_START","2007-05-09 12:48:58","fxs.50","150","150","","","701","extension","Zap/50-1","ParkedCall","701","DOCUMENTATION","","1178736428.5","","Zap/51 -1" ;;; bridge starts for 150 (3way now, then 151 hangs up.) "EV_BRIDGE_END","2007-05-09 12:49:26","fxs.50","150","150","","","701","extension","Zap/50-1","ParkedCall","701","DOCUMENTATION","","1178736428.5","","Zap/51 -1" ;;; 28 seconds later, bridge ends "EV_HANGUP","2007-05-09 12:49:26","","151","152","","","","extension","Zap/51-1","Bridged Call","Zap/50-1","DOCUMENTATION","","1178736378.4","","" ;;; 151 hangs up, leaves 150 and 152 connected "EV_CHAN_END","2007-05-09 12:49:26","","151","152","","","","extension","Zap/51-1","Bridged Call","Zap/50-1","DOCUMENTATION","","1178736378.4","","" ;;; 151 channel ends "EV_CHAN_END","2007-05-09 12:49:26","fxs.51","151","151","","","h","extension","Zap/51-2ZOMBIE","","","DOCUMENTATION","","1178736428.5","","" ;;; 152-2 channel ends (zombie) (just 150 and 152 now) "EV_BRIDGE_END","2007-05-09 12:50:13","fxs.50","150","150","","","152","extension","Zap/50-1","Dial","Zap/52|30|TtWw","DOCUMENTATION","","1178736471.6","","" ;;; 47 sec later, the bridge from 150 to 152 ends "EV_HANGUP","2007-05-09 12:50:13","","152","151","","","","extension","Zap/52-1","Bridged Call","Zap/50-1","DOCUMENTATION","","1178736475.7","","" ;;; 152 hangs up "EV_CHAN_END","2007-05-09 12:50:13","","152","151","","","","extension","Zap/52-1","Bridged Call","Zap/50-1","DOCUMENTATION","","1178736475.7","","" ;;; 152 channel ends "EV_HANGUP","2007-05-09 12:50:13","fxs.50","150","150","","","h","extension","Zap/50-1","","","DOCUMENTATION","","1178736471.6","","" ;;; 150 hangs up
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
338
In terms of Manager events, the above Events correspond to the following 80 Manager events:
Event: Newchannel Privilege: call,all Channel: Zap/52-1 State: Rsrvd CallerIDNum: 152 CallerIDName: fxs.52 Uniqueid: 1178801102.5 Event: Newcallerid Privilege: call,all Channel: Zap/52-1 CallerIDNum: 152 CallerIDName: fxs.52 Uniqueid: 1178801102.5 CID-CallingPres: 0 (Presentation Allowed, Not Screened) Event: Newcallerid Privilege: call,all Channel: Zap/52-1 CallerIDNum: 152 CallerIDName: fxs.52 Uniqueid: 1178801102.5 CID-CallingPres: 0 (Presentation Allowed, Not Screened) Event: Newstate Privilege: call,all Channel: Zap/52-1 State: Ring CallerIDNum: 152 CallerIDName: fxs.52 Uniqueid: 1178801102.5 Event: Newexten Privilege: call,all Channel: Zap/52-1 Context: extension Extension: 151 Priority: 1 Application: Set AppData: CDR(myvar)=zingo Uniqueid: 1178801102.5 Event: Newexten Privilege: call,all Channel: Zap/52-1 Context: extension Extension: 151 Priority: 2 Application: Dial AppData: Zap/51|30|TtWw Uniqueid: 1178801102.5 Event: Newchannel Privilege: call,all Channel: Zap/51-1 State: Rsrvd CallerIDNum: 151 CallerIDName: fxs.51 Uniqueid: 1178801108.6 Event: Newstate Privilege: call,all Channel: Zap/51-1 State: Ringing CallerIDNum: 152 CallerIDName: fxs.52 Uniqueid: 1178801108.6 Event: Dial Privilege: call,all SubEvent: Begin Source: Zap/52-1 Destination: Zap/51-1 CallerIDNum: 152 CallerIDName: fxs.52 SrcUniqueID: 1178801102.5 DestUniqueID: 1178801108.6 Event: Newcallerid Privilege: call,all Channel: Zap/51-1 CallerIDNum: 151 CallerIDName: <Unknown> Uniqueid: 1178801108.6 CID-CallingPres: 0 (Presentation Allowed, Not Screened)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
339
Event: Newstate Privilege: call,all Channel: Zap/52-1 State: Ringing CallerIDNum: 152 CallerIDName: fxs.52 Uniqueid: 1178801102.5 Event: Newstate Privilege: call,all Channel: Zap/51-1 State: Up CallerIDNum: 151 CallerIDName: <unknown> Uniqueid: 1178801108.6 Event: Newstate Privilege: call,all Channel: Zap/52-1 State: Up CallerIDNum: 152 CallerIDName: fxs.52 Uniqueid: 1178801102.5 Event: Link Privilege: call,all Channel1: Zap/52-1 Channel2: Zap/51-1 Uniqueid1: 1178801102.5 Uniqueid2: 1178801108.6 CallerID1: 152 CallerID2: 151 Event: Unlink Privilege: call,all Channel1: Zap/52-1 Channel2: Zap/51-1 Uniqueid1: 1178801102.5 Uniqueid2: 1178801108.6 CallerID1: 152 CallerID2: 151 Event: Link Privilege: call,all Channel1: Zap/52-1 Channel2: Zap/51-1 Uniqueid1: 1178801102.5 Uniqueid2: 1178801108.6 CallerID1: 152 CallerID2: 151 Event: Unlink Privilege: call,all Channel1: Zap/52-1 Channel2: Zap/51-1 Uniqueid1: 1178801102.5 Uniqueid2: 1178801108.6 CallerID1: 152 CallerID2: 151 Event: ParkedCall Privilege: call,all Exten: 701 Channel: Zap/51-1 From: Zap/52-1 Timeout: 45 CallerIDNum: 151 CallerIDName: <unknown> Event: Dial Privilege: call,all SubEvent: End Channel: Zap/52-1 DialStatus: ANSWER Event: Newexten Privilege: call,all Channel: Zap/52-1 Context: extension Extension: h Priority: 1 Application: Goto AppData: label1 Uniqueid: 1178801102.5 Event: Newexten Privilege: call,all Channel: Zap/52-1 Context: extension Extension: h Priority: 4 Application: Goto AppData: label2 Uniqueid: 1178801102.5
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
340
Event: Newexten Privilege: call,all Channel: Zap/52-1 Context: extension Extension: h Priority: 2 Application: NoOp AppData: In Hangup! myvar is zingo and accountcode is billsec is 26 and duration is 40 and end is 2007-05-10 06:45:42. Uniqueid: 1178801102.5 Event: Newexten Privilege: call,all Channel: Zap/52-1 Context: extension Extension: h Priority: 3 Application: Goto AppData: label3 Uniqueid: 1178801102.5 Event: Newexten Privilege: call,all Channel: Zap/52-1 Context: extension Extension: h Priority: 5 Application: NoOp AppData: More Hangup message after hopping around" Uniqueid: 1178801102.5 Event: Hangup Privilege: call,all Channel: Zap/52-1 Uniqueid: 1178801102.5 Cause: 16 Cause-txt: Normal Clearing Event: Newchannel Privilege: call,all Channel: Zap/50-1 State: Rsrvd CallerIDNum: 150 CallerIDName: fxs.50 Uniqueid: 1178801162.7 Event: Newcallerid Privilege: call,all Channel: Zap/50-1 CallerIDNum: 150 CallerIDName: fxs.50 Uniqueid: 1178801162.7 CID-CallingPres: 0 (Presentation Allowed, Not Screened) Event: Newcallerid Privilege: call,all Channel: Zap/50-1 CallerIDNum: 150 CallerIDName: fxs.50 Uniqueid: 1178801162.7 CID-CallingPres: 0 (Presentation Allowed, Not Screened) Event: Newstate Privilege: call,all Channel: Zap/50-1 State: Ring CallerIDNum: 150 CallerIDName: fxs.50 Uniqueid: 1178801162.7 Event: Newexten Privilege: call,all Channel: Zap/50-1 Context: extension Extension: 701 Priority: 1 Application: ParkedCall AppData: 701 Uniqueid: 1178801162.7 Event: UnParkedCall Privilege: call,all Exten: 701 Channel: Zap/51-1 From: Zap/50-1 CallerIDNum: 151 CallerIDName: <unknown> Event: Newstate Privilege: call,all Channel: Zap/50-1 State: Up CallerIDNum: 150 CallerIDName: fxs.50 Uniqueid: 1178801162.7
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
341
Event: Link Privilege: call,all Channel1: Zap/50-1 Channel2: Zap/51-1 Uniqueid1: 1178801162.7 Uniqueid2: 1178801108.6 CallerID1: 150 CallerID2: 151 Event: Newchannel Privilege: call,all Channel: Zap/51-2 State: Rsrvd CallerIDNum: 151 CallerIDName: fxs.51 Uniqueid: 1178801218.8 Event: Unlink Privilege: call,all Channel1: Zap/50-1 Channel2: Zap/51-1 Uniqueid1: 1178801162.7 Uniqueid2: 1178801108.6 CallerID1: 150 CallerID2: 151 Event: Link Privilege: call,all Channel1: Zap/50-1 Channel2: Zap/51-1 Uniqueid1: 1178801162.7 Uniqueid2: 1178801108.6 CallerID1: 150 CallerID2: 151 Event: Unlink Privilege: call,all Channel1: Zap/50-1 Channel2: Zap/51-1 Uniqueid1: 1178801162.7 Uniqueid2: 1178801108.6 CallerID1: 150 CallerID2: 151 Event: Link Privilege: call,all Channel1: Zap/50-1 Channel2: Zap/51-1 Uniqueid1: 1178801162.7 Uniqueid2: 1178801108.6 CallerID1: 150 CallerID2: 151 Event: Newcallerid Privilege: call,all Channel: Zap/51-2 CallerIDNum: 151 CallerIDName: fxs.51 Uniqueid: 1178801218.8 CID-CallingPres: 0 (Presentation Allowed, Not Screened) Event: Newcallerid Privilege: call,all Channel: Zap/51-2 CallerIDNum: 151 CallerIDName: fxs.51 Uniqueid: 1178801218.8 CID-CallingPres: 0 (Presentation Allowed, Not Screened) Event: Newstate Privilege: call,all Channel: Zap/51-2 State: Ring CallerIDNum: 151 CallerIDName: fxs.51 Uniqueid: 1178801218.8 Event: Newexten Privilege: call,all Channel: Zap/51-2 Context: extension Extension: 152 Priority: 1 Application: Set AppData: CDR(myvar)=zingo Uniqueid: 1178801218.8 Event: Newexten Privilege: call,all Channel: Zap/51-2 Context: extension Extension: 152 Priority: 2 Application: Dial AppData: Zap/52|30|TtWw
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
342
Uniqueid: 1178801218.8 Event: Newchannel Privilege: call,all Channel: Zap/52-1 State: Rsrvd CallerIDNum: 152 CallerIDName: fxs.52 Uniqueid: 1178801223.9 Event: Newstate Privilege: call,all Channel: Zap/52-1 State: Ringing CallerIDNum: 151 CallerIDName: fxs.51 Uniqueid: 1178801223.9 Event: Dial Privilege: call,all SubEvent: Begin Source: Zap/51-2 Destination: Zap/52-1 CallerIDNum: 151 CallerIDName: fxs.51 SrcUniqueID: 1178801218.8 DestUniqueID: 1178801223.9 Event: Newcallerid Privilege: call,all Channel: Zap/52-1 CallerIDNum: 152 CallerIDName: <Unknown> Uniqueid: 1178801223.9 CID-CallingPres: 0 (Presentation Allowed, Not Screened) Event: Newstate Privilege: call,all Channel: Zap/51-2 State: Ringing CallerIDNum: 151 CallerIDName: fxs.51 Uniqueid: 1178801218.8 Event: Newstate Privilege: call,all Channel: Zap/52-1 State: Up CallerIDNum: 152 CallerIDName: <unknown> Uniqueid: 1178801223.9 Event: Newstate Privilege: call,all Channel: Zap/51-2 State: Up CallerIDNum: 151 CallerIDName: fxs.51 Uniqueid: 1178801218.8 Event: Link Privilege: call,all Channel1: Zap/51-2 Channel2: Zap/52-1 Uniqueid1: 1178801218.8 Uniqueid2: 1178801223.9 CallerID1: 151 CallerID2: 152 Event: Unlink Privilege: call,all Channel1: Zap/50-1 Channel2: Zap/51-1 Uniqueid1: 1178801162.7 Uniqueid2: 1178801108.6 CallerID1: 150 CallerID2: 151 Event: Link Privilege: call,all Channel1: Zap/50-1 Channel2: Zap/51-1 Uniqueid1: 1178801162.7 Uniqueid2: 1178801108.6 CallerID1: 150 CallerID2: 151 Event: Unlink Privilege: call,all Channel1: Zap/50-1 Channel2: Zap/51-1 Uniqueid1: 1178801162.7 Uniqueid2: 1178801108.6 CallerID1: 150 CallerID2: 151
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
343
Event: Link Privilege: call,all Channel1: Zap/50-1 Channel2: Zap/51-1 Uniqueid1: 1178801162.7 Uniqueid2: 1178801108.6 CallerID1: 150 CallerID2: 151 Event: Unlink Privilege: call,all Channel1: Zap/50-1 Channel2: Zap/51-1 Uniqueid1: 1178801162.7 Uniqueid2: 1178801108.6 CallerID1: 150 CallerID2: 151 Event: Hangup Privilege: call,all Channel: Zap/51-1 Uniqueid: 1178801108.6 Cause: 16 Cause-txt: Normal Clearing Event: Newexten Privilege: call,all Channel: Zap/50-1 Context: extension Extension: h Priority: 1 Application: Goto AppData: label1 Uniqueid: 1178801162.7 Event: Newexten Privilege: call,all Channel: Zap/50-1 Context: extension Extension: h Priority: 4 Application: Goto AppData: label2 Uniqueid: 1178801162.7 Event: Newexten Privilege: call,all Channel: Zap/50-1 Context: extension Extension: h Priority: 2 Application: NoOp AppData: In Hangup! myvar is and accountcode is billsec is 0 and duration is 0 and end is 2007-05-10 06:48:37. Uniqueid: 1178801162.7 Event: Newexten Privilege: call,all Channel: Zap/50-1 Context: extension Extension: h Priority: 3 Application: Goto AppData: label3 Uniqueid: 1178801162.7 Event: Newexten Privilege: call,all Channel: Zap/50-1 Context: extension Extension: h Priority: 5 Application: NoOp AppData: More Hangup message after hopping around" Uniqueid: 1178801162.7 Event: Masquerade Privilege: call,all Clone: Zap/50-1 CloneState: Up Original: Zap/51-2 OriginalState: Up Event: Rename Privilege: call,all Oldname: Zap/50-1 Newname: Zap/50-1<MASQ> Uniqueid: 1178801162.7 Event: Rename Privilege: call,all Oldname: Zap/51-2
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
344
Newname: Zap/50-1 Uniqueid: 1178801218.8 Event: Rename Privilege: call,all Oldname: Zap/50-1<MASQ> Newname: Zap/51-2<ZOMBIE> Uniqueid: 1178801162.7 Event: Hangup Privilege: call,all Channel: Zap/51-2<ZOMBIE> Uniqueid: 1178801162.7 Cause: 0 Cause-txt: Unknown Event: Unlink Privilege: call,all Channel1: Zap/50-1 Channel2: Zap/52-1 Uniqueid1: 1178801218.8 Uniqueid2: 1178801223.9 CallerID1: 150 CallerID2: 152 Event: Hangup Privilege: call,all Channel: Zap/52-1 Uniqueid: 1178801223.9 Cause: 16 Cause-txt: Normal Clearing Event: Dial Privilege: call,all SubEvent: End Channel: Zap/50-1 DialStatus: ANSWER Event: Newexten Privilege: call,all Channel: Zap/50-1 Context: extension Extension: h Priority: 1 Application: Goto AppData: label1 Uniqueid: 1178801218.8 Event: Newexten Privilege: call,all Channel: Zap/50-1 Context: extension Extension: h Priority: 4 Application: Goto AppData: label2 Uniqueid: 1178801218.8 Event: Newexten Privilege: call,all Channel: Zap/50-1 Context: extension Extension: h Priority: 2 Application: NoOp AppData: In Hangup! myvar is and accountcode is billsec is 90 and duration is 94 and end is 2007-05-10 06:48:37. Uniqueid: 1178801218.8 Event: Newexten Privilege: call,all Channel: Zap/50-1 Context: extension Extension: h Priority: 3 Application: Goto AppData: label3 Uniqueid: 1178801218.8 Event: Newexten Privilege: call,all Channel: Zap/50-1 Context: extension Extension: h Priority: 5 Application: NoOp AppData: More Hangup message after hopping around" Uniqueid: 1178801218.8 Event: Hangup Privilege: call,all Channel: Zap/50-1 Uniqueid: 1178801218.8
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
345
And, humorously enough, the above 80 manager events, or 42 CEL events, correspond to the following two CDR records (at the moment!):
""fxs.52" 152","152","h","extension","Zap/52-1","Zap/51-1","NoOp","More Hangup message after hopping around"","2007-05-09 17:35:56","2007-05-09 17:36:20","2007-05-09 17:36:36","40","16","ANSWERED","DOCUMENTATION","","1178753756.0","" ""fxs.50" 150","150","152","extension","Zap/50-1","Zap/51-1","NoOp","More Hangup message after hopping around"","2007-05-09 17:37:59","2007-05-09 17:38:06","2007-05-09 17:39:11","72","65","ANSWERED","DOCUMENTATION","","1178753871.3",""
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
346
Table of CEL Event Fields Table 11.2: List of CEL Event Fields Field eventtype eventtime cid_name Description The name of the event; see the above list. The time the event happened CID name field
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
347
cid_num cid_ani cid_rdnis cid_dnid exten context channame appname appdata amaflags accountcode peeraccount uniqueid linkedid userfield peer
CID number field CID ANI field CID RDNIS field CID DNID field The extension in the dialplan The context in the dialplan The name assigned to the channel in which the event took place The name of the current application The arguments that will be handed to that application The AMA flags associated with the event; user assignable. A user assigned datum (string) A user assigned datum (string) on the peer. Each Channel instance gets a unique ID associated with it. the per-call id, spans several events, possibly. A user assigned datum (string) For bridge or other 2-channel events, this would be the other channel name User defined event name Extra information associated with the event.
userdeftype extra
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
348
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
349
CEL Function
THIS IS NO LONGER TRUE REWRITE *****
The CEL function parallels the CDR function, for fetching values from the channel or event. It has some notable notable differences, though! For instance, CEL data is not stored on the channel. Well, not much of it, anyway! You can use the CEL function to set the amaflags, accountcode, and userfield, which are stored on the channel. Channel variables are not available for reading from the CEL function, nor can any variable name other than what's in the list, be set. CDRs have a structure attached to the channel, where the CDR function could access the values stored there, or set the values there. CDRs could store their own variable lists, but CEL has no such storage. There is no reason to store any event information, as they are immediately output to the various backends at the time they are generated. See the description for the CEL function from the CLI: core show function CEL Here is a list of all the available channel field names:
cidname userfield cidnum amaflags cidani cidrdnis ciddnid appdata exten accountcode context uniqueid channame appname peer eventtime eventtype
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
350
CELGenUserEvent Application
This application allows the dialplan to insert custom events into the event stream. For more information, in the CLI, type: core show application CELGenUserEvent Its arguments take this format:
CELGenUserEvent(eventname)
Please note that there is no restrictions on the name supplied. If it happens to match a standard CEL event name, it will look like that event was generated. This could be a blessing or a curse!
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
351
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
352
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
353
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
354
Compile, or recompile, asterisk so that it will now add support for cel_odbc.
make clean && ./configure --with-odbc && make update && make && make install
Setup odbc configuration files. These are working examples from my system. You will need to modify for your setup. You are not required to store usernames or passwords here. /etc/odbcinst.ini
[FreeTDS] Description = FreeTDS ODBC driver for MSSQL Driver = /usr/lib/libtdsodbc.so Setup = /usr/lib/libtdsS.so FileUsage = 1
/etc/odbc.ini
[MSSQL-asterisk] description = Asterisk ODBC for MSSQL driver = FreeTDS server = 192.168.1.25 port = 1433 database = voipdb tds_version = 7.0 language = us_english
Only install one database connector. Do not confuse asterisk by using both ODBC (cel_odbc) and FreeTDS (cel_tds). This command will erase the contents of cel_tds.conf
[ -f /etc/asterisk/cel_tds.conf ] > /etc/asterisk/cel_tds.conf
unixODBC requires the freeTDS package, but asterisk does not call freeTDS directly.
Now set up cel_odbc configuration files. These are working samples from my system. You will need to modify for your setup. Define your usernames and passwords here, secure file as well. /etc/asterisk/cel_odbc.conf
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
355
Start asterisk in verbose mode, you should see that asterisk logs a connection to the database and will now record every desired channel event at the moment it occurs.
Compile, or recompile, asterisk so that it will now add support for cel_tds.
make clean && ./configure --with-tds && make update && make && make install
Only install one database connector. Do not confuse asterisk by using both ODBC (cel_odbc) and FreeTDS (cel_tds). This command will erase the contents of cel_odbc.conf
[ -f /etc/asterisk/cel_odbc.conf ] > /etc/asterisk/cel_odbc.conf
Setup cel_tds configuration files. These are working samples from my system. You will need to modify for your setup. Define your usernames and passwords here, secure file as well. /etc/asterisk/cel_tds.conf
[global] hostname=192.168.1.25 port=1433 dbname=voipdb user=voipdbuser password=voipdpass charset=BIG5
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
356
CREATE TABLE cel ( [eventtype] [varchar] (30) NULL , [eventtime] [datetime] NULL , [cidname] [varchar] (80) NULL , [cidnum] [varchar] (80) NULL , [cidani] [varchar] (80) NULL , [cidrdnis] [varchar] (80) NULL , [ciddnid] [varchar] (80) NULL , [exten] [varchar] (80) NULL , [context] [varchar] (80) NULL , [channame] [varchar] (80) NULL , [appname] [varchar] (80) NULL , [appdata] [varchar] (80) NULL , [amaflags] [varchar] (16) NULL , [accountcode] [varchar] (20) NULL , [uniqueid] [varchar] (32) NULL , [userfield] [varchar] (255) NULL , [peer] [varchar] (80) NULL ) ;
Start asterisk in verbose mode, you should see that asterisk logs a connection to the database and will now record every call to the database when it's complete.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
357
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
358
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
359
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
360
Configuration of the Radiusclient library By default all the configuration files of the radiusclient library will be in /usr/local/etc/radiusclient-ng directory. File "radiusclient.conf" Open the file and find lines containing the following:
authserver localhost
This is the hostname or IP address of the RADIUS server used for authentication. You will have to change this unless the server is running on the same host as your Asterisk PBX.
acctserver localhost
This is the hostname or IP address of the RADIUS server used for accounting. You will have to change this unless the server is running on the same host as your Asterisk PBX. File "servers" RADIUS protocol uses simple access control mechanism based on shared secrets that allows RADIUS servers to limit access from RADIUS clients. A RADIUS server is configured with a secret string and only RADIUS clients that have the same secret will be accepted. You need to configure a shared secret for each server you have configured in radiusclient.conf file in the previous step. The shared secrets are stored in /usr/local/etc/radiusclient-ng/servers file. Each line contains hostname of a RADIUS server and shared secret used in communication with that server. The two values are separated by white spaces. Configure shared secrets for every RADIUS server you are going to use.
File "dictionary"
Asterisk uses some attributes that are not included in the dictionary of radiusclient library, therefore it is necessary to add them. A file called dictionary.digium (kept in the contrib dir) was created to list all new attributes used by Asterisk. Add to the end of the main dictionary file /usr/local/etc/radiusclient-ng/dictionary the line:
$INCLUDE /path/to/dictionary.digium
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
361
All the configuration files of FreeRADIUS server will be in /usr/local/etc/raddb directory. Configuration of the FreeRADIUS Server There are several files that have to be modified to configure the RADIUS server. These are presented next. File "clients.conf" File /usr/local/etc/raddb/clients.conf contains description of RADIUS clients that are allowed to use the server. For each of the clients you need to specify its hostname or IP address and also a shared secret. The shared secret must be the same string you configured in radiusclient library. Example:
client myhost { secret = mysecret shortname = foo }
This fragment allows access from RADIUS clients on "myhost" if they use "mysecret" as the shared secret. The file already contains an entry for localhost (127.0.0.1), so if you are running the RADIUS server on the same host as your Asterisk server, then modify the existing entry instead, replacing the default password. File "dictionary"
The following procedure brings the dictionary.digium file to previous versions of FreeRADIUS. File /usr/local/etc/raddb/dictionary contains the dictionary of FreeRADIUS server. You have to add the same dictionary file (dictionary.digium), which you added to the dictionary of radiusclient-ng library. You can include it into the main file, adding the following line at the end of file /usr/local/etc/raddb/dictionary:
$INCLUDE /path/to/dictionary.digium
That will include the same new attribute definitions that are used in radiusclient-ng library so the client and server will understand each other.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
362
"Asterisk-Cidrdnis", "Asterisk-Ciddnid", "Asterisk-Exten", "Asterisk-Context", The destination context "Asterisk-Channame", The channel name "Asterisk-Appname", Last application run on the channel "Asterisk-App-Data", Argument to the last channel "Asterisk-Event-Time", "Asterisk-Event-Type", "Asterisk-AMA-Flags", DOCUMENTATION, BILL, IGNORE etc, specified on a per channel basis like accountcode. "Asterisk-Unique-ID", Unique call identifier "Asterisk-User-Field" User field set via SetCELUserField "Asterisk-Peer" Name of the Peer for 2-channel events (like bridge)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
363
Channel Variables
What's a channel variable? Read on to find out why they're important and how they'll improve your quality of life. There are two levels of parameter evaluation done in the Asterisk dial plan in extensions.conf.
1. The first, and most frequently used, is the substitution of variable references with their values. 2. Then there are the evaluations of expressions done in $[ .. ]. This will be discussed below.
Asterisk has user-defined variables and standard variables set by various modules in Asterisk. These standard variables are listed at the end of this document.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
364
Parameter Quoting
exten => s,5,BackGround,blabla
The parameter (blabla) can be quoted ("blabla"). In this case, a comma does not terminate the field. However, the double quotes will be passed down to the Background command, in this example. Also, characters special to variable substitution, expression evaluation, etc (see below), can be quoted. For example, to literally use a $ on the string "$1231", quote it with a preceding . Special characters that must be quoted to be used, are [ ] $ " \. (to write \itself, use a backslash. ). These Double quotes and escapes are evaluated at the level of the asterisk config file parser. Double quotes can also be used inside expressions, as discussed below.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
365
About Variables
Parameter strings can include variables. Variable names are arbitrary strings. They are stored in the respective channel structure. To set a variable to a particular value, do:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
366
Variable Inheritance
Variable names which are prefixed by "" will be inherited to channels that are created in the process of servicing the original channel in which the variable was set. When the inheritance takes place, the prefix will be removed in the channel inheriting the variable. If the name is prefixed by "" in the channel, then the variable is inherited and the "_" will remain intact in the new channel. In the dialplan, all references to these variables refer to the same variable, regardless of having a prefix or not. Note that setting any version of the variable removes any other version of the variable, regardless of prefix.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
367
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
368
${variable_name[:offset[:length]]}
If you want to select the first N characters from the string assigned to a variable, simply append a colon and the number of characters to skip from the beginning of the string to the variable name.
; Remove the first character of extension, save in "number" variable exten => _9X.,1,Set(number=${EXTEN:1})
Assuming we've dialed 918005551234, the value saved to the 'number' variable would be 18005551234. This is useful in situations when we require users to dial a number to access an outside line, but do not wish to pass the first digit. If you use a negative offset number, Asterisk starts counting from the end of the string and then selects everything after the new position. The following example will save the numbers 1234 to the 'number' variable, still assuming we've dialed 918005551234.
; Remove everything before the last four digits of the dialed string exten => _9X.,1,Set(number=${EXTEN:-4})
We can also limit the number of characters from our offset position that we wish to use. This is done by appending a second colon and length value to the variable name. The following example will save the numbers 555 to the 'number' variable.
; Only save the middle numbers 555 from the string 918005551234 exten => _9X.,1,Set(number=${EXTEN:5:3})
The length value can also be used in conjunction with a negative offset. This may be useful if the length of the string is unknown, but the trailing digits are. The following example will save the numbers 555 to the 'number' variable, even if the string starts with more characters than expected (unlike the previous example).
; Save the numbers 555 to the 'number' variable exten => _9X.,1,Set(number=${EXTEN:-7:3})
If a negative length value is entered, Asterisk will remove that many characters from the end of the string.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
369
Expressions
Everything contained inside a bracket pair prefixed by a $ (like $[this]) is considered as an expression and it is evaluated. Evaluation works similar to (but is done on a later stage than) variable substitution: the expression (including the square brackets) is replaced by the result of the expression evaluation. For example, after the sequence:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
370
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
371
Operators
Operators are listed below in order of increasing precedence. Operators with equal precedence are grouped within { } symbols.
expr1 | expr2 Return the evaluation of expr1 if it is neither an empty string nor zero; otherwise, returns the evaluation of expr2. expr1 & expr2 Return the evaluation of expr1 if neither expression evaluates to an empty string or zero; otherwise, returns zero. expr1 {=, >, >=, <, <=, !=} expr2 Return the results of floating point comparison if both arguments are numbers; otherwise, returns the results of string comparison using the locale-specific collation sequence. The result of each comparison is 1 if the specified relation is true, or 0 if the relation is false. expr1 {+, -} expr2 Return the results of addition or subtraction of floating point-valued arguments. expr1 {, /, %} expr2* Return the results of multiplication, floating point division, or remainder of arguments. - expr1 Return the result of subtracting expr1 from 0. This, the unary minus operator, is right associative, and has the same precedence as the ! operator. ! expr1 Return the result of a logical complement of expr1. In other words, if expr1 is null, 0, an empty string, or the string "0", return a 1. Otherwise, return a 0. It has the same precedence as the unary minus operator, and is also right associative. expr1 : expr2 The `:' operator matches expr1 against expr2, which must be a regular expression. The regular expression is anchored to the beginning of the string with an implicit `'.
If the match succeeds and the pattern contains at least one regular expression subexpression `', the string corresponing to `\1' is returned; otherwise the matching operator returns the number of characters matched. If the match fails and the pattern contains a regular expression subexpression the null string is returned; otherwise 0. Normally, the double quotes wrapping a string are left as part of the string. This is disastrous to the : operator. Therefore, before the regex match is made, beginning and ending double quote characters are stripped from both the pattern and the string.
expr1 =~ expr2 Exactly the same as the ':' operator, except that the match is not anchored to the beginning of the string. Pardon any similarity to seemingly similar operators in other programming languages! The ":" and "=~" operators share the same precedence. expr1 ? expr2 :: expr3 Traditional Conditional operator. If expr1 is a number that evaluates to 0 (false), expr3 is result of the this expression evaluation. Otherwise, expr2 is the result. If expr1 is a string, and evaluates to an empty string, or the two characters (""), then expr3 is the result. Otherwise, expr2 is the result. In Asterisk, all 3 exprs will be "evaluated"; if expr1 is "true", expr2 will be the result of the "evaluation" of this expression. expr3 will be the result otherwise. This operator has the lowest precedence. expr1 ~~ expr2 Concatenation operator. The two exprs are evaluated and turned into strings, stripped of surrounding double quotes, and are turned into a single string with no invtervening spaces. This operator is new to trunk after 1.6.0; it is not needed in existing extensions.conf code. Because of the way asterisk evaluates [ ] constructs (recursively, bottom- up), no is ever present when the contents of a [] is evaluated. Thus, tokens are usually already merged at evaluation time. But, in AEL, various exprs are evaluated raw, and [] are gathered and treated as tokens. And in AEL, no two tokens can sit side by side without an intervening operator. So, in AEL, concatenation must be explicitly specified in expressions. This new operator will play well into future plans, where expressions ( constructs) are merged into a single grammar.
Parentheses are used for grouping in the usual manner. Operator precedence is applied as one would expect in any of the C or C derived languages.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
372
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
373
Functions
In 1.6 and above, we upgraded the $[] expressions to handle floating point numbers. Because of this, folks counting on integer behavior would be disrupted. To make the same results possible, some rounding and integer truncation functions have been added to the core of the Expr2 parser. Indeed, dialplan functions can be called from $[..] expressions without the ${...} operators. The only trouble might be in the fact that the arguments to these functions must be specified with a comma. If you try to call the MATH function, for example, and try to say 3 + MATH(7*8), the expression parser will evaluate 7*8 for you into 56, and the MATH function will most likely complain that its input doesn't make any sense. We also provide access to most of the floating point functions in the C library. (but not all of them). While we don't expect someone to want to do Fourier analysis in the dialplan, we don't want to preclude it, either. Here is a list of the 'builtin' functions in Expr2. All other dialplan functions are available by simply calling them (read-only). In other words, you don't need to surround function calls in $[...] expressions with ${...}. Don't jump to conclusions, though! - you still need to wrap variable names in curly braces!
COS(x) x is in radians. Results vary from -1 to 1. SIN(x) x is in radians. Results vary from -1 to 1. TAN(x) x is in radians. ACOS(x) x should be a value between -1 and 1. ASIN(x) x should be a value between -1 and 1. ATAN(x) returns the arc tangent in radians; between -PI/2 and PI/2. ATAN2(x,y) returns a result resembling y/x, except that the signs of both args are used to determine the quadrant of the result. Its result is in radians, between -PI and PI. POW(x,y) returns the value of x raised to the power of y. SQRT(x) returns the square root of x. FLOOR(x) rounds x down to the nearest integer. CEIL(x) rounds x up to the nearest integer. ROUND(x) rounds x to the nearest integer, but round halfway cases away from zero. RINT(x) rounds x to the nearest integer, rounding halfway cases to the nearest even integer. TRUNC(x) rounds x to the nearest integer not larger in absolute value. REMAINDER(x,y) computes the remainder of dividing x by y. The return value is x - n*y, where n is the value x/y, rounded to the nearest integer. If this quotient is 1/2, it is rounded to the nearest even number. EXP(x) returns e to the x power. EXP2(x) returns 2 to the x power. LOG(x) returns the natural logarithm of x. LOG2(x) returns the base 2 log of x. LOG10(x) returns the base 10 log of x.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
374
Expressions Examples
*"One Thousand Five Hundred" =~ "(T[Expressions Examples^ ])" returns: Thousand
"One Thousand Five Hundred" =~ "T[Expressions Examples^ ]" returns: 8 "One Thousand Five Hundred" : "T[Expressions Examples^ ]" returns: 0 "8015551212" : "(...)" returns: 801 "3075551212":"...(...)" returns: 555 ! "One Thousand Five Hundred" =~ "T[Expressions Examples^ ]" returns: 0 (because it applies to the string, which is non-null, which it turns to "0", and then looks for the pattern in the "0", and doesn't find it) !( "One Thousand Five Hundred" : "T[Expressions Examples^ ]+" ) returns: 1 (because the string doesn't start with a word starting with T, so the match evals to 0, and the ! operator inverts it to 1 ) 2+8/2 returns: 6 (because of operator precedence; the division is done first, then the addition) 2+8/2 returns: 6 Spaces aren't necessary (2+8)/2 returns: 5 of course (3+8)/2 returns: 5.5 TRUNC((3+8)/2) returns: 5 FLOOR(2.5) returns: 2 FLOOR(-2.5) returns: -3 CEIL(2.5) returns: 3 CEIL(-2.5) returns: -2 ROUND(2.5) returns: 3 ROUND(3.5) returns: 4 ROUND(-2.5) returns: -3 RINT(2.5) returns: 2
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
375
RINT(3.5) returns: 4 RINT(-2.5) returns: -2 RINT(-3.5) returns: -4 TRUNC(2.5) returns: 2 TRUNC(3.5) returns: 3 TRUNC(-3.5) returns: -3
Of course, all of the above examples use constants, but would work the same if any of the numeric or string constants were replaced with a variable reference ${CALLERID(num)}, for instance.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
376
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
377
Conditionals
There is one conditional application - the conditional goto :
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
378
exten => s,6,GotoIf($[ "${CALLERID(num)}" = "3071234567" & & "${CALLERID(name)}" : "Privacy Manager" ]?callerid-liar,s,1:s,7)
You may see an error in /var/log/asterisk/messages like this:
Jul 15 21:27:49 WARNING[1251240752]: ast_yyerror(): syntax error: parse error, unexpected TOK_AND, expecting TOK_M INUS or TOK_LP or TOKEN; Input: "3072312154" = "3071234567" & & "Steves Extension" : "Privacy Manager" ^
The log line tells you that a syntax error was encountered. It now also tells you (in grand standard bison format) that it hit an "AND" (&) token unexpectedly, and that was hoping for for a MINUS , LP (left parenthesis), or a plain token (a string or number). The next line shows the evaluated expression, and the line after that, the position of the parser in the expression when it became confused, marked with the "" character.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
379
NULL Strings
Testing to see if a string is null can be done in one of two different ways:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
380
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
381
1. Tokens separated by space(s). Previously, tokens were separated by spaces. Thus, ' 1 + 1 ' would evaluate to the value '2', but '1+1' would evaluate to the string '1+1'. If this behavior was depended on, then the expression evaluation will break. '1+1' will now evaluate to '2', and something is not going to work right. To keep such strings from being evaluated, simply wrap them in double quotes: ' "1+1" ' 2. The colon operator. In versions previous to double quoting, the colon operator takes the right hand string, and using it as a regex pattern, looks for it in the left hand string. It is given an implicit perator at the beginning, meaning the pattern will match only at the beginning of the left hand string. If the pattern or the matching string had double quotes around them, these could get in the way of the pattern match. Now, the wrapping double quotes are stripped from both the pattern and the left hand string before applying the pattern. This was done because it recognized that the new way of scanning the expression doesn't use spaces to separate tokens, and the average regex expression is full of operators that the scanner will recognize as expression operators. Thus, unless the pattern is wrapped in double quotes, there will be trouble. For instance, ${VAR1} : (WhoWhat)+ may have have worked before, but unless you wrap the pattern in double quotes now, look out for trouble! This is better: "${VAR1}" : "(WhoWhat*)+" and should work as previous.* 3. Variables and Double Quotes Before these changes, if a variable's value contained one or more double quotes, it was no reason for concern. It is now ! 4. LE, GE, NE operators removed. The code supported these operators, but they were not documented. The symbolic operators, =, =, and != should be used instead. 5. Added the unary '-' operator. So you can 3+ -4 and get -1. 6. Added the unary '!' operator, which is a logical complement. Basically, if the string or number is null, empty, or '0', a '1' is returned. Otherwise a '0' is returned. 7. Added the '=~' operator, just in case someone is just looking for match anywhere in the string. The only diff with the ':' is that match doesn't have to be anchored to the beginning of the string. 8. Added the conditional operator 'expr1 ? true_expr :: false_expr' First, all 3 exprs are evaluated, and if expr1 is false, the 'false_expr' is returned as the result. See above for details. 9. Unary operators '-' and '!' were made right associative.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
382
make testexpr2
in the top level asterisk source directory. This will build a small executable, that is able to take the first command line argument, and run it thru the expression parser. No variable substitutions will be performed. It might be safest to wrap the expression in single quotes...
testexpr2 '2*2+2/2'
is an example. And, in the utils directory, you can say:
make check_expr
and a small program will be built, that will check the file mentioned in the first command line argument, for any expressions that might be have problems when you move to flex-2.5.31. It was originally designed to help spot possible incompatibilities when moving from the pre-2.5.31 world to the upgraded version of the lexer. But one more capability has been added to check_expr, that might make it more generally useful. It now does a simple minded evaluation of all variables, and then passes the $[] exprs to the parser. If there are any parse errors, they will be reported in the log file. You can use check_expr to do a quick sanity check of the expressions in your extensions.conf file, to see if they pass a crude syntax check. The "simple-minded" variable substitution replaces ${varname} variable references with '555'. You can override the 555 for variable values, by entering in var=val arguments after the filename on the command line. So...
check_expr is a very simplistic algorithm, and it is far from being guaranteed to work in all cases, but it is hoped that it will be useful.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
383
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
384
${AGISTATUS} * agi() ${AQMSTATUS} * addqueuemember() ${AVAILSTATUS} * chanisavail() ${CHECKGROUPSTATUS} * checkgroup() ${CHECKMD5STATUS} * checkmd5() ${CPLAYBACKSTATUS} * controlplayback() ${DIALSTATUS} * dial() ${DBGETSTATUS} * dbget() ${ENUMSTATUS} * enumlookup() ${HASVMSTATUS} * hasnewvoicemail() ${LOOKUPBLSTATUS} * lookupblacklist() ${OSPAUTHSTATUS} * ospauth() ${OSPLOOKUPSTATUS} * osplookup() ${OSPNEXTSTATUS} * ospnext() ${OSPFINISHSTATUS} * ospfinish() ${PARKEDAT} * parkandannounce() ${PLAYBACKSTATUS} * playback() ${PQMSTATUS} * pausequeuemember() ${PRIVACYMGRSTATUS} * privacymanager() ${QUEUESTATUS} * queue() ${RQMSTATUS} * removequeuemember() ${SENDIMAGESTATUS} * sendimage() ${SENDTEXTSTATUS} * sendtext() ${SENDURLSTATUS} * sendurl() ${SYSTEMSTATUS} * system() ${TRANSFERSTATUS} * transfer() ${TXTCIDNAMESTATUS} * txtcidname() ${UPQMSTATUS} * unpausequeuemember() ${VMSTATUS} * voicmail() ${VMBOXEXISTSSTATUS} * vmboxexists() ${WAITSTATUS} * waitforsilence()
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
385
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
386
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
387
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
388
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
389
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
390
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
391
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
392
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
393
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
394
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
395
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
396
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
397
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
398
${REDIRECTING_CALLER_SEND_MACRO} Macro to call before sending a redirecting update to the caller ${REDIRECTING_CALLER_SEND_MACRO_ARGS} Arguments to pass to ${REDIRECTING_CALLER_SEND_MACRO} ${CONNECTED_LINE_CALLEE_SEND_MACRO} Macro to call before sending a connected line update to the callee ${CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS} Arguments to pass to ${CONNECTED_LINE_CALLEE_SEND_MACRO}
${CONNECTED_LINE_CALLER_SEND_MACRO} Macro to call before sending a connected line update to the caller ${CONNECTED_LINE_CALLER_SEND_MACRO_ARGS} Arguments to pass to ${CONNECTED_LINE_CALLER_SEND_MACRO}
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
399
Case Sensitivity
Case sensitivity of channel variables in Asterisk is dependent on the version of Asterisk in use.
Asterisk 1.0.X Asterisk 1.2.X Asterisk 1.4.X Asterisk 1.6.0.X Asterisk 1.6.1.X Asterisk 1.6.2.X Asterisk 1.8.X Asterisk 10.X Asterisk 11.X
These versions of Asterisk follow these three rules:
Variables evaluated in the dialplan are case-insensitive Variables evaluated within Asterisk's internals are case-sensitive Built-in variables are case-sensitive
This is best illustrated through the following examples
Since the DEST variable is set and evaluated in the dialplan, its evaluation is case-insensitive. Thus the following would be equivalent:
exten => 1000,1,Set(DEST=${DB(egg/salad)}) same => n,Dial(${dest},15)
As would this:
exten => 1000,1,Set(DeSt=${DB(egg/salad)}) same => n,Dial(${dEsT},15)
Since the variable EXTEN is a built-in variable, the following would not be equivalent:
exten => _X.,1,Dial(SIP/${exten})
The lowercase exten variable would evaluate to an empty string since no previous value was set for exten.
SIP_CODEC is set in the dialplan, but it gets evaluated inside of Asterisk, so the evaluation is case-sensitive. Thus the following dialplan would not be equivalent:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
400
This can lead to some rather confusing situations. Consider that a user wrote the following dialplan. He intended to set the variable SIP_CODEC but instead made a typo:
exten => 1000,Set(SIP_CODEc=g729) same => n,Dial(SIP/1000,15)
As has already been discussed, this is not equivalent to using SIP_CODEC. The user looks over his dialplan and does not notice the typo. As a way of debugging, he decides to place a NoOp in the dialplan:
exten => 1000,Set(SIP_CODEc=g729) same => n,NoOp(${SIP_CODEC}) same => n,Dial(SIP/1000,15)
When the user checks the verbose logs, he sees that the second priority has evaluated SIP_CODEC to be "g729". This is because the evaluation in the dialplan was done case-insensitively.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
401
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
402
Introduction to DUNDi
http://www.dundi.com Mark Spencer, Digium, Inc. DUNDi is essentially a trusted, peer-to-peer system for being able to call any phone number from the Internet. DUNDi works by creating a network of nodes called the "DUNDi E.164 Trust Group" which are bound by a common peering agreement known as the General Peering Agreement or GPA. The GPA legally binds the members of the Trust Group to provide good-faith accurate information to the other nodes on the network, and provides standards by which the community can insure the integrity of the information on the nodes themselves. Unlike ENUM or similar systems, DUNDi is explicitly designed to preclude any necessity for a single centralized system which could be a source of fees, regulation, etc. Much less dramatically, DUNDi can also be used within a private enterprise to share a dialplan efficiently between multiple nodes, without incurring a risk of a single point of failure. In this way, administrators can locally add extensions which become immediately available to the other nodes in the system. For more information visit http://www.dundi.com
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
403
1,1,Set(ID=${DUNDIQUERY(1,dundi_test,b)}) 1,n,Set(NUM=${DUNDIRESULT(${ID},getnum)}) 1,n,NoOp(There are ${NUM} results) 1,n,Set(X=1) 1,n,While($[${X} <= ${NUM}]) 1,n,NoOp(Result ${X} is ${DUNDIRESULT(${ID},${X})}) 1,n,Set(X=$[${X} + 1]) 1,n,EndWhile
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
404
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
405
believe to be honoring the terms of the GPA. Participants may not insert, remove, amend, or otherwise modify any of the terms of the GPA. 2. ACCEPTABLE USE POLICY. The DUNDi protocol contains information that reflect a Subscriber's or Egress Gateway's decisions to receive calls. In addition to the terms and conditions set forth in this GPA, the Participants agree to honor the intent of restrictions encoded in the DUNDi protocol. To that end, Participants agree to the following: (a) A Participant may not utilize or permit the utilization of Routes for which the Subscriber or Egress Gateway provider has indicated that they do not wish to receive "Unsolicited Calls" for the purpose of making an unsolicited phone call on behalf of any party or organization. (b) A Participant may not utilize or permit the utilization of Routes which have indicated that they do not wish to receive "Unsolicited Commercial Calls" for the purpose of making an unsolicited phone call on behalf of a commercial organization. (c) A Participant may never utilize or permit the utilization of any DUNDi route for the purpose of making harassing phone calls. (d) A Party may not utilize or permit the utilization of DUNDi provided Routes for any systematic or random calling of numbers (e.g., for the purpose of locating facsimile, modem services, or systematic telemarketing). (e) Initial control signaling for all communication sessions that utilize Routes obtained from the Peering System must be sent from a member of the Peering System to the Service or Egress Gateway identified in the selected Route. For example, 'SIP INVITES' and IAX2 "NEW" commands must be sent from the requesting DUNDi node to the terminating Service. (f) A Participant may not disclose any specific Route, Service or Participant contact information obtained from the Peering System to any party outside of the Peering System except as a by-product of facilitating communication in accordance with section 2e (e.g., phone books or other databases may not be published, but the Internet addresses of the Egress Gateway or Service does not need to be obfuscated.) (g) The DUNDi Protocol requires that each Participant include valid contact information about itself (including information about nodes connected to each Participant). Participants may use or disclose the contact information only to ensure enforcement of legal furtherance of this Agreement. 3. ROUTES. The Participants shall only propagate valid Routes, as defined herein, through the Peering System, regardless of the original source. The Participants may only provide Routes as set forth below, and then only if such Participant has no good faith reason to believe such Route to be invalid or unauthorized. (a) A Participant may provide Routes if each Route has as its original source another member of the Peering System who has duly executed the GPA and such Routes are provided in accordance with this Agreement; provided that the Routes are not modified (e.g., with regards to existence, destination, technology or Weight); or (b) A Participant may provide Routes for Services with any Weight for which it is the Subscriber; or (c) A Participant may provide Routes for those Services whose Subscriber has authorized the Participant to do so, provided that the Participant is able to confirm that the Authorizing Individual is the Subscriber through: i. a written statement of ownership from the Authorizing Individual, which the Participant believes in good faith to be accurate (e.g., a phone bill with the name of the Authorizing Individual and the number in question); or ii. the Participant's own direct personal knowledge that the Authorizing Individual is the Subscriber. (d) A Participant may provide Routes for Services, with Weight in accordance with the Current DUNDi Specification, if it can in good faith provide an Egress Gateway to that Service on the traditional telephone network without cost to the calling party. 4. REVOCATION. A Participant must provide a free, easily accessible mechanism by which a Subscriber may revoke permission to act as a Route Authority for his Service. A Participant must stop acting as a Route Authority for that Service within 7 days after: (a) receipt of a revocation request; (b) receiving other notice that the Service is no longer valid; or (c) determination that the Subscriber's information is no longer accurate (including that the Subscriber is no longer the service owner or the service owner's authorized delegate). 5. SERVICE FEES. A Participant may charge a fee to act as a Route Authority for a Service, with any Weight, provided that no Participant may charge a fee to propagate the Route received through the Peering System. 6. TOLL SERVICES. No Participant may provide Routes for any Services that require payment from the calling party or their customer for communication with the Service. Nothing in this section shall prohibit a Participant from providing routes for Services where the calling party may later enter into a financial transaction with the called party (e.g., a Participant may provide Routes for calling cards services). 7. QUALITY. A Participant may not intentionally impair communication using a Route provided to the Peering System (e.g. by adding delay, advertisements, reduced quality). If for any reason a Participant is unable to deliver a call via a Route provided to the Peering System, that Participant shall return out-of-band Network Congestion notification (e.g. "503 Service Unavailable" with SIP protocol or "CONGESTION" with IAX protocol). 8. PROTOCOL COMPLIANCE. Participants agree to Propagate Routes in strict compliance with current DUNDi protocol specifications. 9. ADMINISTRATIVE FEES. A Participant may charge (but is not required to charge) another Participant a reasonable fee to cover administrative expenses incurred in the execution of this Agreement. A Participant may not charge any fee to continue the relationship or to provide Routes to another Participant in the Peering System. 10. CALLER IDENTIFICATION. A Participant will make a good faith effort to ensure the accuracy and appropriate nature of any caller identification that it transmits via any Route obtained from the Peering System. Caller identification shall at least be provided as a valid E.164 number. 11. COMPLIANCE WITH LAWS. The Participants are solely responsible for determining to what extent, if any, the obligations set forth in this GPA conflict with any laws or regulations their region. A Participant may not provide any service or otherwise use DUNDi under this GPA if doing so is prohibited by law or regulation, or if any law or regulation imposes requirements on the
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
406
Participant that are inconsistent with the terms of this GPA or the Acceptable Use Policy. 12. WARRANTY. EACH PARTICIPANT WARRANTS TO THE OTHER PARTICIPANTS THAT IT MADE, AND WILL CONTINUE TO MAKE, A GOOD FAITH EFFORT TO AUTHENTICATE OTHERS IN THE PEERING SYSTEM AND TO PROVIDE ACCURATE INFORMATION IN ACCORDANCE WITH THE TERMS OF THIS GPA. THIS WARRANTY IS MADE BETWEEN THE PARTICIPANTS, AND THE PARTICIPANTS MAY NOT EXTEND THIS WARRANTY TO ANY NON-PARTICIPANT INCLUDING END-USERS. 13. DISCLAIMER OF WARRANTIES. THE PARTICIPANTS UNDERSTAND AND AGREE THAT ANY SERVICE PROVIDED AS A RESULT OF THIS GPA IS "AS IS." EXCEPT FOR THOSE WARRANTIES OTHERWISE EXPRESSLY SET FORTH HEREIN, THE PARTICIPANTS DISCLAIM ANY REPRESENTATIONS OR WARRANTIES OF ANY KIND OR NATURE, EXPRESS OR IMPLIED, AS TO THE CONDITION, VALUE OR QUALITIES OF THE SERVICES PROVIDED HEREUNDER, AND SPECIFICALLY DISCLAIM ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY, SUITABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR AS TO THE CONDITION OR WORKMANSHIP THEREOF, OR THE ABSENCE OF ANY DEFECTS THEREIN, WHETHER LATENT OR PATENT, INCLUDING ANY WARRANTIES ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. EXCEPT AS EXPRESSLY PROVIDED HEREIN, THE PARTICIPANTS EXPRESSLY DISCLAIM ANY REPRESENTATIONS OR WARRANTIES THAT THE PEERING SERVICE WILL BE CONTINUOUS, UNINTERRUPTED OR ERROR-FREE, THAT ANY DATA SHARED OR OTHERWISE MADE AVAILABLE WILL BE ACCURATE OR COMPLETE OR OTHERWISE COMPLETELY SECURE FROM UNAUTHORIZED ACCESS. 14. LIMITATION OF LIABILITIES. NO PARTICIPANT SHALL BE LIABLE TO ANY OTHER PARTICIPANT FOR INCIDENTAL, INDIRECT, CONSEQUENTIAL, SPECIAL, PUNITIVE OR EXEMPLARY DAMAGES OF ANY KIND (INCLUDING LOST REVENUES OR PROFITS, LOSS OF BUSINESS OR LOSS OF DATA) IN ANY WAY RELATED TO THIS GPA, WHETHER IN CONTRACT OR IN TORT, REGARDLESS OF WHETHER SUCH PARTICIPANT WAS ADVISED OF THE POSSIBILITY THEREOF. 15. END-USER AGREEMENTS. The Participants may independently enter into agreements with end-users to provide certain services (e.g., fees to a Subscriber to originate Routes for that Service). To the extent that provision of these services employs the Peering System, the Parties will include in their agreements with their end-users terms and conditions consistent with the terms of this GPA with respect to the exclusion of warranties, limitation of liability and Acceptable Use Policy. In no event may a Participant extend the warranty described in Section 12 in this GPA to any end-users. 16. INDEMNIFICATION. Each Participant agrees to defend, indemnify and hold harmless the other Participant or third-party beneficiaries to this GPA (including their affiliates, successors, assigns, agents and representatives and their respective officers, directors and employees) from and against any and all actions, suits, proceedings, investigations, demands, claims, judgments, liabilities, obligations, liens, losses, damages, expenses (including, without limitation, attorneys' fees) and any other fees arising out of or relating to (i) personal injury or property damage caused by that Participant, its employees, agents, servants, or other representatives; (ii) any act or omission by the Participant, its employees, agents, servants or other representatives, including, but not limited to, unauthorized representations or warranties made by the Participant; or (iii) any breach by the Participant of any of the terms or conditions of this GPA. 17. THIRD PARTY BENEFICIARIES. This GPA is intended to benefit those Participants who have executed the GPA and who are in the Peering System. It is the intent of the Parties to this GPA to give to those Participants who are in the Peering System standing to bring any necessary legal action to enforce the terms of this GPA. 18. TERMINATION. Any Participant may terminate this GPA at any time, with or without cause. A Participant that terminates must immediately cease to Propagate. 19. CHOICE OF LAW. This GPA and the rights and duties of the Parties hereto shall be construed and determined in accordance with the internal laws of the State of New York, United States of America, without regard to its conflict of laws principles and without application of the United Nations Convention on Contracts for the International Sale of Goods. 20. DISPUTE RESOLUTION. Unless otherwise agreed in writing, the exclusive procedure for handling disputes shall be as set forth herein. Notwithstanding such procedures, any Participant may, at any time, seek injunctive relief in addition to the process described below. (a) Prior to mediation or arbitration the disputing Participants shall seek informal resolution of disputes. The process shall be initiated with written notice of one Participant to the other describing the dispute with reasonable particularity followed with a written response within ten (10) days of receipt of notice. Each Participant shall promptly designate an executive with requisite authority to resolve the dispute. The informal procedure shall commence within ten (10) days of the date of response. All reasonable requests for non-privileged information reasonably related to the dispute shall be honored. If the dispute is not resolved within thirty (30) days of commencement of the procedure either Participant may proceed to mediation or arbitration pursuant to the rules set forth in (b) or (c) below. (b) If the dispute has not been resolved pursuant to (a) above or, if the disputing Participants fail to commence informal dispute resolution pursuant to (a) above, either Participant may, in writing and within twenty (20) days of the response date noted in (a) above, ask the other Participant to participate in a one (1) day mediation with an impartial mediator, and the other Participant shall do so. Each Participant will bear its own expenses and an equal share of the fees of the mediator. If the mediation is not successful the Participants may proceed with arbitration pursuant to (c) below. (c) If the dispute has not been resolved pursuant to (a) or (b) above, the dispute shall be promptly referred, no later than one (1) year from the date of original notice and subject to applicable statute of limitations, to binding arbitration in accordance with the UNCITRAL Arbitration Rules in effect on the date of this contract. The appointing authority shall be the International Centre for Dispute Resolution. The case shall be administered by the International Centre for Dispute Resolution under its Procedures for Cases under the UNCITRAL Arbitration Rules. Each Participant shall bear its own expenses and shall share equally in fees of the arbitrator. All arbitrators shall have substantial experience in information technology and/or in the telecommunications business and shall be selected by the disputing participants in accordance with UNCITRAL Arbitration Rules. If any arbitrator, once selected is unable or unwilling to continue for any reason, replacement shall be filled via the process described above and a re-hearing shall be conducted. The disputing Participants will provide each other with all requested documents and records reasonably related to the dispute in a manner that will minimize the expense and inconvenience of both parties. Discovery will not include depositions or interrogatories except as the arbitrators expressly allow upon a showing of need. If disputes arise concerning discovery requests, the arbitrators shall have sole and complete discretion to resolve the disputes. The parties and arbitrator shall be guided in resolving discovery disputes by the Federal Rules of Civil Procedure. The Participants agree that time of the essence principles shall guide the hearing and that the arbitrator shall have the right and authority to issue monetary sanctions in the event of unreasonable delay. The arbitrator shall deliver a written opinion setting forth findings of fact and the rationale for the award within thirty (30) days following conclusion of the hearing. The award of the arbitrator, which may include legal and equitable relief, but which may not include punitive damages, will be final and binding upon the disputing Participants, and judgment may be entered upon it in accordance with applicable law in any court having jurisdiction thereof. In addition to award the arbitrator shall have the discretion to award the prevailing Participant all or part of its attorneys' fees and costs, including fees associated with arbitrator, if the arbitrator determines that the positions taken by the other Participant on material issues of the dispute were without substantial foundation. Any conflict between the UNCITRAL Arbitration Rules and the provisions of this GPA shall be controlled by this GPA. 21. INTEGRATED AGREEMENT. This GPA, constitutes the complete integrated agreement between the parties concerning the subject
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
407
matter hereof. All prior and contemporaneous agreements, understandings, negotiations or representations, whether oral or in writing, relating to the subject matter of this GPA are superseded and canceled in their entirety. 22. WAIVER. No waiver of any of the provisions of this GPA shall be deemed or shall constitute a waiver of any other provision of this GPA, whether or not similar, nor shall such waiver constitute a continuing waiver unless otherwise expressly so provided in writing. The failure of either party to enforce at any time any of the provisions of this GPA, or the failure to require at any time performance by either party of any of the provisions of this GPA, shall in no way be construed to be a present or future waiver of such provisions, nor in any way affect the ability of a Participant to enforce each and every such provision thereafter. 23. INDEPENDENT CONTRACTORS. Nothing in this GPA shall make the Parties partners, joint venturers, or otherwise associated in or with the business of the other. Parties are, and shall always remain, independent contractors. No Participant shall be liable for any debts, accounts, obligations, or other liabilities of the other Participant, its agents or employees. No party is authorized to incur debts or other obligations of any kind on the part of or as agent for the other. This GPA is not a franchise agreement and does not create a franchise relationship between the parties, and if any provision of this GPA is deemed to create a franchise between the parties, then this GPA shall automatically terminate. 24. CAPTIONS AND HEADINGS. The captions and headings used in this GPA are used for convenience only and are not to be given any legal effect. 25. EXECUTION. This GPA may be executed in counterparts, each of which so executed will be deemed to be an original and such counterparts together will constitute one and the same Agreement. The Parties shall transmit to each other a signed copy of the GPA by any means that faithfully reproduces the GPA along with the Signature. For purposes of this GPA, the term "signature" shall include digital signatures as defined by the jurisdiction of the Participant signing the GPA. Exhibit A Weight Range Requirements 0-99 May only be used under authorization of Owner 100-199 May only be used by the Owner's service provider, regardless of authorization. 200-299 Reserved -- do not use for e164 context. 300-399 May only be used by the owner of the code under which the Owner's number is a part of. 400-499 May be used by any entity providing access via direct connectivity to the Public Switched Telephone Network. 500-599 May be used by any entity providing access via indirect connectivity to the Public Switched Telephone Network (e.g. Via another VoIP provider) 600- Reserved-- do not use for e164 context. Participant Participant Company: Address: Email:
END OF GENERAL PEERING AGREEMENT -----------------------------------------------How to Peer using this GPA If you wish to exchange routing information with parties using the e164 DUNDi context, all you must do is execute this GPA with any member of the Peering System and you will become a member of the Peering System and be able to make Routes available in accordance with this GPA.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
408
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
409
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
410
Performs an ENUM tree lookup on the specified number, method type, and ordinal record offset, and returns one of four different values:
1. 2. 3. 4.
Post-parsed NAPTR of one method (URI) type Count of elements of one method (URI) type Count of all method types Full URI of method at a particular point in the list of all possible methods
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
411
ENUMLOOKUP Arguments
number - Telephone number or search string. Only numeric values within this string are parsed; all other digits are ignored for search, but are re-written during NAPTR regexp expansion. service_type - tel, sip, h323, iax2, mailto, ...[any other string], ALL. Default type is "sip". Special name of "ALL" will create a list of method types across all NAPTR records for the search number, and then put the results in an ordinal list starting with 1. The position number specified will then be returned, starting with 1 as the first record (lowest value) in the list. The service types are not hardcoded in Asterisk except for the default (sip) if no other service type specified; any method type string (IANA-approved or not) may be used except for the string "ALL". options c - count. Returns the number of records of this type are returned (regardless of order or priority.) If "ALL" is the specified service_type, then a count of all methods will be returned for the DNS record. record# - Which record to present if multiple answers are returned integer = The record in priority/order sequence based on the total count of records passed back by the query. If a service_type is specified, all entries of that type will be sorted into an ordinal list starting with 1 (by order first, then priority). The default of options is "1" zone_suffix - Allows customization of the ENUM zone. Default is e164.arpa.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
412
ENUMLOOKUP Examples
Let's use this ENUM list as an example (note that these examples exist in the DNS, and will hopefully remain in place as example destinations, but they may change or become invalid over time. The end result URIs are not guaranteed to actually work, since some of these hostnames or SIP proxies are imaginary. Of course, the tel: replies go to directory assistance for New York City and San Francisco...) Also note that the complex SIP NAPTR at weight 30 will strip off the leading "+" from the dialed string if it exists. This is probably a better NAPTR than hard-coding the number into the NAPTR, and it is included as a more complex regexp example, though other simpler NAPTRs will work just as well.
0.2.0.1.1.6.5.1.0.3.1.loligo.com. 3600 found." . 0.2.0.1.1.6.5.1.0.3.1.loligo.com. 3600 found." . 0.2.0.1.1.6.5.1.0.3.1.loligo.com. 3600 ([email protected]) not found." . 0.2.0.1.1.6.5.1.0.3.1.loligo.com. 3600 ([email protected]) not found." . 0.2.0.1.1.6.5.1.0.3.1.loligo.com. 3600 (\\[email protected]) not found." . 0.2.0.1.1.6.5.1.0.3.1.loligo.com. 3600 ([email protected]) not found." . IN NAPTR 10 100 "u" "E2U+tel" "Unable to render embedded object: File (+12125551212) not IN NAPTR 21 100 "u" "E2U+tel" "Unable to render embedded object: File (+14155551212) not IN NAPTR 25 100 "u" "E2U+sip" "Unable to render embedded object: File IN NAPTR 26 100 "u" "E2U+sip" "Unable to render embedded object: File IN NAPTR 30 100 "u" "E2U+sip" "Unable to render embedded object: File IN NAPTR 55 100 "u" "E2U+mailto" "Unable to render embedded object: File
Example 1: Simplest case, using first SIP return (use all defaults except for domain name)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
413
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
414
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
415
extensions.conf
; example 1 ; ; Assumes North American international dialing (011) prefix. ; Look up the first SIP result and send the call there, otherwise ; send the call out a PRI. This is the most simple possible ; ENUM example, but only uses the first SIP reply in the list of ; NAPTR(s). ; exten => _011.,1,Set(enumresult=${ENUMLOOKUP(${EXTEN:3})}) exten => _011.,n,Dial(SIP/${enumresult}) exten => _011.,n,Dial(DAHDI/g1/${EXTEN}) ; ; example 2 ; ; Assumes North American international dialing (011) prefix. ; Check to see if there are multiple SIP NAPTRs returned by ; the lookup, and dial each in order. If none work (or none ; exist) then send the call out a PRI, group 1. ; exten => _011.,1,Set(sipcount=${ENUMLOOKUP(${EXTEN:3},sip,c)}|counter=0) exten => _011.,n,While($["${counter}"<"${sipcount}"]) exten => _011.,n,Set(counter=$[${counter}+1]) exten => _011.,n,Dial(SIP/${ENUMLOOKUP(${EXTEN:3},sip,,${counter})}) exten => _011.,n,EndWhile exten => _011.,n,Dial(DAHDI/g1/${EXTEN}) ; ; example 3 ; ; This example expects an ${EXTEN} that is an e.164 number (like ; 14102241145 or 437203001721) ; Search through e164.arpa and then also search through e164.org ; to see if there are any valid SIP or IAX termination capabilities. ; If none, send call out via DAHDI channel 1. ; ; Start first with e164.arpa zone... ; exten => _X.,1,Set(sipcount=${ENUMLOOKUP(${EXTEN},sip,c)}|counter=0) exten => _X.,2,GotoIf($["${counter}"<"${sipcount}"]?3:6) exten => _X.,3,Set(counter=$[${counter}+1]) exten => _X.,4,Dial(SIP/${ENUMLOOKUP(${EXTEN},sip,,${counter})}) exten => _X.,5,GotoIf($["${counter}"<"${sipcount}"]?3:6) ; exten => _X.,6,Set(iaxcount=${ENUMLOOKUP(${EXTEN},iax2,c)}|counter=0) exten => _X.,7,GotoIf($["${counter}"<"${iaxcount}"]?8:11) exten => _X.,8,Set(counter=$[${counter}+1]) exten => _X.,9,Dial(IAX2/${ENUMLOOKUP(${EXTEN},iax2,,${counter})}) exten => _X.,10,GotoIf($["${counter}"<"${iaxcount}"]?8:11) ; exten => _X.,11,NoOp("No valid entries in e164.arpa for ${EXTEN} - checking in e164.org")
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
416
; ; ...then also try e164.org, and look for SIP and IAX NAPTRs... ; exten => _X.,12,Set(sipcount=${ENUMLOOKUP(${EXTEN},sip,c,,e164.org)}|counter=0) exten => _X.,13,GotoIf($["${counter}"<"${sipcount}"]?14:17) exten => _X.,14,Set(counter=$[${counter}+1]) exten => _X.,15,Dial(SIP/${ENUMLOOKUP(${EXTEN},sip,,${counter},e164.org)}) exten => _X.,16,GotoIf($["${counter}"<"${sipcount}"]?14:17) ; exten => _X.,17,Set(iaxcount=${ENUMLOOKUP(${EXTEN},iax2,c,,e164.org)}|counter=0) exten => _X.,18,GotoIf($["${counter}"<"${iaxcount}"]?19:22) exten => _X.,19,Set(counter=$[${counter}+1]) exten => _X.,20,Dial(IAX2/${ENUMLOOKUP(${EXTEN},iax2,,${counter},e164.org)}) exten => _X.,21,GotoIf($["${counter}"<"${iaxcount}"]?19:22) ; ; ...then send out PRI. ;
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
417
exten => _X.,22,NoOp("No valid entries in e164.org for ${EXTEN} - sending out via DAHDI") exten => _X.,23,Dial(DAHDI/g1/${EXTEN})
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
418
Features
Miscellaneous documents that talk about Asterisk functionality. All of this needs to be integrated into Configuration and Operation.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
419
Asterisk Applications
This page is a container page for Asterisk applications, e.g. those things that appear in the apps source directory.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
420
MacroExclusive()
About the MacroExclusive application
By: Steve Davies <[email protected] The MacroExclusive application was added to solve the problem of synchronization between calls running at the same time. This is usually an issue when you have calls manipulating global variables or the Asterisk database, but may be useful elsewhere. Consider this example macro, intended to return a "next" number - each caller is intended to get a different number:
[macro-push] ; push value ${ARG2} onto stack ${ARG1} exten => s,1,Set(DB(STACK/${ARG1})=${ARG2}^${DB(STACK/${ARG1})}) [macro-pop] ; pop top value from stack ${ARG1} exten => s,1,Set(RESULT=${DB(STACK/${ARG1})}) exten => s,n,Set(DB(STACK/${ARG1})=${CUT(RESULT,^,2)}) exten => s,n,Set(RESULT=${CUT(RESULT,^,1)})
All that futzing with the STACK/${ARG1} in the astdb needs protecting if this is to work. But neither push nor pop can run together. So add this "pattern":
s,1,MacroExclusive(stack,push,MYSTACK,bananas) s,n,MacroExclusive(stack,push,MYSTACK,apples) s,n,MacroExclusive(stack,push,MYSTACK,guavas) s,n,MacroExclusive(stack,push,MYSTACK,pawpaws) s,n,MacroExclusive(stack,pop,MYSTACK) ; RESULT s,n,MacroExclusive(stack,pop,MYSTACK) ; RESULT s,n,MacroExclusive(stack,pop,MYSTACK) ; RESULT s,n,MacroExclusive(stack,pop,MYSTACK) ; RESULT
We get to the push and pop macros "via" the stack macro. But only one call can execute the stack macro at a time; ergo, only one of push OR pop can run at a time.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
421
Hope people find this useful. Lastly, its worth pointing out that only Macros that access shared data will require this MacroExclusive protection. And Macro's that you call with macroExclusive should run quickly or you will clog up your Asterisk system.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
422
SMS()
The SMS application
SMS() is an application to handles calls to/from text message capable phones and message centres using ETSI ES 201 912 protocol 1 FSK messaging over analog calls. Basically it allows sending and receiving of text messages over the PSTN. It is compatible with BT Text service in the UK and works on ISDN and PSTN lines. It is designed to connect to an ISDN or DAHDI interface directly and uses FSK so would probably not work over any sort of compressed link (like a VoIP call using GSM codec). Typical applications include:-
1. Connection to a message centre to send text messages - probably initiated via the manager interface or "outgoing" directory 2. Connection to an POTS line with an SMS capable phone to send messages - probably initiated via the manager interface or "outgoing" directory 3. Acceptance of calls from the message centre (based on CLI) and storage of received messages 4. Acceptance of calls from a POTS line with an SMS capable phone and storage of received messages
Arguments to sms():
First argument is queue name Second is options: a: SMS() is to act as the answering side, and so send the initial FSK frame s: SMS() is to act as a service centre side rather than as terminal equipment If a third argument is specified, then SMS does not handle the call at all, but takes the third argument as a destination number to send an SMS to The forth argument onward is a message to be queued to the number in the third argument. All this does is create the file in the me-sc directory. If 's' is set then the number is the source address and the message placed in the sc-me directory.
All text messages are stored in /var/spool/asterisk/sms A log is recorded in /var/log/asterisk/sms There are two subdirectories called sc-me.<queuename> holding all messages from service centre to phone, and me-sc.<queuename> holding all messages from phone to service centre. In each directory are messages in files, one per file, using any filename not starting with a dot. When connected as a service centre, SMS(s) will send all messages waiting in the sc-me-<queuename> directory, deleting the files as it goes. Any received in this mode are placed in the me-sc-<queuename> directory. When connected as a client, SMS() will send all messages waiting in the me-sc-<queuename> directory, deleting the files as it goes. Any received in this mode are placed in the sc-me-<queuename> directory. Message files created by SMS() use a time stamp/reference based filename. The format of the sms file is lines that have the form of key=value Keys are :
oa - Originating Address. Telephone number, national number if just digits. Telephone number starting with + then digits for international. Ignored on sending messages to service centre (CLI used) da - Destination Address. Telephone number, national number if just digits. Telephone number starting with + then digits for international. scts - Service Centre Time Stamp in the format YYYY-MM-DD HH:MM:SS pid - Protocol Identifier (decimal octet value) dcs - Data coding scheme (decimal octet value) mr - Message reference (decimal octet value) ud - The message (see escaping below) srr - 0/1 Status Report Request rp - 0/1 Return Path vp - mins validity period
Omitted fields have default values.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
423
Note that there is special format for ud, ud# instead of ud= which is followed by raw hex (2 characters per octet). This is used in output where characters other than 10,13,32-126,128-255 are included in the data. In this case a comment (line starting ;) is added showing the printable characters When generating files to send to a service centre, only da and ud need be specified. oa is ignored. When generating files to send to a phone, only oa and ud need be specified. da is ignored. When receiving a message as a service centre, only the destination address is sent, so the originating address is set to the callerid. EXAMPLES The following are examples of use within the UK using BT Text SMS/landline service. This is a context to use with a manager script.
[smsdial] ; create and send a text message, expects number+message and ; connect to 17094009 exten => _X.,1,SMS(${CALLERIDNUM},,${EXTEN},${CALLERIDNAME}) exten => _X.,n,SMS(${CALLERIDNUM}) exten => _X.,n,Hangup
The script sends
action: originate callerid: message <from> exten: to channel: Local/17094009 context: smsdial priority: 1
You put the message as the name of the caller ID (messy, I know), the originating number and hence queue name as the number of the caller ID and the exten as the number to which the sms is to be sent. The context uses SMS to create the message in the queue and then SMS to communicate with 17094009 to actually send the message. Note that the 9 on the end of 17094009 is the sub address 9 meaning no sub address (BT specific). If a different digit is used then that is the sub address for the sending message source address (appended to the outgoing CLI by BT). For incoming calls you can use a context like this :-
[incoming] exten => _XXXXXX/_8005875290,1,SMS(${EXTEN:3},a) exten => _XXXXXX/_8005875290,n,System(/usr/lib/asterisk/smsin ${EXTEN:3}) exten => _XXXXXX/_80058752[0-8]0,1,SMS(${EXTEN:3}${CALLERIDNUM:8:1},a) exten => _XXXXXX/_80058752[0-8]0,n,System(/usr/lib/asterisk/smsin ${EXTEN>:3}${CALLERIDNUM:8:1}) exten => _XXXXXX/_80058752[0-8]0,n,Hangup
In this case the called number we get from BT is 6 digits (XXXXXX) and we are using the last 3 digits as the queue name. Priority 1 causes the SMS to be received and processed for the incoming call. It is from 080058752X0. The two versions handle the queue name as 3 digits (no sub address) or 4 digits (with sub address). In both cases, after the call a script (smsin) is run - this is optional, but is useful to actually processed the received queued SMS. In our case we email them based on the target number. Priority 3 hangs up. If using the CAPI drivers they send the right CLI and so the _800... would be _0800...
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
424
How to perform the call, similar to the Dial() application What to do when the call is answered
With call files you submit this information simply by creating a file with the required syntax and placing it in the outgoing spooling directory, located by default in /var/spool/asterisk/outgoing/ (this is configurable in asterisk.conf). The pbx_spool.so module watches the spooling directly, either using an event notification system supplied by the operating system such as inotify or kqueue, or by polling the directory each second when one of those notification systems is unavailable. When a new file appears, Asterisk initiates a new call based on the file's contents.
Creating Files in the Spool Directory Do not write or create the call file directly in the outgoing directory, but always create the file in another directory of the same filesystem and then move the file to the outgoing directory, or Asterisk may read a partial file.
NFS Considerations By default, Asterisk will prefer to use inotify or kqueue where available. When the spooling directory is on a remote server and is mounted via NFS, the inotify method will fail to work. You can force Asterisk to use the older polling method by passing the --without-inotify flag to configure during compilation (e.g. ./configure --without-inotify).
Channel: <channel> - The channel to use for the new call, in the form technology/resource as in the Dial application. This value is required. Callerid: <callerid> - The caller id to use. WaitTime: <number> - How many seconds to wait for an answer before the call fails (ring cycle). Defaults to 45 seconds. MaxRetries: <number> - Number of retries before failing, not including the initial attempt. Default = 0 e.g. don't retry if fails. RetryTime: <number> - How many seconds to wait before retry. The default is 300 (5 minutes). Account: <account> - The account code for the call. This value will be assigned to CDR(accountcode)
When the call answers there are two choices:
To execute an application:
Application: <appname> - The application to execute Data: <args> - The application arguments
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
425
Archive: <yes|no> - If "no" the call file is deleted. If set to "yes" the call file is moved to the "outgoing_done" subdirectory of the Asterisk spool directory. The default is to delete the call file.
If the call file is archived, Asterisk will append to the call file:
Directory locations
<astspooldir>/outgoing - The outgoing dir, where call files are put for processing <astspooldir>/outgoing_done - The archive dir <astspooldir> - Is specified in asterisk.conf, usually /var/spool/asterisk
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
426
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
427
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
428
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
429
- Account -> AccountCode - (new) -> BridgedUniqueid - StatusComplete Event New header - (new) -> Items Number of channels reported
- The ExtensionStatus manager command now has a "StatusDesc" field with text description of the state - The Registry and Peerstatus events in chan_sip and chan_iax now use "ChannelType" instead of "ChannelDriver" - The Response to Action: IAXpeers now have a Response: Success header - The MeetmeJoin now has caller ID name and Caller ID number fields (like MeetMeLeave) - Action DAHDIShowChannels Header changes - Channel: -> DAHDIChannel For active channels, the Channel: and Uniqueid: headers are added You can now add a "DAHDIChannel: " argument to DAHDIshowchannels actions to only get information about one channel. - Event DAHDIShowChannelsComplete New header - (new) -> Items: Reports number of channels reported - Action VoicemailUsersList Added new headers for SayEnvelope, SayCID, AttachMessage, CanReview and CallOperator voicemail configuration settings. - Action Originate Now requires the new Originate privilege. If you call out to a subshell in Originate with the Application parameter, you now also need the System privilege. - Event QueueEntry now also returns the Uniqueid field like other events from app_queue. - Action IAXpeerlist Now includes if the IAX link is a trunk or not - Action IAXpeers Now includes if the IAX link is a trunk or not - Action Ping Response now includes a timestamp - Action SIPshowpeer Response now includes the configured parkinglot
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
430
NEW ACTIONS
- Action: DataGet Modules: data.c Purpose: To be able to retrieve the asterisk data tree. Variables: ActionID: <id> Action ID for this transaction. Will be returned. Path: <data path> The path to the callback node to retrieve. Filter: <filter> Which nodes to retrieve. Search: <search> Search condition. - Action: IAXregistry Modules: chan_iax2 Purpose: To list all IAX2 peers in the IAX registry with their registration status. Variables: ActionID: <id> Action ID for this transaction. Will be returned. - Action: ModuleLoad Modules: loader.c Purpose: To be able to unload, reload and unload modules from AMI. Variables: ActionID: <id> Action ID for this transaction. Will be returned. Module: <name> Asterisk module name (including .so extension) or subsystem identifier: cdr, enum, dnsmgr, extconfig, manager, rtp, http LoadType: load | unload | reload The operation to be done on module If no module is specified for a reload loadtype, all modules are reloaded - Action: ModuleCheck Modules: loader.c Purpose: To check version of a module - if it's loaded Variables: ActionID: <id> Action ID for this transaction. Will be returned. Module: <name> Asterisk module name (not including extension) Returns: If module is loaded, returns version number of the module Note: This will have to change. I don't like sending Response: failure on both command not found (trying this command in earlier versions of Asterisk) and module not found. Also, check if other manager actions behave that way. - Action: QueueSummary Modules: app_queue Purpose: To request that the manager send a QueueSummary event (see the NEW EVENTS section for more details). Variables: ActionID: <id> Action ID for this transaction. Will be returned. Queue: <name> Queue for which the summary is desired - Action: QueuePenalty Modules: app_queue Purpose: To change the penalty of a queue member from AMI Variables: Interface: <tech/name> The interface of the member whose penalty you wish to change Penalty: <number> The new penalty for the member. Must be nonnegative. Queue: <name> If specified, only set the penalty for the member for this queue; Otherwise, set the penalty for the member in all queues to which he belongs. - Action: QueueRule Modules: app_queue Purpose: To list queue rules defined in queuerules.conf Variables: ActionID: <id> Action ID for this transaction. Will be returned. Rule: <name> The name of the rule whose contents you wish to list. If this variable is not present, all rules in queuerules.conf will be listed. - Action: Atxfer Modules: none Purpose: Initiate an attended transfer Variables: Channel: The transferer channel's name Exten: The extension to transfer to
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
431
Priority: The priority to transfer to Context: The context to transfer to - Action: SipShowRegistry Modules: chan_sip Purpose: To request that the manager send a list of RegistryEntry events. Variables: ActionId: <id> Action ID for this transaction. Will be returned. - Action: QueueReload Modules: app_queue Purpose: To reload queue rules, a queue's members, a queue's parameters, or all of the aforementioned Variable: ActionID: <id> Queue: <name> The name of the queue to take action on. If no queue name is specified, then all queues are affected Rules: <yes or no> Whether to reload queuerules.conf Members: <yes or no> Whether to reload the queue's members Parameters: <yes or no> Whether to reload the other queue options - Action: QueueReset Modules: app_queue Purpose: Reset the statistics for a queue Variables: ActionID: <id> Queue: <name> The name of the queue on which to reset statistics - Action: SKINNYdevices Modules: chan_skinny Purpose: To list all SKINNY devices configured. Variables: ActionId: <id> Action ID for this transaction. Will be returned. - Action: SKINNYlines Modules: chan_skinny Purpose: To list all SKINNY lines configured. Variables: ActionId: <id> Action ID for this transaction. Will be returned. - Action SKINNYshowdevice Modules: chan_skinny Purpose: To list the information about a specific SKINNY device. Variables: Device: <device> Device to show information about. - Action SKINNYshowline Modules: chan_skinny Purpose: To list the information about a specific SKINNY line. Variables: Line: <line> Line to show information about. - Action: CoreSettings Modules: manager.c Purpose: To report core settings, like AMI and Asterisk version, maxcalls and maxload settings. * Integrated in SVN trunk as of May 4th, 2007 Example: Response: Success ActionID: 1681692777 AMIversion: 1.1 AsteriskVersion: SVN-oej-moremanager-r61756M SystemName: EDVINA-node-a CoreMaxCalls: 120 CoreMaxLoadAvg: 0.000000 CoreRunUser: edvina CoreRunGroup: edvina - Action: CoreStatus Modules: manager.c Purpose: To report current PBX core status flags, like number of concurrent calls, startup and reload time. * Integrated in SVN trunk as of May 4th, 2007 Example: Response: Success ActionID: 1649760492 CoreStartupTime: 22:35:17 CoreReloadTime: 22:35:17 CoreCurrentCalls: 20 - Action: MixMonitorMute Modules: app_mixmonitor.c Purpose:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
432
Mute / unMute a Mixmonitor recording. Variables: ActionId: <id> Action ID for this transaction. Will be returned. Channel: the channel MixMonitor is running on Direction: Which part of the recording to mute: read, write or both (from
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
433
channel, to channel or both channels). State: Turn mute on or off : 1 to turn on, 0 to turn off.
NEW EVENTS
- Event: FullyBooted Modules: loader.c Purpose: It is handy to have a single event notification for when all Asterisk modules have been loaded--especially for situations like running automated tests. This event will fire 1) immediately upon all modules loading or 2) upon connection to the AMI interface if the modules have already finished loading before the connection was made. This ensures that a user will never miss getting a FullyBooted event. In vary rare circumstances, it might be possible to get two copies of the message if the AMI connection is made right as the modules finish loading. Example: Event: FullyBooted Privilege: system,all Status: Fully Booted - Event: Transfer Modules: res_features, chan_sip Purpose: Inform about call transfer, linking transferer with transfer target You should be able to trace the call flow with this missing piece of information. If it works out well, the "Transfer" event should be followed by a "Bridge" event The transfermethod: header informs if this is a pbx core transfer or something done on channel driver level. For SIP, check the example: Example: Event: Transfer Privilege: call,all TransferMethod: SIP TransferType: Blind Channel: SIP/device1-01849800 SIP-Callid: [email protected] TargetChannel: SIP/device2-01841200 TransferExten: 100 TransferContext: default - Event: ChannelUpdate Modules: chan_sip.c, chan_iax2.c Purpose: Updates channel information with ID of PVT in channel driver, to be able to link events on channel driver level. * Integrated in SVN trunk as of May 4th, 2007 Example: Event: ChannelUpdate Privilege: system,all Uniqueid: 1177271625.27 Channel: SIP/olle-01843c00 Channeltype: SIP SIPcallid: NTQzYWFiOWM4NmE0MWRkZjExMzU2YzQ3OWQwNzg3ZmI. SIPfullcontact: sip:[email protected]:49054 - Event: NewAccountCode Modules: cdr.c Purpose: To report a change in account code for a live channel Example: Event: NewAccountCode Privilege: call,all Channel: SIP/olle-01844600 Uniqueid: 1177530895.2 AccountCode: Stinas account 1234848484 OldAccountCode: OllesAccount 12345 - Event: ModuleLoadReport Modules: loader.c Purpose: To report that module loading is complete. Some aggressive clients connect very quickly to AMI and needs to know when all manager events embedded in modules are loaded Also, if this does not happen, something is seriously wrong. This could happen to chan_sip and other modules using DNS. Example: Event: ModuleLoad ModuleLoadStatus: Done ModuleSelection: All ModuleCount: 24 - Event: QueueSummary Modules: app_queue Purpose: To report a summary of queue information. This event is generated by
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
434
issuing a QueueSummary AMI action. Example: Event: QueueSummary Queue: Sales LoggedIn: 12 Available: 5 Callers: 10 HoldTime: 47 If an actionID was specified for the QueueSummary action, it will be appended as the last line of the QueueSummary event. - Event: AgentRingNoAnswer Modules: app_queue Purpose: Reports when a queue member was rung but there was no answer. Example: Event: AgentRingNoAnswer Queue: Support Uniqueid: 1177530895.2 Channel: SIP/1000-53aee458 Member: SIP/1000 MemberName: Thaddeus McClintock Ringtime: 10 - Event: RegistryEntry Modules: chan_sip Purpose: Reports the state of the SIP registrations. This event is generated by issuing a QueueSummary AMI action. The RegistrationTime header is expressed as epoch. Example: Event: RegistryEntry Host: sip.myvoipprovider.com Port: 5060 Username: guestuser Refresh: 105 State: Registered RegistrationTime: 1219161830 If an actionID was specified for the SipShowRegistry action, it will be appended as the last line of the RegistrationsComplete event. - Event: ChanSpyStart Modules: app_chanspy Purpose: Reports when an active channel starts to be monitored by someone. Example: Event: ChanSpyStart SpyerChannel: SIP/4321-13bba124 SpyeeChannel: SIP/1234-56ecc098 - Event: ChanSpyStop Modules: app_chanspy Purpose: Reports when an active channel stops to be monitored by someone. Example:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
435
TODO ...
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
436
Building Queues
Building Queues
Written by: Leif Madsen Initial version: 2010-01-14 In this article, we'll look at setting up a pair of queues in Asterisk called 'sales' and 'support'. These queues can be logged into by queue members, and those members will also have the ability to pause and unpause themselves. All configuration will be done in flat files on the system in order to maintain simplicity in configuration. Note that this documentation is based on Asterisk 1.6.2, and this is just one approach to creating queues and the dialplan logic. You may create a better way, and in that case, I would encourage you to submit it to the Asterisk issue tracker at http://issues.asterisk.org for inclusion in Asterisk. Adding SIP Devices to Your Server The first thing we want to do is register a couple of SIP devices to our server. These devices will be our agents that can login and out of the queues we'll create later. Our naming convention will be to use MAC addresses as we want to abstract the concepts of user (agent), device, and extension from each other. In sip.conf, we add the following to the bottom of our file:
sip.conf -------[std-device](!) type=peer context=devices host=dynamic secret=s3CuR#p@s5 dtmfmode=rfc2833 disallow=all allow=ulaw [0004f2040001](std-device) [0004f2040002](std-device)
What we're doing here is creating a [std-device] template and applying it to a pair of peers that we'll register as 0004f2040001 and 0004f2040002; our devices. Then our devices can register to Asterisk. In my case I have a hard phone and a soft phone registered. I can verify their connectivity by running 'sip show peers'.
*CLI> sip show peers Name/username Host Dyn Nat ACL Port Status 0004f2040001/0004f2040001 192.168.128.145 D 5060 Unmonitored 0004f2040002/0004f2040002 192.168.128.126 D 5060 Unmonitored 2 sip peers [Monitored: 0 online, 0 offline Unmonitored: 2 online, 0 offline]
Configuring Device State Next, we need to configure our system to track the state of the devices. We do this by defining a 'hint' in the dialplan which creates the ability for a device subscription to be retained in memory. By default we can see there are no hints registered in our system by running the 'core show hints' command.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
437
We need to add the devices we're going to track to the extensions.conf file under the [default] context which is the default configuration in sip.conf, however we can change this to any context we want with the 'subscribecontext' option. Add the following lines to extensions.conf:
*CLI> core show hints -= Registered Asterisk Dial Plan Hints =0004f2040002@default : SIP/0004f2040002 Watchers 0 0004f2040001@default : SIP/0004f2040001 Watchers 0 ---------------- 2 hints registered
State:Idle State:Idle
At this point, create an extension that you can dial that will play a prompt that is long enough for you to go back to the Asterisk console to check the state of your device while it is in use. To do this, add the 555 extension to the [devices] context and make it playback the tt-monkeys file.
*CLI> == Using SIP RTP CoS mark 5 -- Executing [555@devices:1] Playback("SIP/0004f2040001-00000001", "tt-monkeys") in new stack -- <SIP/0004f2040001-00000001> Playing 'tt-monkeys.slin' (language 'en') *CLI> core show hints -= Registered Asterisk Dial Plan Hints =0004f2040002@default : SIP/0004f2040002 Watchers 0 0004f2040001@default : SIP/0004f2040001 Watchers 0 ---------------- 2 hints registered
Aha, we're not getting the device state correctly. There must be something else we need to configure. In sip.conf, we need to enable 'callcounter' in order to activate the ability for Asterisk to monitor whether the device is in use or not. In versions prior to 1.6.0 we needed to use 'call-limit' for this functionality, but call-limit is now deprecated and is no longer necessary. So, in sip.conf, in our [std-device] template, we need to add the callcounter option.
State:Idle State:Idle
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
438
sip.conf -------[std-device](!) type=peer context=devices host=dynamic secret=s3CuR#p@s5 dtmfmode=rfc2833 disallow=all allow=ulaw callcounter=yes
Then reload chan_sip with 'sip reload' and perform our 555 test again. Dial 555 and then check the device state with 'core show hints'.
*CLI> == Using SIP RTP CoS mark 5 -- Executing [555@devices:1] Playback("SIP/0004f2040001-00000002", "tt-monkeys") in new stack -- <SIP/0004f2040001-00000002> Playing 'tt-monkeys.slin' (language 'en') *CLI> core show hints -= Registered Asterisk Dial Plan Hints =0004f2040002@default : SIP/0004f2040002 Watchers 0 0004f2040001@default : SIP/0004f2040001 Watchers 0 ---------------- 2 hints registered
State:Idle State:InUse
Note that now we have the correct device state when extension 555 is dialed, showing that our device is InUse after dialing extension 555. This is important when creating queues, otherwise our queue members would get multiple calls from the queues. Adding Queues to Asterisk The next step is to add a couple of queues to Asterisk that we can assign queue members into. For now we'll work with two queues; sales and support. Lets create those queues now in queues.conf. We'll leave the default settings that are shipped with queues.conf.sample in the [general] section of queues.conf. See the queues.conf.sample file for more information about each of the available options.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
439
queues.conf ---------[queue_template](!) musicclass=default strategy=rrmemory joinempty=yes leavewhenempty=no ringinuse=no [sales](queue_template) ; Sales queue [support](queue_template) ; Support queue
After defining our queues, lets reload our app_queue.so module.
; ; ; ; ;
play [default] music use the Round Robin Memory strategy join the queue when no members available don't leave the queue no members available don't ring members when already InUse
*CLI> module reload app_queue.so -- Reloading module 'app_queue.so' (True Call Queueing) == Parsing '/etc/asterisk/queues.conf':
Then verify our queues loaded with 'queue show'.
== Found
*CLI> queue show support has 0 calls (max unlimited) in 'rrmemory' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s No Members No Callers sales has 0 calls (max unlimited) in 'rrmemory' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s No Members No Callers
Adding Queue Members You'll notice that we have no queue members available to take calls from the queues. We can add queue members from the Asterisk CLI with the 'queue add member' command. This is the format of the 'queue add member' command:
Usage: queue add member <channel> to <queue> [[[penalty <penalty>] as <membername>] state_interface <interface>] Add a channel to a queue with optionally: a penalty, membername and a state_interface
The penalty, membername, and state_interface are all optional values. Special attention should be brought to the 'state_interface' option for a member though. The reason for state_interface is that if you're using a channel that does not have device state itself (for example, if you were using the Local channel to deliver a call to an end point) then you could assign the device state of a SIP device to the pseudo channel. This allows the state of a SIP device to be applied to the Local channel for correct device state information. Lets add our device located at SIP/0004f2040001
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
440
*CLI> queue add member SIP/0004f2040001 to sales Added interface 'SIP/0004f2040001' to queue 'sales'
Then lets verify our member was indeed added.
*CLI> queue show sales sales has 0 calls (max unlimited) in 'rrmemory' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s Members: SIP/0004f2040001 (dynamic) (Not in use) has taken no calls yet No Callers
Now, if we dial our 555 extension, we should see that our member becomes InUse within the queue.
*CLI> == Using SIP RTP CoS mark 5 -- Executing [555@devices:1] Playback("SIP/0004f2040001-00000001", "tt-monkeys") in new stack -- <SIP/0004f2040001-00000001> Playing 'tt-monkeys.slin' (language 'en')
*CLI> queue show sales sales has 0 calls (max unlimited) in 'rrmemory' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s Members: SIP/0004f2040001 (dynamic) (In use) has taken no calls yet No Callers
We can also remove our members from the queue using the 'queue remove' CLI command.
*CLI> queue remove member SIP/0004f2040001 from sales Removed interface 'SIP/0004f2040001' from queue 'sales'
Because we don't want to have to add queue members manually from the CLI, we should create a method that allows queue members to login and out from their devices. We'll do that in the next section. But first, lets add an extension to our dialplan in order to permit people to dial into our queues so calls can be delivered to our queue members.
extensions.conf --------------[devices] exten => 555,1,Playback(tt-monkeys) exten => 100,1,Queue(sales) exten => 101,1,Queue(support)
Then reload the dialplan, and try calling extension 100 from SIP/0004f2040002, which is the device we have not logged into the queue.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
441
*CLI> == Using SIP RTP CoS mark 5 -- Executing [100@devices:1] Queue("SIP/0004f2040002-00000005", "sales") in new stack -- Started music on hold, class 'default', on SIP/0004f2040002-00000005 == Using SIP RTP CoS mark 5 -- SIP/0004f2040001-00000006 is ringing
We can see the device state has changed to Ringing while the device is ringing.
*CLI> queue show sales sales has 1 calls (max unlimited) in 'rrmemory' strategy (2s holdtime, 3s talktime), W:0, C:1, A:1, SL:0.0% within 0s Members: SIP/0004f2040001 (dynamic) (Ringing) has taken 1 calls (last was 14 secs ago) Callers: 1. SIP/0004f2040002-00000005 (wait: 0:03, prio: 0)
Our queue member then answers the phone.
*CLI> -- SIP/0004f2040001-00000006 answered SIP/0004f2040002-00000005 -- Stopped music on hold on SIP/0004f2040002-00000005 -- Native bridging SIP/0004f2040002-00000005 and SIP/0004f2040001-00000006
And we can see the queue member is now in use.
*CLI> queue show sales sales has 0 calls (max unlimited) in 'rrmemory' strategy (3s holdtime, 3s talktime), W:0, C:1, A:1, SL:0.0% within 0s Members: SIP/0004f2040001 (dynamic) (In use) has taken 1 calls (last was 22 secs ago) No Callers
Then the call is hung up.
*CLI> queue show sales sales has 0 calls (max unlimited) in 'rrmemory' strategy (3s holdtime, 4s talktime), W:0, C:2, A:1, SL:0.0% within 0s Members: SIP/0004f2040001 (dynamic) (Not in use) has taken 2 calls (last was 6 secs ago) No Callers
Logging In and Out of Queues In this section we'll show how to use the AddQueueMember() and RemoveQueueMember() dialplan applications to login and out of queues. For more information about the available options to AddQueueMember() and RemoveQueueMember() use the 'core show application <app>' command from the CLI. The following bit of dialplan is a bit long, but stick with it, and you'll see that it isn't really all that bad. The gist of the dialplan is that it will check to see if the active user (the device that is dialing the extension) is currently logged into the queue extension that has been requested, and if logged in, then will log them out; if not logged in, then they will be logged into the queue.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
442
We've updated the two lines we added in the previous section that allowed us to dial the sales and support queues. We've abstracted this out a bit in order to make it easier to add new queues in the future. This is done by adding the queue names to a global variable, then utilizing the extension number dialed to look up the queue name. So we replace extension 100 and 101 with the following dialplan.
; Call any of the queues we've defined in the [globals] section. exten => _1XX,1,Verbose(2,Call queue as configured in the QUEUE_${EXTEN} global variable) exten => _1XX,n,Set(thisQueue=${GLOBAL(QUEUE_${EXTEN})}) exten => _1XX,n,GotoIf($["${thisQueue}" = ""]?invalid_queue,1) exten => _1XX,n,Verbose(2, --> Entering the ${thisQueue} queue) exten => _1XX,n,Queue(${thisQueue}) exten => _1XX,n,Hangup() exten => invalid_queue,1,Verbose(2,Attempted to enter invalid queue) exten => invalid_queue,n,Playback(silence/1&invalid) exten => invalid_queue,n,Hangup()
The globals section contains the following two global variables.
; Extension *100 or *101 will login/logout a queue member from sales or support queues respectively. exten => _*10[0-1],1,Set(xtn=${EXTEN:1}) ; save ${EXTEN} with * chopped off to ${xtn} exten => _*10[0-1],n,Goto(queueLoginLogout,member_check,1) ; check if already logged into a queue
We save the value of ${EXTEN:1} to the 'xtn' channel variable so we don't need to keep typing the complicated pattern match. Now we move into the meat of our login/out dialplan inside the [queueLoginLogout] context. The first section is initializing some variables that we need throughout the member_check extension such as the name of the queue, the members currently logged into the queue, and the current device peer name (i.e. SIP/0004f2040001).
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
443
; ### Login or Logout a Queue Member [queueLoginLogout] exten => member_check,1,Verbose(2,Logging queue member in or out of the request queue) exten => member_check,n,Set(thisQueue=${GLOBAL(QUEUE_${xtn})}) ; assign queue name to a variable exten => member_check,n,Set(queueMembers=${QUEUE_MEMBER_LIST(${thisQueue})}) ; assign list of logged in members of thisQueue to ; a variable (comma separated) exten => member_check,n,Set(thisActiveMember=SIP/${CHANNEL(peername)}) ; initialize 'thisActiveMember' as current device exten => member_check,n,GotoIf($["${queueMembers}" = ""]?q_login,1) circuit to logging in if we don't have members logged into this queue ; short ; any
At this point if there are no members currently logged into our sales queue, we then short-circuit our dialplan to go to the 'q_login' extension since there is no point in wasting cycles searching to see if we're already logged in. The next step is to finish initializing some values we need within the While() loop that we'll use to check if we're already logged into the queue. We set our ${field} variable to 1, which will be used as the field number offset in the CUT() function.
; Initialize some values we'll use in the While() loop exten => member_check,n,Set(field=1) our field counter at one exten => member_check,n,Set(logged_in=0) initialize 'logged_in' to "not logged in" exten => member_check,n,Set(thisQueueMember=${CUT(queueMembers,\,,${field})}) initialize 'thisQueueMember' with the value in the field of the comma-separated list
Now we get to enter our While() loop to determine if we're already logged in.
; start ; ; ; first
; Enter our loop to check if our member is already logged into this queue exten => member_check,n,While($[${EXISTS(${thisQueueMember})}]) ; while we have a queue member...
This is where we check to see if the member at this position of the list is the same as the device we're calling from. If it doesn't match, then we go to the 'check_next' priority label (where we increase our ${field} counter variable). If it does match, then we continue on in the dialplan.
exten => member_check,n,GotoIf($["${thisQueueMember}" != "${thisActiveMember}"]?check_next) ; if 'thisQueueMember' is not the ; ; ; same as our active peer, then check the next in the list of logged in queue members
If we continued on in the dialplan, then we set the ${logged_in} channel variable to '1' which represents we're already logged into this queue. We then exit the While() loop with the ExitWhile() dialplan application.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
444
exten => member_check,n,Set(logged_in=1) ; if we got here, set as logged in exten => member_check,n,ExitWhile() ; then exit our loop
If we didn't match this peer name in the list, then we increase our ${field} counter variable by one, update the ${thisQueueMember} channel variable and then move back to the top of the loop for another round of checks.
exten => member_check,n(check_next),Set(field=$[${field} + 1]) ; if we got here, increase counter exten => member_check,n,Set(thisQueueMember=${CUT(queueMembers,\,,${field})}) ; get next member in the list exten => member_check,n,EndWhile() ; ...end of our loop
And once we exit our loop, we determine whether we need to log our device in or out of the queue.
; if not logged in, then login to this queue, otherwise, logout exten => member_check,n,GotoIf($[${logged_in} = 0]?q_login,1:q_logout,1) logged in, then login, otherwise, logout
; if not
The following two extensions are used to either log the device in or out of the queue. We use the AddQueueMember() and RemovQueueMember() applications to login or logout the device from the queue. The first two arguments for AddQueueMember() and RemoveQueueMember() are 'queue' and 'device'. There are additional arguments we can pass, and you can check those out with 'core show application AddQueueMember' and 'core show application RemoveQueueMember()'.
Login queue member ### => q_login,1,Verbose(2,Logging ${thisActiveMember} into the ${thisQueue} queue) => q_login,n,AddQueueMember(${thisQueue},${thisActiveMember}) our active device to the queue
; ;
; If the member was added to the queue successfully, then playback "Agent logged in", otherwise, state an error occurred exten => q_login,n,ExecIf($["${AQMSTATUS}" = "ADDED"]?Playback(agent-loginok):Playback(an-error-has-occurred)) exten => q_login,n,Hangup()
; ### Logout queue member ### exten => q_logout,1,Verbose(2,Logging ${thisActiveMember} out of ${thisQueue} queue) exten => q_logout,n,RemoveQueueMember(${thisQueue},${thisActiveMember}) exten => q_logout,n,Playback(silence/1) exten => q_logout,n,ExecIf($["${RQMSTATUS}" = "REMOVED"]?Playback(agent-loggedoff):Playback(an-error-has-occurred)) exten => q_logout,n,Hangup()
And that's it! Give it a shot and you should see console output similar to the following which will login and logout your queue members to the queues you've configured. You can see there are already a couple of queue members logged into the sales queue.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
445
*CLI> queue show sales sales has 0 calls (max unlimited) talktime), W:0, C:2, A:1, SL:0.0% within Members: SIP/0004f2040001 (dynamic) (Not in SIP/0004f2040002 (dynamic) (Not in No Callers
Then we dial *100 to logout the active device from the sales queue.
in 'rrmemory' strategy (3s holdtime, 4s 0s use) has taken no calls yet use) has taken no calls yet
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
446
*CLI> == Using SIP RTP CoS mark 5 -- Executing [*100@devices:1] Set("SIP/0004f2040001-00000012", "xtn=100") in new stack -- Executing [*100@devices:2] Goto("SIP/0004f2040001-00000012", "queueLoginLogout,member_check,1") in new stack -- Goto (queueLoginLogout,member_check,1) -- Executing [member_check@queueLoginLogout:1] Verbose("SIP/0004f2040001-00000012", "2,Logging queue member in or out of the request queue") in new stack == Logging queue member in or out of the request queue -- Executing [member_check@queueLoginLogout:2] Set("SIP/0004f2040001-00000012", "thisQueue=sales") in new stack -- Executing [member_check@queueLoginLogout:3] Set("SIP/0004f2040001-00000012", "queueMembers=SIP/0004f2040001,SIP/0004f2040002") in new stack -- Executing [member_check@queueLoginLogout:4] Set("SIP/0004f2040001-00000012", "thisActiveMember=SIP/0004f2040001") in new stack -- Executing [member_check@queueLoginLogout:5] GotoIf("SIP/0004f2040001-00000012", "0?q_login,1") in new stack -- Executing [member_check@queueLoginLogout:6] Set("SIP/0004f2040001-00000012", "field=1") in new stack -- Executing [member_check@queueLoginLogout:7] Set("SIP/0004f2040001-00000012", "logged_in=0") in new stack -- Executing [member_check@queueLoginLogout:8] Set("SIP/0004f2040001-00000012", "thisQueueMember=SIP/0004f2040001") in new stack -- Executing [member_check@queueLoginLogout:9] While("SIP/0004f2040001-00000012", "1") in new stack -- Executing [member_check@queueLoginLogout:10] GotoIf("SIP/0004f2040001-00000012", "0?check_next") in new stack -- Executing [member_check@queueLoginLogout:11] Set("SIP/0004f2040001-00000012", "logged_in=1") in new stack -- Executing [member_check@queueLoginLogout:12] ExitWhile("SIP/0004f2040001-00000012", "") in new stack -- Jumping to priority 15 -- Executing [member_check@queueLoginLogout:16] GotoIf("SIP/0004f2040001-00000012", "0?q_login,1:q_logout,1") in new stack -- Goto (queueLoginLogout,q_logout,1) -- Executing [q_logout@queueLoginLogout:1] Verbose("SIP/0004f2040001-00000012", "2,Logging SIP/0004f2040001 out of sales queue") in new stack == Logging SIP/0004f2040001 out of sales queue -- Executing [q_logout@queueLoginLogout:2] RemoveQueueMember("SIP/0004f2040001-00000012", "sales,SIP/0004f2040001") in new stack [Nov 12 12:08:51] NOTICE[11582]: app_queue.c:4842 rqm_exec: Removed interface 'SIP/0004f2040001' from queue 'sales' -- Executing [q_logout@queueLoginLogout:3] Playback("SIP/0004f2040001-00000012", "silence/1") in new stack -- <SIP/0004f2040001-00000012> Playing 'silence/1.slin' (language 'en') -- Executing [q_logout@queueLoginLogout:4] ExecIf("SIP/0004f2040001-00000012", "1?Playback(agent-loggedoff):Playback(an-error-has-occurred)") in new stack -- <SIP/0004f2040001-00000012> Playing 'agent-loggedoff.slin' (language 'en') -- Executing [q_logout@queueLoginLogout:5] Hangup("SIP/0004f2040001-00000012", "") in new stack == Spawn extension (queueLoginLogout, q_logout, 5) exited non-zero on 'SIP/0004f2040001-00000012'
And we can see that the device we loggd out by running 'queue show sales'.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
447
*CLI> queue show sales sales has 0 calls (max unlimited) in 'rrmemory' strategy (3s holdtime, 4s talktime), W:0, C:2, A:1, SL:0.0% within 0s Members: SIP/0004f2040002 (dynamic) (Not in use) has taken no calls yet No Callers
Pausing and Unpausing Members of Queues Once we have our queue members logged in, it is inevitable that they will want to pause themselves during breaks, and other short periods of inactivity. To do this we can utilize the 'queue pause' and 'queue unpause' CLI commands. We have two devices logged into the sales queue as we can see with the 'queue show sales' CLI command.
*CLI> queue show sales sales has 0 calls (max unlimited) talktime), W:0, C:0, A:0, SL:0.0% within Members: SIP/0004f2040002 (dynamic) (Not in SIP/0004f2040001 (dynamic) (Not in No Callers
in 'rrmemory' strategy (0s holdtime, 0s 0s use) has taken no calls yet use) has taken no calls yet
We can then pause our devices with 'queue pause' which has the following format.
Usage: queue {pause|unpause} member <member> [queue <queue> [reason <reason>]] Pause or unpause a queue member. Not specifying a particular queue will pause or unpause a member across all queues to which the member belongs.
Lets pause device 0004f2040001 in the sales queue by executing the following.
*CLI> queue pause member SIP/0004f2040001 queue sales paused interface 'SIP/0004f2040001' in queue 'sales' for reason 'lunch'
And we can see they are paused with 'queue show sales'.
*CLI> queue show sales sales has 0 calls (max unlimited) in 'rrmemory' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s Members: SIP/0004f2040002 (dynamic) (Not in use) has taken no calls yet SIP/0004f2040001 (dynamic) (paused) (Not in use) has taken no calls yet No Callers
At this point the queue member will no longer receive calls from the system. We can unpause them with the CLI command 'queue unpause member'.
*CLI> queue unpause member SIP/0004f2040001 queue sales unpaused interface 'SIP/0004f2040001' in queue 'sales'
And if you don't specify a queue, it will pause or unpause from all queues.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
448
extensions.conf --------------; Allow queue members to pause and unpause themselves from all queues, or an individual queue. ; ; _*0[01]! pattern match will match on *00 and *01 plus 0 or more digits. exten => _*0[01]!,1,Verbose(2,Pausing or unpausing queue member from one or more queues) exten => _*0[01]!,n,Set(xtn=${EXTEN:3}) ; save the queue extension to 'xtn' exten => _*0[01]!,n,Set(thisQueue=${GLOBAL(QUEUE_${xtn})}) ; get the queue name if available exten => _*0[01]!,n,GotoIf($[${ISNULL(${thisQueue})} & ${EXISTS(${xtn})}]?invalid_queue,1) ; if 'thisQueue' is blank and the ; ; the agent dialed a queue exten, we will tell them it's invalid
The following line will determine if we're trying to pause or unpause. This is done by taking the value dialed (e.g. *00100) and chopping off the first 2 digits which leaves us with 0100, and then the :1 will return the next digit, which in this case is '0' that we're using to signify that the queue member wants to be paused (in queue 100). So we're doing the following with our EXTEN variable.
offset
${EXTEN:2:1} ^ ^ length
*00100 ^^ *00100 ^
; ;
The following two extensions, pause & unpause, are used for pausing and unpausing our extension from the queue(s). We use the PauseQueueMember() and UnpauseQueueMember() dialplan applications which accept the queue name (optional) and the queue member name. If the queue name is not
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
449
provided, then it is assumed we want to pause or unpause from all logged in queues.
; Unpause ourselves from one or more queues exten => unpause,1,NoOp() exten => unpause,n,UnpauseQueueMember(${thisQueue},SIP/${CHANNEL(peername)}) if 'thisQueue' is populated we'll pause in that queue, otherwise, we'll unpause in
; ; ;
in all queues
Once we've unpaused ourselves, we use GoSub() to perform some common dialplan logic that is used for pausing and unpausing. We pass three arguments to the subroutine:
variable name that contains the result of our operation the value we're expecting to get back if successful the filename to play
exten => unpause,n,GoSub(changePauseStatus,start,1(UPQMSTATUS,UNPAUSED,available)) use the changePauseStatus subroutine and pass the values for: variable to check,
; ; ;
; Pause ourselves in one or more queues exten => pause,1,NoOp() exten => pause,n,PauseQueueMember(${thisQueue},SIP/${CHANNEL(peername)}) exten => pause,n,GoSub(changePauseStatus,start,1(PQMSTATUS,PAUSED,unavailable)) exten => pause,n,Hangup()
Lets explore what happens in the subroutine we're using for pausing and unpausing.
; ### Subroutine we use to check pausing and unpausing status ### [changePauseStatus] ; ARG1: variable name to check, such as PQMSTATUS and UPQMSTATUS (PauseQueueMemberStatus / UnpauseQueueMemberStatus) ; ARG2: value to check for, such as PAUSED or UNPAUSED ; ARG3: file to play back if our variable value matched the value to check for ; exten => start,1,NoOp() exten => start,n,Playback(silence/1) ; answer line with silence
The following line is probably the most complex. We're using the IF() function inside the Playback() application which determines which file to playback to the user. Those three values we passed in from the pause and unpause extensions could have been something like:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
450
$["${PQMSTATUS}" = "PAUSED"]?unavailable:not-yet-connected
${PQMSTATUS} would then be expanded further to contain the status of our PauseQueueMember() dialplan application, which could either be PAUSED or NOTFOUND. So if ${PQMSTATUS} returned PAUSED, then it would match what we're looking to match on, and we'd then return 'unavailable' to Playback() that would tell the user they are now unavailable. Otherwise, we'd get back a message saying "not yet connected" to indicate they are likely not logged into the queue they are attempting to change status in.
; Please note that ${ARG1} is wrapped in ${ } in order to expand the value of ${ARG1} into ; the variable we want to retrieve the value from, i.e. ${${ARG1}} turns into ${PQMSTATUS} exten => start,n,Playback(${IF($["${${ARG1}}" = "${ARG2}"]?${ARG3}:not-yet-connected)}) ; check if value of variable ; ; ; matches the value we're looking for and playback the file we want to play if it does
If ${xtn} is null, then we just go to the end of the subroutine, but if it isn't then we will play back "in the queue" followed by the queue extension number indicating which queue they were (un)paused from.
exten => start,n,GotoIf($[${ISNULL(${xtn})}]?end) Return() exten => start,n,Playback(in-the-queue) "in the queue" exten => start,n,SayNumber(${xtn}) (un)paused from exten => start,n(end),Return()
; if ${xtn} is null, then just ; ; if not null, then playback and the queue number that we
Conclusion You should now have a simple system that permits you to login and out of queues you create in queues.conf, and to allow queue members to pause themselves within one or more queues. There are a lot of dialplan concepts utilized in this article, so you are encouraged to seek out additional documentation if any of these concepts are a bit fuzzy for you. A good start is the doc/ subdirectory of the Asterisk sources, or the various configuration samples files located in the configs/ subdirectory of your Asterisk source code.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
451
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
452
Call Queues
Template holder while we wait for input on a good README for call queues. Please open a bug report and add text to this document General advice on the agent channel Using dynamic queue members SIP channel configuration Queues depend on the channel driver reporting the proper state for each member of the queue. To get proper signalling on queue members that use the SIP channel driver, you need to enable a call limit (could be set to a high value so it is not put into action) and also make sure that both inbound and outbound calls are accounted for. Example:
Other references
queuelog.txt queues-with-callback-members.txt
(Should we merge those documents into this?)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
453
Channel Drivers
placeholder page to store the various channel driver subpages
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
454
Corosync
Corosync Corosync is an open source group messaging system typically used in clusters, cloud computing, and other high availability environments. The project, at it's core, provides four C api features:
A closed process group communication model with virtual synchrony guarantees for creating replicated state machines. A simple availability manager that restarts the application process when it has failed. A configuration and statistics in-memory database that provide the ability to set, retrieve, and receive change notifications of information. A quorum system that notifies applications when quorum is achieved or lost.
Corosync and Asterisk Using Corosync together with res_corosync allows events to be shared amongst a local cluster of Asterisk servers. Specifically, the types of events that may be shared include:
Device state Message Waiting Indication, or MWI (to allow voicemail to live on a server that is different from where the phones are registered)
Setup and Configuration Corosync Installation
Debian / Ubuntu
apt-get install corosync corosync-dev
Authkey
To create an authentication key for secure communications between your nodes you need to do this on, what will be, the active node.
corosync-keygen
Now, on the standby node, you'll need to stick the authkey in it's new home and fix it's permissions / ownership.
asterisk_standby:~# mv ~/authkey /etc/corosync/authkey asterisk_standby:~# chown root:root /etc/corosync/authkey asterisk_standby:~# chmod 400 /etc/corosync/authkey
/etc/corosync/corosync.conf
The interface section under the totem block defines the communication path(s) to the other Corosync processes running on nodes within the cluster. These can be either IPv4 or IPv6 ip addresses but can not be mixed and matched within an interface. Adjustments can be made to the cluster settings based on your needs and installation environment.
IPv4 Active Node Example
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
455
totem { version: 2 token: 160 token_retransmits_before_loss_const: 3 join: 30 consensus: 300 vsftype: none max_messages: 20 threads: 0 nodeid: 1 rrp_mode: none interface { ringnumber: 0 bindnetaddr: 192.168.1.0 mcastaddr: 226.94.1.1 mcastport: 5405 } }
Start Corosync
service corosync start
Asterisk Installation
/etc/asterisk/res_corosync.conf
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
456
; ; ; ; ; ; ; ; ; ; ; ; ; ;
Sample configuration file for res_corosync. This module allows events to be shared amongst a local cluster of Asterisk servers. Specifically, the types of events that may be shared include: - Device State (for shared presence information) - Message Waiting Indication, or MWI (to allow Voicemail to live on a server that is different from where the phones are registered) For more information about Corosync, see: http://www.corosync.org/
[general] ; ; Publish Message Waiting Indication (MWI) events from this server to the ; cluster. publish_event = mwi ; ; Subscribe to MWI events from the cluster. subscribe_event = mwi ; ; Publish Device State (presence) events from this server to the cluster. publish_event = device_state ; ; Subscribe to Device State (presence) events from the cluster. subscribe_event = device_state ;
In the general section of the res_corosync.conf file we are specifying which events we'd like to publish and subscribe to (at the moment this is either device_state or mwi).
Verifying Installation
If everything is setup correctly, you should see this output after executing a 'corosync show members' on the Asterisk CLI.
*CLI> corosync show members ============================================================= === Cluster members ========================================= ============================================================= === === Node 1 === --> Group: asterisk === --> Address 1: <host #1 ip goes here> === =============================================================
After starting Corosync and Asterisk on your second node, the 'corosync show members' output should look something like this:
*CLI> corosync show members ============================================================= === Cluster members ========================================= ============================================================= === === Node 1 === --> Group: asterisk === --> Address 1: <host #1 ip goes here> === Node 2 === --> Group: asterisk === --> Address 1: <host #2 ip goes here> === =============================================================
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
457
Database Transactions
As of 1.6.2, Asterisk now supports doing database transactions from the Dialplan. A number of new applications and functions have been introduced for this purpose and this document should hopefully familiarize you with all of them. First, the ODBC() function has been added which is used to set up all new database transactions. Simply write the name of the transaction to this function, along with the arguments of "transaction" and the database name, e.g. Set(ODBC(transaction,postgres-asterisk)=foo). In this example, the name of the transaction is "foo". The name doesn't really matter, unless you're manipulating multiple transactions within the same dialplan, at the same time. Then, you use the transaction name to change which transaction is active for the next dialplan function. The ODBC() function is also used to turn on a mode known as forcecommit. For most cases, you won't need to use this, but it's there. It simply causes a transaction to be committed, when the channel hangs up. The other property which may be set is the isolation property. Please consult with your database vendor as to which values are supported by their ODBC driver. Asterisk supports setting all standard ODBC values, but many databases do not support the entire complement. Finally, when you have run multiple statements on your transaction and you wish to complete the transaction, use the ODBC_Commit and ODBC_Rollback applications, along with the transaction ID (in the example above, "foo") to commit or rollback the transaction. Please note that if you do not explicitly commit the transaction or if forcecommit is not turned on, the transaction will be automatically rolled back at channel destruction (after hangup) and all related database resources released back to the pool.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
458
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
459
1. Introduction
Various changes have been made related to "event handling" in Asterisk. One of the most important things included in these changes is the ability to share certain events between servers. The two types of events that can currently be shared between servers are:
1. MWI - Message Waiting Indication - This gives you a high performance option for letting servers in a cluster be aware of changes in the state of a mailbox. Instead of having each server have to poll an ODBC database, this lets the server that actually made the change to the mailbox generate an event which will get distributed to the other servers that have subscribed to this information. 2. Device State - This lets servers in a local cluster inform each other about changes in the state of a device on that particular server. When the state of a device changes on any server, the overall state of that device across the cluster will get recalculated. So, any subscriptions to the state of a device, such as hints in the dialplan or an application like Queue() which reads device state, will then reflect the state of a device across a cluster.
2. OpenAIS Installation
Description The current solution for providing distributed events with Asterisk is done by using the AIS (Application Interface Specification), which provides an API for a distributed event service. While this API is standardized, this code has been developed exclusively against the open source implementation of AIS called OpenAIS. For more information about OpenAIS, visit their web site http://www.openais.org/. Install Dependencies
$ $ $ $ $
3. OpenAIS Configuration
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
460
Basic OpenAIS configuration to get this working is actually pretty easy. Start by copying in a sample configuration file for Corosync and OpenAIS.
$ sudo mkdir -p /etc/ais $ cd openais-1.1.4 $ sudo cp conf/openais.conf.sample /etc/ais/openais.conf
The only section that you should need to change is the totem - interface section.
/etc/ais/openais.conf
totem { ... interface { ringnumber: 0 bindnetaddr: 10.24.22.144 mcastaddr: 226.94.1.1 mcastport: 5405 } }
The default mcastaddr and mcastport is probably fine. You need to change the bindnetaddr to match the address of the network interface that this node will use to communicate with other nodes in the cluster. Now, edit /etc/corosync/corosync.conf, as well. The same change will need to be made to the totem-interface section in that file.
4. Running OpenAIS
While testing, I recommend starting the aisexec application in the foreground so that you can see debug messages that verify that the nodes have discovered each other and joined the cluster.
$ sudo aisexec -f
For example, here is some sample output from the first server after starting aisexec on the second server:
Nov Nov Nov Nov Nov Nov Nov Nov Nov 13 13 13 13 13 13 13 13 13 06:55:30 06:55:30 06:55:30 06:55:30 06:55:30 06:55:30 06:55:30 06:55:30 06:55:30 corosync corosync corosync corosync corosync corosync corosync corosync corosync [CLM [CLM [CLM [CLM [CLM [CLM [CLM [TOTEM [MAIN ] ] ] ] ] ] ] ] ] CLM CONFIGURATION CHANGE New Configuration: r(0) ip(10.24.22.144) r(0) ip(10.24.22.242) Members Left: Members Joined: r(0) ip(10.24.22.242) A processor joined or left the membership and a new membership was formed. Completed service synchronization, ready to provide service.
5. Installing Asterisk
Install Asterisk as usual. Just make sure that you run the configure script after OpenAIS gets installed. That way, it will find the AIS header files and will let you build the res_ais module. Check menuselect to make sure that res_ais is going to get compiled and installed.
$ cd asterisk-source $ ./configure $ make menuselect ---> Resource Modules
If you have existing configuration on the system being used for testing, just be sure to install the addition configuration file needed for res_ais.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
461
6. Configuring Asterisk
First, ensure that you have a unique "entity ID" set for each server.
*CLI> core show settings ... Entity ID:
01:23:45:67:89:ab
The code will attempt to generate a unique entity ID for you by reading MAC addresses off of a network interface. However, you can also set it manually in the [options] section of asterisk.conf.
$ sudo ${EDITOR:-vim} /etc/asterisk/asterisk.conf
asterisk.conf
[options] entity_id=01:23:45:67:89:ab
Edit the Asterisk ais.conf to enable distributed events. For example, if you would like to enable distributed device state, you should add the following section to the file:
$ sudo ${EDITOR:-vim} /etc/asterisk/ais.conf
/etc/asterisk/ais.conf
[device_state] type=event_channel publish_event=device_state subscribe_event=device_state
For more information on the contents and available options in this configuration file, please see the sample configuration file:
$ cd asterisk-source $ less configs/ais.conf.sample
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
462
*CLI> ais clm show members ============================================================= === Cluster Members ========================================= ============================================================= === === --------------------------------------------------------=== Node Name: 10.24.22.144 === ==> ID: 0x9016180a === ==> Address: 10.24.22.144 === ==> Member: Yes === --------------------------------------------------------=== === --------------------------------------------------------=== Node Name: 10.24.22.242 === ==> ID: 0xf216180a === ==> Address: 10.24.22.242 === ==> Member: Yes === --------------------------------------------------------=== =============================================================
If you're having trouble getting the nodes of the cluster to see each other, make sure you do not have firewall rules that are blocking the multicast traffic that is used to communicate amongst the nodes.
The next thing to do is to verify that you have successfully configured some event channels in the Asterisk ais.conf file. This command is related to the event service (EVT), so like the previous command, uses the syntax: ais <service name> <command>.
*CLI> ais evt show event channels ============================================================= === Event Channels ========================================== ============================================================= === === --------------------------------------------------------=== Event Channel Name: device_state === ==> Publishing Event Type: device_state === ==> Subscribing to Event Type: device_state === --------------------------------------------------------=== =============================================================
/etc/asterisk/extensions.conf
[devstate_test] exten => 1234,hint,Custom:mystate
Now, you can test that the cluster-wide state of "Custom:mystate" is what you would expect after going to the CLI of each server and adjusting the state.
server1*CLI> dialplan set global DEVICE_STATE(Custom:mystate) NOT_INUSE ... server2*CLI> dialplan set global DEVICE_STATE(Custom:mystate) INUSE ...
Various combinations of setting and checking the state on different servers can be used to verify that it works as expected. Also, you can see the status of the hint on each server, as well, to see how extension state would reflect the state change with distributed device state:
server2*CLI> core show hints -= Registered Asterisk Dial Plan Hints =1234@devstate_test : Custom:mystate
State:InUse
Watchers
One other helpful thing here during testing and debugging is to enable debug logging. To do so, enable debug on the console in /etc/asterisk/logger.conf.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
463
When you have this debug enabled, you will see output during the processing of every device state change. The important thing to look for is where the known state of the device for each server is added together to determine the overall state.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
464
1. Introduction
This document describes installing and utilizing XMPP PubSub events to distribute device state and message waiting indication (MWI) events between servers. The difference between this method and OpenAIS (see Distributed Device State with AIS) is that OpenAIS can only be used in low latency networks; meaning only on the LAN, and not across the internet. If you plan on distributing device state or MWI across the internet, then you will require the use of XMPP PubSub events.
2. Tigase Installation
Description Currently the only server supported for XMPP PubSub events is the Tigase open source XMPP/Jabber environment. This is the server that the various Asterisk servers will connect to in order to distribute the events. The Tigase server can even be clustered in order to provide high availability for your device state; however, that is beyond the scope of this document. For more information about Tigase, visit their web site http://www.tigase.org/. Download To download the Tigase environment, get the latest version at http://www.tigase.org/content/tigase-downloads. Some distributions have Tigase packaged, as well. Install The Tigase server requires a working Java environment, including both a JRE (Java Runtime Environment) and a JDK (Java Development Kit), currently at least version 1.6. For more information about how to install Tigase, see the web site http://www.tigase.org/content/quick-start.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
465
# keytool -genkey -alias yourdomain -keystore rsa-keystore -keyalg RSA -sigalg MD5withRSA
The keytool application will then ask you for a password. Use the password 'keystore' as this is the default password that Tigase will use to load the keystore file. You then need to specify your domain as the first value to be entered in the security certificate.
What is your first and last name? [Unknown]: asterisk.mydomain.tld What is the name of your organizational unit? [Unknown]: What is the name of your organization? [Unknown]: What is the name of your City or Locality? [Unknown]: What is the name of your State or Province? [Unknown]: What is the two-letter country code for this unit? [Unknown]: Is CN=asterisk.mydomain.tld, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct? [no]: yes
You will then be asked for another password, in which case you must just press enter for the same password as Tigase will not work without them being the same.
Enter key password for <mykey> (RETURN if same as keystore password):
Configuring init.properties The next step is to configure the init.properties file which is used by Tigase to generate the tigase.xml file. Whenever you change the init.properties file because sure to remove the current tigase.xml file so that it will be regenerated at start up.
# cd /opt/Tigase-4.3.1-b1858/etc
Be sure to change the domain in the --admin and --virt-hosts options. The most important lines are --comp-name-1 and --comp-class-1 which tell Tigase to load the PubSub module.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
466
[email protected]/astvoip1 [email protected]/astvoip2
3. Installing Asterisk
Install Asterisk as usual. However, you'll need to make sure you have the res_jabber module compiled, which requires the iksemel development library. Additionally, be sure you have the OpenSSL development library installed so you can connect securly to the Tigase server. Make sure you check menuselect that res_jabber is selected so that it will compile.
# cd asterisk-source # ./configure # make menuselect ---> Resource Modules
If you don't have jabber.conf in your existing configuration, because sure to copy the sample configuration file there.
# cd configs # cp jabber.conf.sample /etc/asterisk/jabber.conf
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
467
jabber.conf on server1
[general] debug=no ;autoprune=yes your for a test) ;;you might lose your contacts list. Default is 'no'. autoregister=yes ;collection_nodes=yes ;pubsub_autocreate=yes using ;;Auto register users from buddy list. ;;Enable support for XEP-0248 for use with ;;distributed device state. Default is 'no'. ;;Whether or not the PubSub server supports/is ;;auto-create for nodes. If it is, we have to ;;explicitly pre-create nodes before publishing them. ;;Default is 'no'. [asterisk] type=client serverhost=asterisk.mydomain.tld pubsub_node=pubsub.asterisk.mydomain.tld [email protected]/astvoip1 secret=welcome distribute_events=yes status=available usetls=no usesasl=yes [email protected]/astvoip2
Asterisk Server 2
;;Turn on debugging by default. ;;Auto remove users from buddy list. Depending on ;;setup (ie, using your personal Gtalk account
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
468
jabber.conf on server2
[general] debug=yes ;;Turn on debugging by default. ;autoprune=yes ;;Auto remove users from buddy list. Depending on your ;;setup (ie, using your personal Gtalk account for a test) ;;you might lose your contacts list. Default is 'no'. autoregister=yes ;;Auto register users from buddy list. ;collection_nodes=yes ;;Enable support for XEP-0248 for use with ;;distributed device state. Default is 'no'. ;pubsub_autocreate=yes ;;Whether or not the PubSub server supports/is using ;;auto-create for nodes. If it is, we have to ;;explicitly pre-create nodes before publishing them. ;;Default is 'no'. [asterisk] type=client serverhost=asterisk.mydomain.tld pubsub_node=pubsub.asterisk.mydomain.tld [email protected]/astvoip2 secret=welcome distribute_events=yes status=available usetls=no usesasl=yes [email protected]/astvoip1
- Connected
The command above has given us output which verifies we've connected our first server. We can then check the state of our buddies with the 'jabber show buddies' CLI command.
*CLI> jabber show buddies Jabber buddy lists Client: [email protected]/astvoip1 Buddy: [email protected] Resource: None Buddy: [email protected]/astvoip2 Resource: None
The output above tells us we're not connected to any buddies, and thus we're not distributing state to anyone (or getting it from anyone). That makes sense since we haven't yet started our other server. Now, let's start the other server and verify the servers are able to establish a connection between each other. On Asterisk 2, again we run the 'jabber show connected' command to make sure we've connected successfully to the XMPP server.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
469
- Connected
Excellent! So we're connected to the buddy on Asterisk 1, and we could run the same command on Asterisk 1 to verify the buddy on Asterisk 2 is seen.
Now, you can test that the cluster-wide state of "Custom:mystate" is what you would expect after going to the CLI of each server and adjusting the state.
server1*CLI> console dial set_inuse@devstate_test ... server2*CLI> console dial check@devstate_test -- Executing [check@devstate_test:1] NoOp("OSS/dsp", "Custom:mystate is INUSE") in new stack
Various combinations of setting and checking the state on different servers can be used to verify that it works as expected. Also, you can see the status of the hint on each server, as well, to see how extension state would reflect the state change with distributed device state:
server2*CLI> core show hints -= Registered Asterisk Dial Plan Hints =1234@devstate_test : Custom:mystate
State:InUse
Watchers
One other helpful thing here during testing and debugging is to enable debug logging. To do so, enable debug on the console in /etc/asterisk/logger.conf. Also, enable debug at the Asterisk CLI.
*CLI> core set debug 1
When you have this debug enabled, you will see output during the processing of every device state change. The important thing to look for is where the known state of the device for each server is added together to determine the overall state.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
470
One method for making this slightly easier is to utilize the #exec functionality in configuration files, and dynamically generate the buddies via script that pulls the information from a database, or to #include a file which is automatically generated on all the servers when you add a new node to the cluster. Unfortunately this still requires a reload of res_jabber.so on all the servers, but this could also be solved through the use of the Asterisk Manager Interface (AMI). So while this is not the ideal situation, it is programmatically solvable with existing technologies and features found in Asterisk today.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
471
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
472
(a) The term "DUNDi" means the DUNDi protocol as published by Digium, Inc. or its successor in interest with respect to the DUNDi protocol specification. (b) The terms "E.164" and "E164" mean ITU-T specification E.164 as published by the International Telecommunications Union (ITU) in May, 1997. (c) The term "Service" refers to any communication facility (e.g., telephone, fax, modem, etc.), identified by an E.164-compatible number, and assigned by the appropriate authority in that jurisdiction. (d) The term "Egress Gateway" refers an Internet facility that provides a communications path to a Service or Services that may not be directly addressable via the Internet. (e) The term "Route" refers to an Internet address, policies, and other characteristics defined by the DUNDi protocol and associated with the Service, or the Egress Gateway which provides access to the specified Service. (f) The term "Propagate" means to accept or transmit Service and/or Egress Gateway Routes only using the DUNDi protocol and the DUNDi context "e164" without regard to case, and does not apply to the exchange of information using any other protocol or context.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
473
(g) The term "Peering System" means the network of systems that Propagate Routes. (h) The term "Subscriber" means the owner of, or someone who contracts to receive, the services identified by an E.164 number. (i) The term "Authorizing Individual" means the Subscriber to a number who has authorized a Participant to provide Routes regarding their services via this Peering System. (j) The term "Route Authority" refers to a Participant that provides an original source of said Route within the Peering System. Routes are propagated from the Route Authorities through the Peering System and may be cached at intermediate points. There may be multiple Route Authorities for any Service. (k) The term "Participant" (introduced above) refers to any member of the Peering System. (l) The term "Service Provider" refers to the carrier (e.g., exchange carrier, Internet Telephony Service Provider, or other reseller) that provides communication facilities for a particular Service to a Subscriber, Customer or other End User. (m) The term "Weight" refers to a numeric quality assigned to a Route as per the DUNDi protocol specification. The current Weight definitions are shown in Exhibit A. 1. PEERING. The undersigned Participants agree to Propagate Routes with each other and any other member of the Peering System and further agree not to Propagate DUNDi Routes with a third party unless they have first have executed this GPA (in its unmodified form) with such third party. The Participants further agree only to Propagate Routes with Participants whom they reasonably believe to be honoring the terms of the GPA. Participants may not insert, remove, amend, or otherwise modify any of the terms of the GPA. 2. ACCEPTABLE USE POLICY. The DUNDi protocol contains information that reflect a Subscriber's or Egress Gateway's decisions to receive calls. In addition to the terms and conditions set forth in this GPA, the Participants agree to honor the intent of restrictions encoded in the DUNDi protocol. To that end, Participants agree to the following: (a) A Participant may not utilize or permit the utilization of Routes for which the Subscriber or Egress Gateway provider has indicated that they do not wish to receive "Unsolicited Calls" for the purpose of making an unsolicited phone call on behalf of any party or organization. (b) A Participant may not utilize or permit the utilization of Routes which have indicated that they do not wish to receive "Unsolicited Commercial Calls" for the purpose of making an unsolicited phone call on behalf of a commercial organization. (c) A Participant may never utilize or permit the utilization of any DUNDi route for the purpose of making harassing phone calls. (d) A Party may not utilize or permit the utilization of DUNDi provided Routes for any systematic or random calling of numbers (e.g., for the purpose of locating facsimile, modem services, or systematic telemarketing). (e) Initial control signaling for all communication sessions that utilize Routes obtained from the Peering System must be sent from a member of the Peering System to the Service or Egress Gateway identified in the selected Route. For example, 'SIP INVITES' and IAX2 "NEW" commands must be sent from the requesting DUNDi node to the terminating Service. (f) A Participant may not disclose any specific Route, Service or Participant contact information obtained from the Peering System to any party outside of the Peering System except as a by-product of facilitating communication in accordance with section 2e (e.g., phone books or other databases may not be published, but the Internet addresses of the Egress Gateway or Service does not need to be obfuscated.) (g) The DUNDi Protocol requires that each Participant include valid contact information about itself (including information about nodes connected to each Participant). Participants may use or disclose the contact information only to ensure enforcement of legal furtherance of this Agreement. 3. ROUTES. The Participants shall only propagate valid Routes, as defined herein, through the Peering System, regardless of the original source. The Participants may only provide Routes as set forth below, and then only if such Participant has no good faith reason to believe
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
474
such Route to be invalid or unauthorized. (a) A Participant may provide Routes if each Route has as its original source another member of the Peering System who has duly executed the GPA and such Routes are provided in accordance with this Agreement; provided that the Routes are not modified (e.g., with regards to existence, destination, technology or Weight); or (b) A Participant may provide Routes for Services with any Weight for which it is the Subscriber; or (c) A Participant may provide Routes for those Services whose Subscriber has authorized the Participant to do so, provided that the Participant is able to confirm that the Authorizing Individual is the Subscriber through: i. a written statement of ownership from the Authorizing Individual, which the Participant believes in good faith to be accurate (e.g., a phone bill with the name of the Authorizing Individual and the number in question); or ii. the Participant's own direct personal knowledge that the Authorizing Individual is the Subscriber. (d) A Participant may provide Routes for Services, with Weight in accordance with the Current DUNDi Specification, if it can in good faith provide an Egress Gateway to that Service on the traditional telephone network without cost to the calling party. 4. REVOCATION. A Participant must provide a free, easily accessible mechanism by which a Subscriber may revoke permission to act as a Route Authority for his Service. A Participant must stop acting as a Route Authority for that Service within 7 days after: (a) receipt of a revocation request; (b) receiving other notice that the Service is no longer valid; or (c) determination that the Subscriber's information is no longer accurate (including that the Subscriber is no longer the service owner or the service owner's authorized delegate). 5. SERVICE FEES. A Participant may charge a fee to act as a Route Authority for a Service, with any Weight, provided that no Participant may charge a fee to propagate the Route received through the Peering System. 6. TOLL SERVICES. No Participant may provide Routes for any Services that require payment from the calling party or their customer for communication with the Service. Nothing in this section shall prohibit a Participant from providing routes for Services where the calling party may later enter into a financial transaction with the called party (e.g., a Participant may provide Routes for calling cards services). 7. QUALITY. A Participant may not intentionally impair communication using a Route provided to the Peering System (e.g. by adding delay, advertisements, reduced quality). If for any reason a Participant is unable to deliver a call via a Route provided to the Peering System, that Participant shall return out-of-band Network Congestion notification (e.g. "503 Service Unavailable" with SIP protocol or "CONGESTION" with IAX protocol). 8. PROTOCOL COMPLIANCE. Participants agree to Propagate Routes in strict compliance with current DUNDi protocol specifications. 9. ADMINISTRATIVE FEES. A Participant may charge (but is not required to charge) another Participant a reasonable fee to cover administrative expenses incurred in the execution of this Agreement. A Participant may not charge any fee to continue the relationship or to provide Routes to another Participant in the Peering System. 10. CALLER IDENTIFICATION. A Participant will make a good faith effort to ensure the accuracy and appropriate nature of any caller identification that it transmits via any Route obtained from the Peering System. Caller identification shall at least be provided as a valid E.164 number. 11. COMPLIANCE WITH LAWS. The Participants are solely responsible for determining to what extent, if any, the obligations set forth in this GPA conflict with any laws or regulations their region. A Participant may not provide any service or otherwise use DUNDi under this GPA if doing so is prohibited by law or regulation, or if any law or regulation imposes requirements on the Participant that are inconsistent with the terms of this GPA or the Acceptable Use Policy. 12. WARRANTY. EACH PARTICIPANT WARRANTS TO THE OTHER PARTICIPANTS THAT IT MADE, AND WILL CONTINUE TO MAKE, A GOOD FAITH EFFORT TO AUTHENTICATE OTHERS IN THE PEERING SYSTEM AND TO PROVIDE ACCURATE INFORMATION IN
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
475
ACCORDANCE WITH THE TERMS OF THIS GPA. THIS WARRANTY IS MADE BETWEEN THE PARTICIPANTS, AND THE PARTICIPANTS MAY NOT EXTEND THIS WARRANTY TO ANY NON-PARTICIPANT INCLUDING END-USERS. 13. DISCLAIMER OF WARRANTIES. THE PARTICIPANTS UNDERSTAND AND AGREE THAT ANY SERVICE PROVIDED AS A RESULT OF THIS GPA IS "AS IS." EXCEPT FOR THOSE WARRANTIES OTHERWISE EXPRESSLY SET FORTH HEREIN, THE PARTICIPANTS DISCLAIM ANY REPRESENTATIONS OR WARRANTIES OF ANY KIND OR NATURE, EXPRESS OR IMPLIED, AS TO THE CONDITION, VALUE OR QUALITIES OF THE SERVICES PROVIDED HEREUNDER, AND SPECIFICALLY DISCLAIM ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY, SUITABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR AS TO THE CONDITION OR WORKMANSHIP THEREOF, OR THE ABSENCE OF ANY DEFECTS THEREIN, WHETHER LATENT OR PATENT, INCLUDING ANY WARRANTIES ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. EXCEPT AS EXPRESSLY PROVIDED HEREIN, THE PARTICIPANTS EXPRESSLY DISCLAIM ANY REPRESENTATIONS OR WARRANTIES THAT THE PEERING SERVICE WILL BE CONTINUOUS, UNINTERRUPTED OR ERROR-FREE, THAT ANY DATA SHARED OR OTHERWISE MADE AVAILABLE WILL BE ACCURATE OR COMPLETE OR OTHERWISE COMPLETELY SECURE FROM UNAUTHORIZED ACCESS. 14. LIMITATION OF LIABILITIES. NO PARTICIPANT SHALL BE LIABLE TO ANY OTHER PARTICIPANT FOR INCIDENTAL, INDIRECT, CONSEQUENTIAL, SPECIAL, PUNITIVE OR EXEMPLARY DAMAGES OF ANY KIND (INCLUDING LOST REVENUES OR PROFITS, LOSS OF BUSINESS OR LOSS OF DATA) IN ANY WAY RELATED TO THIS GPA, WHETHER IN CONTRACT OR IN TORT, REGARDLESS OF WHETHER SUCH PARTICIPANT WAS ADVISED OF THE POSSIBILITY THEREOF. 15. END-USER AGREEMENTS. The Participants may independently enter into agreements with end-users to provide certain services (e.g., fees to a Subscriber to originate Routes for that Service). To the extent that provision of these services employs the Peering System, the Parties will include in their agreements with their end-users terms and conditions consistent with the terms of this GPA with respect to the exclusion of warranties, limitation of liability and Acceptable Use Policy. In no event may a Participant extend the warranty described in Section 12 in this GPA to any end-users. 16. INDEMNIFICATION. Each Participant agrees to defend, indemnify and hold harmless the other Participant or third-party beneficiaries to this GPA (including their affiliates, successors, assigns, agents and representatives and their respective officers, directors and employees) from and against any and all actions, suits, proceedings, investigations, demands, claims, judgments, liabilities, obligations, liens, losses, damages, expenses (including, without limitation, attorneys' fees) and any other fees arising out of or relating to (i) personal injury or property damage caused by that Participant, its employees, agents, servants, or other representatives; (ii) any act or omission by the Participant, its employees, agents, servants or other representatives, including, but not limited to, unauthorized representations or warranties made by the Participant; or (iii) any breach by the Participant of any of the terms or conditions of this GPA. 17. THIRD PARTY BENEFICIARIES. This GPA is intended to benefit those Participants who have executed the GPA and who are in the Peering System. It is the intent of the Parties to this GPA to give to those Participants who are in the Peering System standing to bring any necessary legal action to enforce the terms of this GPA. 18. TERMINATION. Any Participant may terminate this GPA at any time, with or without cause. A Participant that terminates must immediately cease to Propagate. 19. CHOICE OF LAW. This GPA and the rights and duties of the Parties hereto shall be construed and determined in accordance with the internal laws of the State of New York, United States of America, without regard to its conflict of laws principles and without application of the United Nations Convention on Contracts for the International Sale of Goods. 20. DISPUTE RESOLUTION. Unless exclusive procedure for handling Notwithstanding such procedures, injunctive relief in addition to otherwise agreed in writing, the disputes shall be as set forth herein. any Participant may, at any time, seek the process described below.
(a) Prior to mediation or arbitration the disputing Participants shall seek informal resolution of disputes. The process shall be initiated with written notice of one Participant to the other describing the dispute with reasonable particularity followed with a written response within ten (10) days of receipt of notice. Each Participant shall promptly designate an executive with requisite authority to resolve the dispute. The informal procedure shall commence within ten (10) days of the date of response. All reasonable requests for non-privileged information reasonably related to the dispute shall be honored. If the dispute is not resolved within thirty (30) days of commencement of the procedure either Participant may proceed to mediation or arbitration pursuant to the rules set forth in (b) or (c) below. (b) If the dispute has not been resolved pursuant to (a) above or, if the disputing Participants fail to commence informal dispute
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
476
resolution pursuant to (a) above, either Participant may, in writing and within twenty (20) days of the response date noted in (a) above, ask the other Participant to participate in a one (1) day mediation with an impartial mediator, and the other Participant shall do so. Each Participant will bear its own expenses and an equal share of the fees of the mediator. If the mediation is not successful the Participants may proceed with arbitration pursuant to (c) below. (c) If the dispute has not been resolved pursuant to (a) or (b) above, the dispute shall be promptly referred, no later than one (1) year from the date of original notice and subject to applicable statute of limitations, to binding arbitration in accordance with the UNCITRAL Arbitration Rules in effect on the date of this contract. The appointing authority shall be the International Centre for Dispute Resolution. The case shall be administered by the International Centre for Dispute Resolution under its Procedures for Cases under the UNCITRAL Arbitration Rules. Each Participant shall bear its own expenses and shall share equally in fees of the arbitrator. All arbitrators shall have substantial experience in information technology and/or in the telecommunications business and shall be selected by the disputing participants in accordance with UNCITRAL Arbitration Rules. If any arbitrator, once selected is unable or unwilling to continue for any reason, replacement shall be filled via the process described above and a re-hearing shall be conducted. The disputing Participants will provide each other with all requested documents and records reasonably related to the dispute in a manner that will minimize the expense and inconvenience of both parties. Discovery will not include depositions or interrogatories except as the arbitrators expressly allow upon a showing of need. If disputes arise concerning discovery requests, the arbitrators shall have sole and complete discretion to resolve the disputes. The parties and arbitrator shall be guided in resolving discovery disputes by the Federal Rules of Civil Procedure. The Participants agree that time of the essence principles shall guide the hearing and that the arbitrator shall have the right and authority to issue monetary sanctions in the event of unreasonable delay. The arbitrator shall deliver a written opinion setting forth findings of fact and the rationale for the award within thirty (30) days following conclusion of the hearing. The award of the arbitrator, which may include legal and equitable relief, but which may not include punitive damages, will be final and binding upon the disputing Participants, and judgment may be entered upon it in accordance with applicable law in any court having jurisdiction thereof. In addition to award the arbitrator shall have the discretion to award the prevailing Participant all or part of its attorneys' fees and costs, including fees associated with arbitrator, if the arbitrator determines that the positions taken by the other Participant on material issues of the dispute were without substantial foundation. Any conflict between the UNCITRAL Arbitration Rules and the provisions of this GPA shall be controlled by this GPA. 21. INTEGRATED AGREEMENT. This GPA, constitutes the complete integrated agreement between the parties concerning the subject matter hereof. All prior and contemporaneous agreements, understandings, negotiations or representations, whether oral or in writing, relating to the subject matter of this GPA are superseded and canceled in their entirety. 22. WAIVER. No waiver of any of the provisions of this GPA shall be deemed or shall constitute a waiver of any other provision of this GPA, whether or not similar, nor shall such waiver constitute a continuing waiver unless otherwise expressly so provided in writing. The failure of either party to enforce at any time any of the provisions of this GPA, or the failure to require at any time performance by either party of any of the provisions of this GPA, shall in no way be construed to be a present or future waiver of such provisions, nor in any way affect the ability of a Participant to enforce each and every such provision thereafter. 23. INDEPENDENT CONTRACTORS. Nothing in this GPA shall make the Parties partners, joint venturers, or otherwise associated in or with the business of the other. Parties are, and shall always remain, independent contractors. No Participant shall be liable for any debts, accounts, obligations, or other liabilities of the other Participant, its agents or employees. No party is authorized to incur debts or other obligations of any kind on the part of or as agent for the other. This GPA is not a franchise agreement and does not create a franchise relationship between the parties, and if any provision of this GPA is deemed to create a franchise between the parties, then this GPA shall automatically terminate. 24. CAPTIONS AND HEADINGS. The captions and headings used in this GPA are used for convenience only and are not to be given any legal effect. 25. EXECUTION. This GPA may be executed in counterparts, each of which
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
477
so executed will be deemed to be an original and such counterparts together will constitute one and the same Agreement. The Parties shall transmit to each other a signed copy of the GPA by any means that faithfully reproduces the GPA along with the Signature. For purposes of this GPA, the term "signature" shall include digital signatures as defined by the jurisdiction of the Participant signing the GPA. Exhibit A Weight Range 0-99 100-199 Requirements May only be used under authorization of Owner May only be used by the Owner's service provider, regardless of authorization. Reserved -- do not use for e164 context. May only be used by the owner of the code under which the Owner's number is a part of. May be used by any entity providing access via direct connectivity to the Public Switched Telephone Network. May be used by any entity providing access via indirect connectivity to the Public Switched Telephone Network (e.g. Via another VoIP provider) Reserved-- do not use for e164 context. Participant Company: Address: Email: Participant
200-299 300-399
400-499
500-599
600-
END OF GENERAL PEERING AGREEMENT -----------------------------------------------How to Peer using this GPA If you wish to exchange routing information with parties using the e164 DUNDi context, all you must do is execute this GPA with any member of the Peering System and you will become a member of the Peering System and be able to make Routes available in
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
478
accordance with this GPA. DUNDi, IAX, Asterisk and GPA are trademarks of Digium, Inc.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
479
ExternalIVR(/full/path/to/applcation[(arguments)],options)
The arguments are optional, however if they exist they must be enclosed in parentheses. The external application will be executed in a child process, with its standard file handles connected to the Asterisk process as follows:
stdin (0) - Events will be received on this handle stdout (1) - Commands can be sent on this handle stderr (2) - Messages can be sent on this handle
Use of stderr for message communication is discouraged because it is not supported by a socket connection.
ExternalIVR(ivr://host[:port][(arguments)],options)
The host can be a fully qualified domain name or an IP address (both IPv4 and IPv6 are supported). The port is optional and, if not specified, is 2949 by default. The ExternalIVR application will connect to the specified socket server and establish a bidirectional socket connection, where events will be sent to the TCP/IP server and commands received from it. The specific ExternalIVR options, #events and #commands are detailed below. Upon execution, if not specifically prevented by an option, the ExternalIVR application will answer the channel (if it's not already answered), create an audio generator, and start playing silence. When your application wants to send audio to the channel, it can send a command to add a file to the generator's playlist. The generator will then work its way through the list, playing each file in turn until it either runs out of files to play, the channel is hung up, or a command is received to clear the list and start with a new file. At any time, more files can be added to the list and the generator will play them in sequence. While the generator is playing audio (or silence), any DTMF #events received on the channel will be sent to the child process. Note that this can happen at any time, since the generator, the child process and the channel thread are all executing independently. It is very important that your external application be ready to receive events from Asterisk at all times (without blocking), or you could cause the channel to become non-responsive. If the child process dies, or the remote server disconnects, ExternalIVR will notice this and hang up the channel immediately (and also send a message to the log). ExternalIVR Options
n - 'n'oanswer, don't answer an otherwise unanswered channel. i - 'i'gnore_hangup, instead of sending an H event and exiting ExternalIVR upon channel hangup, it instead sends an I event and expects the external application to exit the process. d - 'd'ead, allows the operation of ExternalIVR on channels that have already been hung up.
Events All events are be newline-terminated strings and are sent in the following format:
tag,timestamp[,data]
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
480
0-9 - DTMF event for keys 0 through 9 A-D - DTMF event for keys A through D * - DTMF event for key * # - DTMF event for key # H - The channel was hung up by the connected party E - The script requested an exit Z - The previous command was unable to be executed. There may be a data element if appropriate, see specific commands below for details T - The play list was interrupted (see S command) D - A file was dropped from the play list due to interruption (the data element will be the dropped file name) NOTE: this tag conflicts with the D DTMF event tag. The existence of the data element is used to differentiate between the two cases F - A file has finished playing (the data element will be the file name) P - A response to the P command G - A response to the G command I - A Inform message, meant to "inform" the client that something has occurred. (see Inform Messages below)
The timestamp will be a decimal representation of the standard Unix epoch-based timestamp, e.g., 284654100.
Commands All commands are newline-terminated (\n) strings. The child process can send one of the following commands:
S,filename A,filename I,TIMESTAMP H,message E,message O,option V,name=value[,name=value[,name=value]] G,name[,name[,name]] L,log_message P,TIMESTAMP T,TIMESTAMP
The S command checks to see if there is a playable audio file with the specified name, and if so, clears the generator's playlist and places the file onto the list. Note that the playability check does not take into account transcoding requirements, so it is possible for the file to not be played even though it was found. If the file does not exist it sends a Z response with the data element set to the file requested. If the generator is not currently playing silence, then T and D events will be sent to signal the playlist interruption and notify it of the files that will not be played. The A command checks to see if there is a playable audio file with the specified name, and if so, appends it to the generator's playlist. The same playability and exception rules apply as for the S command. The I command stops any audio currently playing and clears the generator's playlist. The I command was added in Asterisk 11. The E command logs the supplied message to the Asterisk log, stops the generator and terminates the ExternalIVR application, but continues execution in the dialplan. The H command logs the supplied message to the Asterisk log, stops the generator, hangs up the channel and terminates the ExternalIVR application. The O command allows the child to set/clear options in the ExternalIVR() application. The supported options are:
(no)autoclear - Automatically interrupt and clear the playlist upon reception of DTMF input.
The T command will answer an unanswered channel. If it fails either answering the channel or starting the generator it sends a Z response of Z,TIMESTAM P,ANSWER_FAILED or Z,TIMESTAMP,GENERATOR_FAILED respectively. The V command sets the specified channel variable(s) to the specified value(s). The G command gets the specified channel variable(s). Multiple variables are separated by commas. Response is in name=value format. The P command gets the parameters passed into ExternalIVR minus the options to ExternalIVR itself:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
481
ExternalIVR(/usr/bin/foo(arg1,arg2),n)
The response to the P command would be:
P,TIMESTAMP,/usr/bin/foo,arg1,arg2
This is the only way for a TCP/IP server to be able to get retrieve the arguments.
This is preferred to using stderr and is the only way for a TCP/IP server to log a message.
Inform Messages The only inform message that currently exists is a HANGUP message, in the form I,TIMESTAMP,HANGUP and is used to inform of a hangup when the i opt ion is specified. Errors Any newline-terminated (\n) output generated by the child process on its stderr handle will be copied into the Asterisk log.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
482
Followme - Realtime
Followme is now realtime-enabled. To use, you must define two backend data structures, with the following fields:
followme: name
musicclass OR musiconhold OR music context takecall declinecall call_from_prompt norecording_prompt options_prompt hold_prompt status_prompt sorry_prompt
Name of this followme entry. Specified when invoking the FollowMe application in the dialplan. This field is the only one which is mandatory. All of the other fields will inherit the default from followme.conf, if not specified in this data resource. The musiconhold class used for the caller while waiting to be connected. Dialplan context from which to dial numbers DTMF used to accept the call and be connected. For obvious reasons, this needs to be a single digit, '*', or '#'. DTMF used to refuse the call, sending it onto the next step, if any. Prompt to play to the callee, announcing the call. The alternate prompt to play to the callee, when the caller refuses to leave a name (or the option isn't set to allow them). Normally, "press 1 to accept, 2 to decline". Message played to the caller while dialing the followme steps. Normally, "Party is not at their desk". Normally, "Unable to locate party".
Name of this followme entry. Must match the name above. An integer, specifying the order in which these numbers will be followed. The telephone number(s) you would like to call, separated by '&'. Timeout associated with this step. See the followme documentation for more information on how this value is handled.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
483
IAX2 Security
IAX2 Security
Copyright (c) 2009 - Digium, Inc. All Rights Reserved. Document Version 1.0 09/03/09 Asterisk Development Team <[email protected]>
1 Introduction 1.1 Overview 2 User Guide 2.1 Configuration 2.1.1 Quick Start 2.1.2 Controlled Networks 2.1.2.1 Full Upgrade 2.1.2.2 Partial Upgrade 2.1.3 Public Networks 2.1.3.1 Full Upgrade 2.1.3.2 Partial Upgrade 2.1.3.3 Guest Access 2.2 CLI Commands 2.2.1 iax2 show callnumber usage 2.2.2 iax2 show peer 3 Protocol Modification 3.1 Overview 3.2 Call Token Validation 3.3 Example Message Exchanges 3.3.1 Call Setup 3.3.2 Call Setup, client does not support CALLTOKEN 3.3.3 Call Setup, client supports CALLTOKEN, server does not 3.3.4 Call Setup from client that sends invalid token 4 Asterisk Implementation 4.1 CALLTOKEN IE Payload
Introduction
Overview
A change has been made to the IAX2 protocol to help mitigate denial of service attacks. This change is referred to as call token validation. This change affects how messages are exchanged and is not backwards compatible for an older client connecting to an updated server, so a number of options have been provided to disable call token validation as needed for compatibility purposes. In addition to call token validation, Asterisk can now also limit the number of connections allowed per IP address to disallow one host from preventing other hosts from making successful connections. These options are referred to as call number limits. For additional details about the configuration options referenced in this document, see the sample configuration file, iax.conf.sample. For information regarding the details of the call token validation protocol modification, see #Protocol Modification.
User Guide
Configuration Quick Start
We strongly recommend that administrators leave the IAX2 security enhancements in place where possible. However, to bypass the security enhancements completely and have Asterisk work exactly as it did before, the following options can be specified in the [general] section of iax.conf:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
484
iax.conf
[general] ... calltokenoptional = 0.0.0.0/0.0.0.0 maxcallnumbers = 16382 ...
Controlled Networks
This section discusses what needs to be done for an Asterisk server on a network where no unsolicited traffic will reach the IAX2 service. Full Upgrade If all IAX2 endpoints have been upgraded, then no changes to configuration need to be made. Partial Upgrade If only some of the IAX2 endpoints have been upgraded, then some configuration changes will need to be made for interoperability. Since this is for a controlled network, the easiest thing to do is to disable call token validation completely, as described under #Quick Start.
Public Networks
This section discusses the use of the IAX2 security functionality on public networks where it is possible to receive unsolicited IAX2 traffic. Full Upgrade If all IAX2 endpoints have been upgraded to support call token validation, then no changes need to be made. However, for enhanced security, the administrator may adjust call number limits to further reduce the potential impact of malicious call number consumption. The following configuration will allow known peers to consume more call numbers than unknown source IP addresses:
iax.conf
[general] ; By default, restrict call number usage to a low number. maxcallnumbers = 16 ... [callnumberlimits] ; For peers with known IP addresses, call number limits can ; be set in this section. This limit is per IP address for ; addresses that fall in the specified range. ; <IP>/<mask> = <limit> 192.168.1.0/255.255.255.0 = 1024 ... [peerA] ; Since we won't know the IP address of a dynamic peer until ; they register, a max call number limit can be set in a ; dynamic peer configuration section. type = peer host = dynamic maxcallnumbers = 1024 ...
Partial Upgrade
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
485
If only some IAX2 endpoints have been upgraded, or the status of an IAX2 endpoint is unknown, then call token validation must be disabled to ensure interoperability. To reduce the potential impact of disabling call token validation, it should only be disabled for a specific peer or user as needed. By using the auto option, call token validation will be changed to required as soon as we determine that the peer supports it.
iax.conf
[friendA] requirecalltoken = auto ...
Note that there are some cases where auto should not be used. For example, if multiple peers use the same authentication details, and they have not all upgraded to support call token validation, then the ones that do not support it will get locked out. Once an upgraded client successfully completes an authenticated call setup using call token validation, Asterisk will require it from then on. In that case, it would be better to set the requirecalltoken option to no. Guest Access Guest access via IAX2 requires special attention. Given the number of existing IAX2 endpoints that do not support call token validation, most systems that allow guest access should do so without requiring call token validation.
iax.conf
[guest] ; Note that the name "guest" is special here. When the code ; tries to determine if call token validation is required, it ; will look for a user by the username specified in the ; request. Guest calls can be sent without a username. In ; that case, we will look for a defined user called "guest" to ; determine if call token validation is required or not. type = user requirecalltoken = no ...
Since disabling call token validation for the guest account allows a huge hole for malicious call number consumption, an option has been provided to segregate the call numbers consumed by connections not using call token validation from those that do. That way, there are resources dedicated to the more secure connections to ensure that service is not interrupted for them.
iax.conf
[general] maxcallnumbers_nonvalidated = 2048 ...
Protocol Modification
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
486
This section discusses the modification that has been made to the IAX2 protocol. This information would be most useful to implementors of IAX2.
Overview
The IAX2 protocol uses a call number to associate messages with which call they belong to. The available amount of call numbers is finite as defined by the protocol. Because of this, it is important to prevent attackers from maliciously consuming call numbers. To achieve this, an enhancement to the IAX2 protocol has been made which is referred to as call token validation. Call token validation ensures that an IAX2 connection is not coming from a spoofed IP address. In addition to using call token validation, Asterisk will also limit how many call numbers may be consumed by a given remote IP address. These limits have defaults that will usually not need to be changed, but can be modified for a specific need. The combination of call token validation and call number limits is used to mitigate a denial of service attack to consume all available IAX2 call numbers. An alternative approach to securing IAX2 would be to use a security layer on top of IAX2, such as DTLS RFC 4347 or IPsec RFC 4301.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
487
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
488
Asterisk Implementation
This section includes some additional details on the implementation of these changes in Asterisk.
CALLTOKEN IE Payload
For Asterisk, we will encode the payload of the CALLTOKEN IE such that the server is able to validate a received token without having to store any information after transmitting the CALLTOKEN response. The CALLTOKEN IE payload will contain:
A timestamp (epoch based) SHA1 hash of the remote IP address and port, the timestamp, as well some random data generated when Asterisk starts.
When a CALLTOKEN IE is received, its validity will be determined by recalculating the SHA1 hash. If it is a valid token, the timestamp is checked to determine if the token is expired. The token timeout will be hard coded at 10 seconds for now. However, it may be made configurable at some point if it seems to be a useful addition. If the server determines that a received token is expired, it will treat it as an invalid token and not respond to the request. By using this method, we require no additional memory to be allocated for a dialog, other than what is on the stack for processing the initial request, until token validation is complete. However, one thing to note with this CALLTOKEN IE encoding is that a token would be considered valid by Asterisk every time a client sent it until we considered it an expired token. However, with use of the "maxcallnumbers" option, this is not actually a problem. It just means that an attacker could hit their call number limit a bit quicker since they would only have to acquire a single token per timeout period, instead of a token per request.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
489
To use static realtime with certain core configuration files the realtime backend you wish to use must be preloaded in modules.conf.
cd contrib/scripts sudo cp asterisk.ldap-schema /etc/ldap/schema/ sudo service slapd restart sudo ldapadd -Y EXTERNAL -H ldapi:/// -f ./asterisk.ldif
Let's edit the extconfig.conf file to specify LDAP as our realtime storage engine and where Asterisk will look for data.
You'll want to reference the Asterisk res_ldap.conf file which holds the LDAP mapping configuration when building your own record schema.
Basic sip users record layout which will need to be saved to a file (we'll use 'createduser.ldif' here as an example). This example record is for sip user '1000'. This example record is for sip user '1000'.
dn: cn=1000,ou=sip,dc=digium,dc=internal objectClass: AsteriskAccount objectClass: AsteriskExtension objectClass: AsteriskSIPUser objectClass: top AstAccountName: sip user cn: 1000 AstAccountDefaultUser: 0 AstAccountExpirationTimestamp: 0 AstAccountFullContact: 0 AstAccountHost: dynamic AstAccountIPAddress: 0 AstAccountLastQualifyMilliseconds: 0 AstAccountPort: 0 AstAccountRegistrationServer: 0 AstAccountType: 0 AstAccountUserAgent: 0 AstExtension: 1000
Let's add the record to the LDAP server:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
490
When creating your own record schema, you'll obviously want to incorporate authentication. Asterisk + LDAP requires that the user secrets be stored as an MD5 hash. MD5 hashes can be created using 'md5sum'. For AstAccountRealmedPassword authentication use this.
printf "<secret composed of username, realm, and password goes here>" | md5sum
For AstMD5secret authentication use this.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
491
1 Introduction This document provides instructions on how to build and configure Asterisk V1.6 with the OSP Toolkit to enable secure, multi-lateral peering. This document is also available in the Asterisk source package as doc/osp.txt. The OSP Toolkit is an open source implementation of the OSP peering protocol and is freely available from https://sourceforge.net/projects/osp-toolkit. The OSP standard defined by the European Telecommunications Standards Institute (ETSI TS 101 321) www.etsi.org. If you have questions or need help, building Asterisk with the OSP Toolkit, please post your question on the OSP mailing list at https://lists.sourceforge.net/lists/listinfo/osp-toolkit-client.
2 OSP Toolkit Please reference the OSP Toolkit document "How to Build and Test the OSP Toolkit available from https://sourceforge.net/projects/osp-toolkit.
2.1 Build OSP Toolkit The software listed below is required to build and use the OSP Toolkit:
OpenSSL (required for building) - Open Source SSL protocol and Cryptographic Algorithms (version 0.9.7g recommended) from www.openssl.org. Pre-compiled OpenSSL binary packages are not recommended because of the binary compatibility issue.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
492
Perl (required for building) - A programming language used by OpenSSL for compilation. Any version of Perl should work. One version of Perl is available from www.activestate.com/Products/ActivePer. If pre-compiled OpenSSL packages are used, Perl package is not required. C compiler (required for building) - Any C compiler should work. The GNU Compiler Collection from www.gnu.org is routinely used for building the OSP Toolkit for testing. OSP Server (required for testing) - Access to any OSP server should work. An open source reference OSP server developed by Cisco System is available at http://www.vovida.org/applications/downloads/openosp/. RAMS, a java based open source OSP server is available at https://sourceforge.net/projects/rams. A free version of the TransNexus commercial OSP server may be downloaded from http://www.tr ansnexus.com/OSP%20Toolkit/Peering_Server/VoIP_Peering_Server.htm.
2.1.1 Unpacking the Toolkit After downloading the OSP Toolkit (version 3.3.6 or later release) from www.sourceforge.net, perform the following steps in order:
Copy the OSP Toolkit distribution into the directory where it will reside. The default directory for the OSP Toolkit is /usr/src.
*Un-package the distribution file by executing the following command:
cd TK-3_3_6-20060303
Within this directory, you will find directories and files similar to what is listed below if the command "ls -F" is executed):
ls -F enroll/ RelNotes.txt lib/ README.txt license.txt bin/ src/ crypto/ test/ include/
Compile OpenSSL according to the instructions provided with the OpenSSL distribution (You would need to do this only if you dont have openssl already). Copy the OpenSSL header files (the *.h files) into the crypto/openssl directory within the osptoolkit directory. The OpenSSL header files are located under the openssl/include/openssl directory. Copy the OpenSSL library files (libcrypto.a and libssl.a) into the lib directory within the osptoolkit directory. The OpenSSL library files are located under the openssl directory. Note: Since the Asterisk requires the OpenSSL package. If the OpenSSL package has been installed, steps 4 through 6 are not necessary. Optionally, change the install directory of the OSP Toolkit. Open the Makefile in the /usr/src/TK-3_3_6-20060303/src directory, look for the install path variable INSTALL_PATH, and edit it to be anywhere you want (defaults /usr/local). Note: Please change the install path variable only if you are familiar with both the OSP Toolkit and the Asterisk.
From within the OSP Toolkit directory (/usr/src/TK-3_3_6-20060303), start the compilation script by executing the following commands:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
493
2.1.4 Installing the OSP Toolkit The header files and the library of the OSP Toolkit should be installed. Otherwise, you must specify the OSP Toolkit path for the Asterisk.
make install
The make script is also used to install the OSP Toolkit header files and the library into the INSTALL_PATH specified in the Makefile.
Please make sure you have the rights to access the INSTALL_PATH directory. For example, in order to access /usr/local directory, root privileges are required.
2.1.5 Building the Enrollment Utility Device enrollment is the process of establishing a trusted cryptographic relationship between the VoIP device and the OSP Server. The Enroll program is a utility application for establishing a trusted relationship between an OSP client and an OSP server. Please see the document "Device Enrollment" at http://w ww.transnexus.com/OSP%20Toolkit/OSP%20Toolkit%20Documents/Device_Enrollment.pdf for more information about the enroll application.
From within the OSP Toolkit directory (example: /usr/src/TK-3_3_6-20060303), execute the following commands at the command prompt:
2.2 Obtain Crypto Files The OSP module in Asterisk requires three crypto files containing a local certificate (localcert.pem), private key (pkey.pem), and CA certificate (cacert_0.pem). Asterisk will try to load the files from the Asterisk public/private key directory - /var/lib/asterisk/keys. If the files are not present, the OSP module will not start and the Asterisk will not support the OSP protocol. Use the enroll.sh script from the toolkit distribution to enroll Asterisk with an OSP server and obtain the crypto files. Documentation explaining how to use the enroll.sh script (Device Enrollment) to enroll with an OSP server is available at http://www.transnexus.com/OSP%20Toolkit/OSP%20Toolkit%20Documents/Device_Enrollment.pdf. Copy the files generated by the enrollment process to the Asterisk /var/lib/asterisk/keys directory.
The osptestserver.transnexus.com is configured only for sending and receiving non-SSL messages, and issuing signed tokens. If you need help, post a message on the OSP mailing list at https://lists.sourceforge.net/lists/listinfo/osp-toolkit-client
The enroll.sh script takes the domain name or IP addresses of the OSP servers that the OSP Toolkit needs to enroll with as arguments, and then generates pem files cacert_#.pem, certreq.pem, localcert.pem, and pkey.pem. The # in the cacert file name is used to differentiate the ca certificate file names for the various SPs (OSP servers). If only one address is provided at the command line, cacert_0.pem will be generated. If 2 addresses are provided at the command line, 2 files will be generated cacert_0.pem and cacert_1.pem, one for each SP (OSP server). The example below shows the usage when the client is registering with osptestserver.transnexus.com.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
494
./enroll.sh osptestserver.transnexus.com Generating a 512 bit RSA private key ........................++++++++++++ .........++++++++++++ writing new private key to 'pkey.pem' ----You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----Country Name (2 letter code) [AU]: _______ State or Province Name (full name) [Some-State]: _______ Locality Name (eg, city) []:_______ Organization Name (eg, company) [Internet Widgits Pty Ltd]: _______ Organizational Unit Name (eg, section) []:_______ Common Name (eg, YOUR name) []:_______ Email Address []:_______ Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []:_______ An optional company name []:_______ Error Code returned from openssl command : 0 CA certificate received [SP: osptestserver.transnexus.com]Error Code returned from getcacert command : 0 output buffer after operation: operation=request output buffer after nonce: operation=request&nonce=1655976791184458 X509 CertInfo context is null pointer Unable to get Local Certificate depth=0 /CN=osptestserver.transnexus.com/O=OSPServer verify error:num=18:self signed certificate verify return:1 depth=0 /CN=osptestserver.transnexus.com/O=OSPServer verify return:1 The certificate request was successful. Error Code returned from localcert command : 0
The files generated should be copied to the /var/lib/asterisk/keys directory.
The script enroll.sh requires AT&T korn shell (ksh) or any of its compatible variants. The /usr/src/TK-3_3_6-20060303/bin directory should be in the PATH variable. Otherwise, enroll.sh cannot find the enroll file.
3 Asterisk In Asterisk, all OSP support is implemented as dial plan functions. In Asterisk V1.6, all combinations of routing between OSP and non-OSP enabled networks using any combination of SIP, H.323 and IAX protocols are fully supported. Section 3.1 describes the three easy steps to add OSP support to Asterisk:
1. Build Asterisk with OSP Toolkit 2. Configure osp.conf file 3. Cut and paste to extensions.conf
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
495
Sections 3.2 and 3.3 provide a detailed explanation of OSP dial plan functions and configuration examples. The detailed information provided in Sections 3.2 and 3.3 is not required for operating Asterisk with OSP, but may be helpful to developers who want to customize their Asterisk OSP implementation.
3.1.1 Build Asterisk with OSP Toolkit The first step is to build Asterisk with the OSP Toolkit. If the OSP Toolkit is installed in the default install directory, /usr/local, no additional configuration is required. Compile Asterisk according to the instructions provided with the Asterisk distribution. If the OSP Toolkit is installed in another directory, such as /myosp, Asterisk must be configured with the location of the OSP Toolkit. See the example below.
--with-osptk=/myosp
Please change the install path only if you familiar with both the OSP Toolkit and the Asterisk. Otherwise, the change may result in Asterisk not supporting the OSP protocol.
3.1.2 osp.conf The /etc/asterisk/osp.conf file, shown below, contains configuration parameters for using OSP. Two parameters, servicepoint and source must be configured. The default values for all other parameters will work well for standard OSP implementations.
; ; Open Settlement Protocol Sample Configuration File ; ; This file contains configuration of OSP server providers that ; are used by the Asterisk OSP module. The section "general" is ; reserved for global options. All other sections describe specific ; OSP Providers. The provider "default" is used when no provider is ; otherwise specified. : : The "servicepoint" and "source" parameters must be configured. For ; most implementations the other parameters in this file can be left ; unchanged. ; [general] ; ; Enable cryptographic acceleration hardware. ; accelerate=no ; ; Defines the status of tokens that Asterisk will validate. ; 0 - signed tokens only ; 1 - unsigned tokens only ; 2 - both signed and unsigned ; The default value is 0, i.e. the Asterisk will only validate signed ; tokens. ; tokenformat=0 ; [default] ; ; List all service points (OSP servers) for this provider. Use ; either domain name or IP address. Most OSP servers use port 5045. ;
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
496
;servicepoint=http://osptestserver.transnexus.com:5045/osp servicepoint=http://OSP server IP:5045/osp ; ; Define the "source" device for requesting OSP authorization. : This value is usually the domain name or IP address of the : the Asterisk server. ; ;source=domain name or [IP address in brackets] source=[host IP] ; ; Define path and file name of crypto files. ; The default path for crypto file is /var/lib/asterisk/keys. If no ; path is defined, crypto files should be in ; /var/lib/asterisk/keys directory. ; ; Specify the private key file name. ; If this parameter is unspecified or not present, the default name ; will be the osp.conf section name followed by "-privatekey.pem" ; (for example: default-privatekey.pem) ; privatekey=pkey.pem ; ; Specify the local certificate file. ; If this parameter is unspecified or not present, the default name ; will be the osp.conf section name followed by "- localcert.pem " ; (for example: default-localcert.pem) ; localcert=localcert.pem ; ; Specify one or more Certificate Authority key file names. If none ; are listed, a single Certificate Authority key file name is added ; with the default name of the osp.conf section name followed by ; "-cacert_0.pem " (for example: default-cacert_0.pem) ; cacert=cacert_0.pem ; ; Configure parameters for OSP communication between Asterisk OSP ; client and OSP servers. ; ; maxconnections: Max number of simultaneous connections to the ; provider OSP server (default=20) ; retrydelay: Extra delay between retries (default=0) ; retrylimit: Max number of retries before giving up (default=2) ; timeout: Timeout for response in milliseconds (default=500) ; maxconnections=20 retrydelay=0 retrylimit=2 timeout=500 ; ; Set the authentication policy. ; 0 - NO - Accept all calls. ; 1 YES - Accept calls with valid token or no token. ; Block calls with invalid token. ; 2 EXCLUSIVE Accept calls with valid token. ; Block calls with invalid token or no token. ; Default is 1, ; authpolicy=1
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
497
; ; Set the default destination protocol. The OSP module supports ; SIP, H323, and IAX protocols. The default protocol is set to SIP.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
498
; defaultprotocol=SIP
3.1.3 extensions.conf OSP functions are implemented as dial plan functions in the extensions.conf file. To add OSP support to your Asterisk server, simply copy and paste the text box below to your extensions.conf file. These functions will enable your Asterisk server to support all OSP call scenarios. Configuration of your Asterisk server for OSP is now complete.
[globals] DIALOUT=DAHDI/1 [SrcGW] ; OSP Source Gateway exten => _XXXX.,1,NoOp(OSPSrcGW) ; Set calling number if necessary exten => _XXXX.,n,Set(CALLERID(numner)=1234567890) ; OSP lookup using default provider, if fail/error jump to lookup+101 exten => _XXXX.,n(lookup),OSPLookup(${EXTEN}||j) ; Deal with outbound call according to protocol exten => _XXXX.,n,Macro(outbound) ; Dial to destination, 60 timeout, with call duration limit exten => _XXXX.,n,Dial(${OSPDIALSTR},60,oL($[${OSPOUTTIMELIMIT}*1000])) ; Wait 1 second exten => _XXXX.,n,Wait,1 ; Hangup exten => _XXXX.,n,Hangup ; Deal with OSPLookup fail/error exten => _XXXX.,lookup+101,Hangup exten => h,1,NoOp() ; OSP report usage exten => h,n,OSPFinish(${HANGUPCAUSE}) [DstGW] ; OSP Destination Gateway exten => _XXXX.,1,NoOp(OSPDstGW) ; Deal with inbound call according to protocol exten => _XXXX.,n,Macro(inbound) ; Validate token using default provider, if fail/error jump to auth+101 exten => _XXXX.,n(auth),OSPAuth(|j) ; Ringing exten => _XXXX.,n,Ringing ; Wait 1 second exten => _XXXX.,n,Wait,1 ; Check inbound call duration limit exten => _XXXX.,n,GoToIf($[${OSPINTIMELIMIT}=0]?100:200) ; Without duration limit exten => _XXXX.,100,Dial(${DIALOUT},15,o) exten => _XXXX.,n,Goto(1000) ; With duration limit exten => _XXXX.,200,Dial(${DIALOUT},15,oL($[${OSPINTIMELIMIT}*1000])) exten => _XXXX.,n,Goto(1000) ; Wait 1 second exten => _XXXX.,1000,Wait,1 ; Hangup exten => _XXXX.,n,Hangup ; Deal with OSPAuth fail/error exten => _XXXX.,auth+101,Hangup exten => h,1,NoOp()
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
499
; OSP report usage exten => h,n,OSPFinish(${HANGUPCAUSE}) [GeneralProxy] ; Proxy exten => _XXXX.,1,NoOp(OSP-GeneralProxy) ; Deal with inbound call according to protocol exten => _XXXX.,n,Macro(inbound) ; Validate token using default provider, if fail/error jump to auth+101 exten => _XXXX.,n(auth),OSPAuth(|j) ; OSP lookup using default provider, if fail/error jump to lookup+101 exten => _XXXX.,n(lookup),OSPLookup(${EXTEN}||j) ; Deal with outbound call according to protocol exten => _XXXX.,n,Macro(outbound) ; Dial to destination, 14 timeout, with call duration limit exten => _XXXX.,n,Dial(${OSPDIALSTR},14,oL($[${OSPOUTTIMELIMIT}*1000])) ; OSP lookup next destination using default provider, if fail/error jump to next1+101 exten => _XXXX.,n(next1),OSPNext(${HANGUPCAUSE}||j) ; Deal with outbound call according to protocol exten => _XXXX.,n,Macro(outbound) ; Dial to destination, 15 timeout, with call duration limit exten => _XXXX.,n,Dial(${OSPDIALSTR},15,oL($[${OSPOUTTIMELIMIT}*1000])) ; OSP lookup next destination using default provider, if fail/error jump to next2+101 exten => _XXXX.,n(next2),OSPNext(${HANGUPCAUSE}||j) ; Deal with outbound call according to protocol exten => _XXXX.,n,Macro(outbound) ; Dial to destination, 16 timeout, with call duration limit exten => _XXXX.,n,Dial(${OSPDIALSTR},16,oL($[${OSPOUTTIMELIMIT}*1000])) ; Hangup exten => _XXXX.,n,Hangup ; Deal with OSPAuth fail/error exten => _XXXX.,auth+101,Hangup ; Deal with OSPLookup fail/error exten => _XXXX.,lookup+101,Hangup ; Deal with OSPNext fail/error exten => _XXXX.,next1+101,Hangup ; Deal with OSPNext fail/error exten => _XXXX.,next2+101,Hangup exten => h,1,NoOp() ; OSP report usage exten => h,n,OSPFinish(${HANGUPCAUSE}) [macro-inbound] exten => s,1,NoOp(inbound) ; Get inbound protocol exten => s,n,Set(CHANTECH=${CUT(CHANNEL,/,1)}) exten => s,n,GoToIf($["${CHANTECH}"="H323"]?100) exten => s,n,GoToIf($["${CHANTECH}"="IAX2"]?200) exten => s,n,GoToIf($["${CHANTECH}"="SIP"]?300) exten => s,n,GoTo(1000) ; H323 -------------------------------------------------------; Get peer IP exten => s,100,Set(OSPPEERIP=${H323CHANINFO(peerip)}) ; Get OSP token exten => s,n,Set(OSPINTOKEN=${H323CHANINFO(osptoken)}) exten => s,n,GoTo(1000) ; IAX ---------------------------------------------------------; Get peer IP exten => s,200,Set(OSPPEERIP=${IAXPEER(CURRENTCHANNEL)}) ; Get OSP token
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
500
exten => s,n,Set(OSPINTOKEN=${IAXCHANINFO(osptoken)}) exten => s,n,GoTo(1000) ; SIP ---------------------------------------------------------; Get peer IP exten => s,300,Set(OSPPEERIP=${SIPCHANINFO(peerip)}) ; Get OSP token exten => s,n,Set(OSPINTOKEN=${SIP_HEADER(P-OSP-Auth-Token)}) exten => s,n,GoTo(1000) ; -------------------------------------------------------------exten => s,1000,MacroExit [macro-outbound] exten => s,1,NoOp(outbound) ; Set calling number which may be translated exten => s,n,Set(CALLERID(num)=${OSPCALLING}) ; Check destinatio protocol exten => s,n,GoToIf($["${OSPTECH}"="H323"]?100) exten => s,n,GoToIf($["${OSPTECH}"="IAX2"]?200) exten => s,n,GoToIf($["${OSPTECH}"="SIP"]?300) ; Something wrong exten => s,n,Hangup exten => s,n,GoTo(1000) ; H323 -------------------------------------------------------; Set call id exten => s,100,Set(H323CHANINFO(callid)=${OSPOUTCALLID}) ; Set OSP token exten => s,n,Set(H323CHANINFO(osptoken)=${OSPOUTTOKEN}) exten => s,n,GoTo(1000) ; IAX ---------------------------------------------------------; Set OSP token exten => s,200,Set(IAXCHANINFO(osptoken)=${OSPOUTTOKEN}) exten => s,n,GoTo(1000) ; SIP ---------------------------------------------------------exten => s,300,GoTo(1000)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
501
3.2 OSP Dial Plan Functions This section provides a description of each OSP dial plan function.
OSPPEERIP: last hop IP address OSPINTOKEN: inbound OSP token provider: OSP service provider configured in osp.conf. If it is empty, default provider is used. priority jump
Output:
OSPINHANDLE: inbound OSP transaction handle OSPINTIMELIMIT: inbound call duration limit OSPAUTHSTATUS: OSPAuth return value. SUCCESS/FAILED/ERROR
OSPPEERIP: last hop IP address OSPINHANDLE: inbound OSP transaction handle OSPINTIMELIMIT: inbound call duration limit exten: called number provider: OSP service provider configured in osp.conf. If it is empty, default provider is used. priority jump callidtypes: Generate call ID for the outbound call. h: H.323; s: SIP; i: IAX. Only h, H.323, has been implemented.
Output:
OSPOUTHANDLE: outbound transaction handle OSPTECH: outbound protocol OSPDEST: outbound destination IP address OSPCALLED: outbound called nummber OSPCALLING: outbound calling number OSPOUTTOKEN: outbound OSP token OSPRESULTS: number of remaining destinations OSPOUTTIMELIMIT: outbound call duration limit OSPOUTCALLIDTYPES: same as input callidtypes OSPOUTCALLID: outbound call ID. Only for H.323 OSPDIALSTR: outbound dial string OSPLOOKUPSTATUS: OSPLookup return value. SUCCESS/FAILED/ERROR
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
502
OSPINHANDLE: inbound transaction handle OSPOUTHANDLE: outbound transaction handle OSPINTIMELIMIT: inbound call duration limit OSPOUTCALLIDTYPES: types of call ID generated by Asterisk. OSPRESULTS: number of remain destinations cause: last destination disconnect cause priority jump
Output:
OSPTECH: outbound protocol OSPDEST: outbound destination IP address OSPCALLED: outbound called number OSPCALLING: outbound calling number OSPOUTTOKEN: outbound OSP token OSPRESULTS: number of remain destinations OSPOUTTIMELIMIT: outbound call duration limit OSPOUTCALLID: outbound call ID. Only for H.323 OSPDIALSTR: outbound dial string OSPNEXTSTATUS: OSPLookup return value. SUCCESS/FAILED/ERROR
OSPINHANDLE: inbound transaction handle OSPOUTHANDLE: outbound transaction handle OSPAUTHSTATUS: OSPAuth return value OSPLOOKUPTSTATUS: OSPLookup return value OSPNEXTSTATUS: OSPNext return value cause: last destination disconnect cause priority jump
Output:
3.3 extensions.conf Examples The extensions.conf file example provided in Section 3.1 is designed to handle all OSP call scenarios when Asterisk is used as a source or destination gateway to the PSTN or as a proxy between VoIP networks. The extenstion.conf examples in this section are designed for specific use cases only.
3.3.1 Source Gateway The examples in this section apply when the Asterisk server is being used as a TDM to VoIP gateway. Calls originate on the TDM network and are converted to VoIP by Asterisk. In these cases, the Asterisk server queries an OSP server to find a route to a VoIP destination. When the call ends, Asterisk sends a CDR to the OSP server. For SIP protocol.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
503
[SIPSrcGW] exten => _XXXX.,1,NoOp(SIPSrcGW) ; Set calling number if necessary exten => _XXXX.,n,Set(CALLERID(numner)=CallingNumber) ; OSP lookup using default provider, if fail/error jump to lookup+101 exten => _XXXX.,n(lookup),OSPLookup(${EXTEN}||j) ; Set calling number which may be translated exten => _XXXX.,n,Set(CALLERID(num)=${OSPCALLING}) ; Dial to destination, 60 timeout, with call duration limit exten => _XXXX.,n,Dial(${OSPDIALSTR},60,oL($[${OSPOUTTIMELIMIT}*1000])) ; Wait 3 seconds exten => _XXXX.,n,Wait,3 ; Hangup exten => _XXXX.,n,Hangup ; Deal with OSPLookup fail/error exten => _XXXX.,lookup+101,Hangup exten => h,1,NoOp() ; OSP report usage exten => h,n,OSPFinish(${HANGUPCAUSE})
For IAX protocol.
[IAXSrcGW] exten => _XXXX.,1,NoOp(IAXSrcGW) ; Set calling number if necessary exten => _XXXX.,n,Set(CALLERID(numner)=CallingNumber) ; OSP lookup using default provider, if fail/error jump to lookup+101 exten => _XXXX.,n(lookup),OSPLookup(${EXTEN}||j) ; Set outbound OSP token exten => _XXXX.,n,Set(IAXCHANINFO(osptoken)=${OSPOUTTOKEN}) ; Set calling number which may be translated exten => _XXXX.,n,Set(CALLERID(num)=${OSPCALLING}) ; Dial to destination, 60 timeout, with call duration limit exten => _XXXX.,n,Dial(${OSPDIALSTR},60,oL($[${OSPOUTTIMELIMIT}*1000])) ; Wait 3 seconds exten => _XXXX.,n,Wait,3 ; Hangup exten => _XXXX.,n,Hangup ; Deal with OSPLookup fail/error exten => _XXXX.,lookup+101,Hangup exten => h,1,NoOp() ; OSP report usage exten => h,n,OSPFinish(${HANGUPCAUSE})
For H.323 protocol.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
504
[H323SrcGW] exten => _XXXX.,1,NoOp(H323SrcGW) ; Set calling number if necessary exten => _XXXX.,n,Set(CALLERID(numner)=CallingNumber) ; OSP lookup using default provider, if fail/error jump to lookup+101 ; h parameter is used to generate a call id ; Cisco OSP gateways use this call id to validate OSP token exten => _XXXX.,n(lookup),OSPLookup(${EXTEN}||jh) ; Set outbound call id exten => _XXXX.,n,Set(OH323CHANINFO(callid)=${OSPOUTCALLID}) ; Set outbound OSP token exten => _XXXX.,n,Set(OH323CHANINFO(osptoken)=${OSPOUTTOKEN}) ; Set calling number which may be translated exten => _XXXX.,n,Set(CALLERID(num)=${OSPCALLING}) ; Dial to destination, 60 timeout, with call duration limit exten => _XXXX.,n,Dial(${OSPDIALSTR},60,oL($[${OSPOUTTIMELIMIT}*1000])) ; Wait 3 seconds exten => _XXXX.,n,Wait,3 ; Hangup exten => _XXXX.,n,Hangup ; Deal with OSPLookup fail/error exten => _XXXX.,lookup+101,Hangup exten => h,1,NoOp() ; OSP report usage exten => h,n,OSPFinish(${HANGUPCAUSE})
3.3.2 Destination Gateway The examples in this section apply when Asterisk is being used as a VoIP to TDM gateway. VoIP calls are received by Asterisk which validates the OSP peering token and completes to the TDM network. After the call ends, Asterisk sends a CDR to the OSP server. For SIP protocol
[SIPDstGW] exten => _XXXX.,1,NoOp(SIPDstGW) ; Get peer IP exten => _XXXX.,n,Set(OSPPEERIP=${SIPCHANINFO(peerip)}) ; Get OSP token exten => _XXXX.,n,Set(OSPINTOKEN=${SIP_HEADER(P-OSP-Auth-Token)}) ; Validate token using default provider, if fail/error jump to auth+101 exten => _XXXX.,n(auth),OSPAuth(|j) ; Ringing exten => _XXXX.,n,Ringing ; Wait 1 second exten => _XXXX.,n,Wait,1 ; Dial phone, timeout 15 seconds, with call duration limit exten => _XXXX.,n,Dial(${DIALOUTANALOG}/${EXTEN:1},15,oL($[${OSPINTIMELIMIT}*1000])) ; Wait 3 seconds exten => _XXXX.,n,Wait,3 ; Hangup exten => _XXXX.,n,Hangup ; Deal with OSPAuth fail/error exten => _XXXX.,auth+101,Hangup exten => h,1,NoOp() ; OSP report usage exten => h,n,OSPFinish(${HANGUPCAUSE})
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
505
[IAXDstGW] exten => _XXXX.,1,NoOp(IAXDstGW) ; Get peer IP exten => _XXXX.,n,Set(OSPPEERIP=${IAXPEER(CURRENTCHANNEL)}) ; Get OSP token exten => _XXXX.,n,Set(OSPINTOKEN=${IAXCHANINFO(osptoken)}) ; Validate token using default provider, if fail/error jump to auth+101 exten => _XXXX.,n(auth),OSPAuth(|j) ; Ringing exten => _XXXX.,n,Ringing ; Wait 1 second exten => _XXXX.,n,Wait,1 ; Dial phone, timeout 15 seconds, with call duration limit exten => _XXXX.,n,Dial(${DIALOUTANALOG}/${EXTEN:1},15,oL($[${OSPINTIMELIMIT}*1000])) ; Wait 3 seconds exten => _XXXX.,n,Wait,3 ; Hangup exten => _XXXX.,n,Hangup ; Deal with OSPAuth fail/error exten => _XXXX.,auth+101,Hangup exten => h,1,NoOp() ; OSP report usage exten => h,n,OSPFinish(${HANGUPCAUSE})
For H.323 protocol
[H323DstGW] exten => _XXXX.,1,NoOp(H323DstGW) ; Get peer IP exten => _XXXX.,n,Set(OSPPEERIP=${H323CHANINFO(peerip)}) ; Get OSP token exten => _XXXX.,n,Set(OSPINTOKEN=${H323CHANINFO(osptoken)}) ; Validate token using default provider, if fail/error jump to auth+101 exten => _XXXX.,n(auth),OSPAuth(|j) ; Ringing exten => _XXXX.,n,Ringing ; Wait 1 second exten => _XXXX.,n,Wait,1 ; Dial phone, timeout 15 seconds, with call duration limit exten => _XXXX.,n,Dial(${DIALOUTANALOG}/${EXTEN:1},15,oL($[${OSPINTIMELIMIT}*1000])) ; Wait 3 seconds exten => _XXXX.,n,Wait,3 ; Hangup exten => _XXXX.,n,Hangup ; Deal with OSPAuth fail/error exten => _XXXX.,auth+101,Hangup exten => h,1,NoOp() ; OSP report usage exten => h,n,OSPFinish(${HANGUPCAUSE})
3.3.3 Proxy The example in this section applies when Asterisk is a proxy between two VoIP networks.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
506
[GeneralProxy] exten => _XXXX.,1,NoOp(GeneralProxy) ; Get peer IP and inbound OSP token ; SIP, un-comment the following two lines. ;exten => _XXXX.,n,Set(OSPPEERIP=${SIPCHANINFO(peerip)}) ;exten => _XXXX.,n,Set(OSPINTOKEN=${SIP_HEADER(P-OSP-Auth-Token)}) ; IAX, un-comment the following 2 lines ;exten => _XXXX.,n,Set(OSPPEERIP=${IAXPEER(CURRENTCHANNEL)}) ;exten => _XXXX.,n,Set(OSPINTOKEN=${IAXCHANINFO(osptoken)}) ; H323, un-comment the following two lines. ;exten => _XXXX.,n,Set(OSPPEERIP=${OH323CHANINFO(peerip)}) ;exten => _XXXX.,n,Set(OSPINTOKEN=${OH323CHANINFO(osptoken)}) ;--------------------------------------------------------------; Validate token using default provider, if fail/error jump to auth+101 exten => _XXXX.,n(auth),OSPAuth(|j) ; OSP lookup using default provider, if fail/error jump to lookup+101 ; h parameter is used to generate a call id for H.323 destinations ; Cisco OSP gateways use this call id to validate OSP token exten => _XXXX.,n(lookup),OSPLookup(${EXTEN}||jh) ; Set outbound call id and OSP token ; IAX, un-comment the following line. ;exten => _XXXX.,n,Set(IAXCHANINFO(osptoken)=${OSPOUTTOKEN}) ; H323, un-comment the following two lines. ;exten => _XXXX.,n,Set(OH323CHANINFO(callid)=${OSPOUTCALLID}) ;exten => _XXXX.,n,Set(OH323CHANINFO(osptoken)=${OSPOUTTOKEN}) ;--------------------------------------------------------------; Set calling number which may be translated exten => _XXXX.,n,Set(CALLERID(num)=${OSPCALLING}) ; Dial to destination, 14 timeout, with call duration limit exten => _XXXX.,n,Dial(${OSPDIALSTR},14,oL($[${OSPOUTTIMELIMIT}*1000])) ; OSP lookup next destination using default provider, if fail/error jump to next1+101 exten => _XXXX.,n(next1),OSPNext(${HANGUPCAUSE}||j) ; Set outbound call id and OSP token ; IAX, un-comment the following line. ;exten => _XXXX.,n,Set(IAXCHANINFO(osptoken)=${OSPOUTTOKEN}) ; H323, un-comment the following two lines. ;exten => _XXXX.,n,Set(OH323CHANINFO(callid)=${OSPOUTCALLID}) ;exten => _XXXX.,n,Set(OH323CHANINFO(osptoken)=${OSPOUTTOKEN}) ;--------------------------------------------------------------; Set calling number which may be translated exten => _XXXX.,n,Set(CALLERID(num)=${OSPCALLING}) ; Dial to destination, 15 timeout, with call duration limit exten => _XXXX.,n,Dial(${OSPDIALSTR},15,oL($[${OSPOUTTIMELIMIT}*1000])) ; OSP lookup next destination using default provider, if fail/error jump to next2+101 exten => _XXXX.,n(next2),OSPNext(${HANGUPCAUSE}||j) ; Set outbound call id and OSP token ; IAX, un-comment the following line. ;exten => _XXXX.,n,Set(IAXCHANINFO(osptoken)=${OSPOUTTOKEN}) ; H323, un-comment the following two lines. ;exten => _XXXX.,n,Set(OH323CHANINFO(callid)=${OSPOUTCALLID}) ;exten => _XXXX.,n,Set(OH323CHANINFO(osptoken)=${OSPOUTTOKEN}) ;--------------------------------------------------------------; Set calling number which may be translated exten => _XXXX.,n,Set(CALLERID(num)=${OSPCALLING}) ; Dial to destination, 16 timeout, with call duration limit exten => _XXXX.,n,Dial(${OSPDIALSTR},16,oL($[${OSPOUTTIMELIMIT}*1000])) ; Hangup exten => _XXXX.,n,Hangup ; Deal with OSPAuth fail/error
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
507
exten => _XXXX.,auth+101,Hangup ; Deal with OSPLookup fail/error exten => _XXXX.,lookup+101,Hangup ; Deal with 1st OSPNext fail/error exten => _XXXX.,next1+101,Hangup ; Deal with 2nd OSPNext fail/error exten => _XXXX.,next2+101,Hangup exten => h,1,NoOp() ; OSP report usage exten => h,n,OSPFinish(${HANGUPCAUSE})
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
508
PSTN Connectivity
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
509
Advice of Charge
Written by: David Vossel Initial version: 04-19-2010 Email: [email protected] This document is designed to give an overview of how to configure and generate Advice of Charge along with a detailed explanation of how each option works. Read This First PLEASE REPORT ANY ISSUES ENCOUNTERED WHILE USING AOC. This feature has had very little community feedback so far. If you are using this feature please share with us any problems you are having and any improvements that could make this feature more useful. Thank you! Terminology AOC: Advice of Charge AOC-S: Advice of Charge message sent at the beginning of a call during call setup. This message contains a list of rates associated with the call. AOC-D: Advice of Charge message sent during the call. This message is typically used to update the endpoint with the current call charge. AOC-E: Advice of Charge message sent at the end of a call. This message is used to indicate to the endpoint the final call charge. AMI: Asterisk Manager Interface. This interface is used to generate AOC messages and listen for AOC events. AOC in chan_dahdi LibPRI Support: ETSI, or euroisdn, is the only switchtype that LibPRI currently supports for AOC. Enable AOC Pass-through in chan_dahdi To enable AOC pass-through between the ISDN and Asterisk use the 'aoc_enable' config option. This option allows for any combination of AOC-S, AOC-D, and AOC-E to be enabled or disabled. For example:
aoc_enable=s,d,e ; enables pass-through of AOC-S, AOC-D, and AOC-E aoc_enable=s,d ; enables pass-through of AOC-S and AOC-D. Rejects ; AOC-E and AOC-E request messages
Since AOC messages are often transported on facility messages, the 'facilityenable' option must be enabled as well to fully support AOC pass-through. Handling AOC-E in chan_dahdi Whenever a dahdi channel receives an AOC-E message from Asterisk, it stores that message to deliver it at the appropriate time during call termination. This means that if two AOC-E messages are received on the same call, the last one will override the first one and only one AOC-E message will be sent during call termination. There are some tricky situations involving the final AOC-E message. During a bridged call, if the endpoint receiving the AOC messages terminates the call before the endpoint delivering the AOC does, the final AOC-E message sent by the sending side during termination will never make it to the receiving end because Asterisk will have already torn down that channel. This is where the chan_dahdi.conf 'aoce_delayhangup' option comes into play. By enabling 'aoce_delayhangup', anytime a hangup is initiated by the ISDN side of an Asterisk channel, instead of hanging up the channel, the channel sends a unique internal AOC-E termination request to its bridge channel. This indicates it is about to hangup and wishes to receive the final AOC-E message from the bridged channel before completely tearing down. If the bridged channel knows what to do with this AOC-E termination request, it will do whatever is necessary to indicate to its endpoint that the call is being terminated without actually hanging up the Asterisk channel. This allows the final AOC-E message to come in and be sent across the bridge while both channels are still up. If the channel delaying its hangup for the final AOC-E message times out, the call will be torn down just as it normally would. In chan_dahdi the timeout period is 1/2 the T305 timer which by default is 15 seconds. 'aoce_delayhangup' currently only works when both bridged channels are dahdi_channels. If a SIP channel receives an AOC-E termination request, it just responds by immediately hanging up the channel. Using this option when bridged to any channel technology besides SIP or DAHDI will result in the 15 second timeout period before tearing down the call completely. Requesting AOC services
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
510
AOC can be requested on a call by call basis using the DAHDI dialstring option, A(). The A() option takes in 's', 'd', and 'e' parameters which represent the three types of AOC messages, AOC-S, AOC-D, and AOC-E. By using this option Asterisk will indicate to the endpoint during call setup that it wishes to receive the specified forms of AOC during the call. Example Usage in extensions.conf
exten => 1111,1,Dial(DAHDI/g1/1112/A(s,d,e) ; requests AOC-S, AOC-D, and AOC-E on ; call setup exten => 1111,1,Dial(DAHDI/g1/1112/A(d,e) ; requests only AOC-D, and AOC-E on ; call setup
AOC in chan_sip Asterisk supports a very basic way of sending AOC on a SIP channel to Snom phones using an AOC specification designed by Snom. This support is limited to the sending of AOC-D and AOC-E pass-through messages. No support for AOC-E on call termination is present, so if the Snom endpoint receiving the AOC messages from Asterisk terminates the call, the channel will be torn down before the phone can receive the final AOC-E message. To enable passthrough of AOC messages via the snom specification, use the 'snom_aoc_enabled' option in sip.conf. Generate AOC Messages via AMI Asterisk supports a way to generate AOC messages on a channel via the AMI action AOCMessage. At the moment the AOCMessage action is limited to AOC-D and AOC-E message generation. There are some limitations involved with delivering the final AOC-E message as well. The AOCMessage action has its own detailed parameter documentation so this discussion will focus on higher level use. When generating AOC messages on a Dahdi channel first make sure the appropriate chan_dahdi.conf options are enabled. Without enabling 'aoc_enable' correctly for pass-through the AOC messages will never make it out the pri. The same goes with SIP, the 'snom_aoc_enabled' option must be configured before messages can successfully be set to the endpoint. AOC-D Message Generation AOC-D message generation can happen anytime throughout the call. This message type is very straight forward. Example: AOCMessage action generating AOC-D currency message with Success response.
Action: AOCMessage Channel: DAHDI/i1/1111-1 MsgType: d ChargeType: Currency CurrencyAmount: 16 CurrencyName: USD CurrencyMultiplier: OneThousandth AOCBillingId: Normal ActionID: 1234 Response: Success ActionID: 1234 Message: AOC Message successfully queued on channel
AOC-E Message Generation AOC-E messages are sent during call termination and represent the final charge total for the call. Since Asterisk call termination results in the channel being destroyed, it is currently not possible for the AOCMessage AMI action to be used to send the final AOC-E message on call hangup. There is however a work around for this issue that can be used for Dahdi channels. By default chan_dahdi saves any AOC-E message it receives from Asterisk during a call and waits to deliver that message during call termination. If multiple AOC-E messages are received from Asterisk on the same Dahdi channel, only the last message received is stored for delivery. This means that each new AOC-E message received on the channel overrides the previous one. Knowing this the final AOC-E message can be continually updated on a Dahdi channel until call termination occurs allowing the last update to be sent on hangup. This method is only as accurate as the intervals in which it is updated, but allows some form of AOC-E to be generated. Example: AOCMessage action generating AOC-E unit message with Success response.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
511
Action: AOCMessage Channel: DAHDI/i1/1111-1 MsgType: e ChargeType: Unit UnitAmount(0): 111 UnitType(0): 6 UnitAmount(1): 222 UnitType(1): 5 UnitAmount(2): 333 UnitType(3): 4 UnitAmount(4): 444 AOCBillingId: Normal ActionID: 1234 Response: Success ActionID: 1234 Message: AOC Message successfully queued on channel
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
512
Caller ID in India
India finds itself in a unique situation (hopefully). It has several telephone line providers, and they are not all using the same CID signaling; and the CID signalling is not like other countries. In order to help those in India quickly find to the CID signaling system that their carrier uses (or range of them), and get the configs right with a minimal amount of experimentation, this file is provided. Not all carriers are covered, and not all mentioned below are complete. Those with updates to this table should post the new information on bug 6683 of the asterisk bug tracker. Provider: Bharti (is this BSNL?) Config:
cidstart=polarity_in cidsignalling=dtmf
Results: ? (this should work), but needs to be tested? Tested by: ? Provider: VSNL Config:
null
Results: ? Tested by: ? Provider: BSNL Config:
cid_start=ring cid_signalling=dtmf
Results: ? Tested by: (abhi) Provider: MTNL, old BSNL Config:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
513
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
514
Siemens EWSD - (ITU style) MTP2 and MTP3 comes up, ISUP inbound and outbound calls work as well. DTI DXC 4K - (ANSI style) 56kbps link, MTP2 and MTP3 come up, ISUP inbound and outbound calls work as well. Huawei M800 - (ITU style) MTP2 and MTP3 comes up, ISUP National, International inbound and outbound calls work as well, CallerID presentation&screening work.
and MORE~! Thanks: Mark Spencer, for writing Asterisk and libpri and being such a great friend and boss. Luciano Ramos, for donating a link in getting the first "real" ITU switch working. Collin Rose and John Lodden, John for introducing me to Collin, and Collin for the first "real" ANSI link and for holding my hand through the remaining changes that had to be done for ANSI switches. To Use: In order to use libss7, you must get at least the following versions of DAHDI and Asterisk: DAHDI: 2.0.x libss7: trunk (currently, there only is a trunk release). Asterisk: 1.6.x You must then do a `make; make install` in each of the directories that you installed in the given order (DAHDI first, libss7 second, and Asterisk last).
In order to check out the code, you must have the subversion client installed. This is how to check them out from the public subversion server. These are the commands you would type to install them:
`svn co http://svn.digium.com/svn/dahdi/linux/trunk dahdi-trunk` `cd dahdi-trunk` `make; make install` `svn co http://svn.digium.com/svn/dahdi/tools/trunk dahdi-tools` `cd dahdi-tools` `./configure; make; make install` `svn co http://svn.digium.com/svn/libss7/trunk libss7-trunk` `cd libss7-trunk` `make; make install` `svn co http://svn.digium.com/svn/asterisk/trunk asterisk-trunk` `cd asterisk-trunk` `./configure; make; make install;`
This should build DAHDI, libss7, and Asterisk with SS7 support.
In the past, there was a special asterisk-ss7 branch to use which contained the SS7 code. That code has been merged back into the trunk version of Asterisk, and the old asterisk-ss7 branch has been deprecated and removed. If you are still using the asterisk-ss7 branch, it will not work against the current version of libss7, and you should switch to asterisk-trunk instead. Configuration: In /etc/dahdi/system.conf, your signalling channel(s) should be a "dchan" and your bearers should be set as "bchan". The sample chan_dahdi.conf contains sample configuration for setting up an E1 link. In brief, here is a simple ss7 linkset setup:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
515
signalling = ss7 ss7type = itu ; or ansi if you are using an ANSI link linkset = 1 ; Pick a number for your linkset identifier in chan_dahdi.conf
pointcode = 28 ; The decimal form of your point code. If you are using an ; ANSI linkset, you can use the xxx-xxx-xxx notation for ; specifying your link adjpointcode = 2 ; The point code of the switch adjacent to your linkset defaultdpc = 3 ; The point code of the switch you want to send your ISUP ; traffic to. A lot of the time, this is the same as your ; adjpointcode. ; Now we configure our Bearer channels (CICs) cicbeginswith = 1 ; Number to start counting the CICs from. So if DAHDI/1 to ; DAHDI/15 are CICs 1-15, you would set this to 1 before you ; declare channel=1-15 channel=1-15 ; Use DAHDI/1-15 and assign them to CICs 1-15
cicbeginswith = 17 ; Now for DAHDI/17 to DAHDI/31, they are CICs 17-31 so we initialize ; cicbeginswith to 17 before we declare those channels channel = 17-31 ; This assigns CICs 17-31 to channels 17-31
sigchan = 16 ; This is where you declare which DAHDI channel is your signalling ; channel. In our case it is DAHDI/16. You can add redundant ; signalling channels by adding additional sigchan= lines. ; If we want an alternate redundant signalling channel add this sigchan = 48 ; This would put two signalling channels in our linkset, one at ; DAHDI/16 and one at DAHDI/48 which both would be used to send/receive ; ISUP traffic. ; End of chan_dahdi.conf
This is how a basic linkset is setup. For more detailed chan_dahdi.conf SS7 config information as well as other options available for that file, see the default chan_dahdi.conf that comes with the samples in asterisk. If you would like, you can do a `make samples` in your asterisk-trunk directory and it will install a sample chan_dahdi.conf for you that contains more information about SS7 setup. For more information, please use the asterisk-ss7 or asterisk-dev mailing lists (I monitor them regularly) or email me directly. Matthew Fredrickson [email protected]
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
516
Omnitor Allan eC - SIP audio/video/text softphone AuPix APS-50 - audio/video/text softphone. France Telecom eConf audio/video/text softphone. SIPcon1 - open source SIP audio/text softphone available in Sourceforge.
Credits
Asterisk real-time text support is developed by AuPix Asterisk real-time text redundancy support is developed by Omnitor
The work with Asterisk real-time text redundancy was supported with funding from the National Institute on Disability and Rehabilitation Research (NIDRR), U.S. Department of Education, under grant number H133E040013 as part of a co-operation between the Telecommunication Access Rehabilitation Engineering Research Center of the University of Wisconsin Trace Center joint with Gallaudet University, and Omnitor. Olle E. Johansson, Edvina AB, has been a liason between the Asterisk project and this project.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
517
RTP Packetization
Overview
Asterisk currently supports configurable RTP packetization per codec for select RTP-based channels. Channels These channel drivers allow RTP packetization on a user/peer/friend or global level:
chan_sip chan_skinny chan_h323 chan_ooh323 (Asterisk-Addons) chan_gtalk chan_jingle chan_motif (Asterisk 11+)
Configuration To set a desired packetization interval on a specific codec, append that inteval to the allow= statement. Example:
allow=ulaw:30,alaw,g729:60
No packetization is specified in the case of alaw in this example, so the default of 20ms is used. Autoframing In addition, chan_sip has the ability to negotiate the desired framing at call establishment. In sip.conf if autoframing=yes is set in the global section, then all calls will try to set the packetization based on the remote endpoint's preferences. This behaviour depends on the endpoints ability to present the desired packetization (ptime\:) in the SDP. If the endpoint does not include a ptime attribute, the call will be established with 20ms packetization. Autoframing can be set at the global level or on a user/peer/friend basis. If it is enabled at the global level, it applies to all users/peers/friends regardless of their prefered codec packetization. Codec framing options The following table lists the minimum and maximum values that are valid per codec, as well as the increment value used for each. Please note that the maximum values here are only recommended maximums, and should not exceed the RTP MTU. Name g723 gsm ulaw alaw g726 ADPCM SLIN lpc10 g729 speex ilbc Minimum (ms) 30 20 10 10 10 10 10 20 10 10 30 Maximum (ms) 300 300 150 150 300 300 70 20 230 60 30 Default (ms) 30 20 20 20 20 20 20 20 20 20 30 Increment (ms) 30 20 10 10 10 10 10 20 10 10 30
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
518
g726_aal2
10
300
20
10
1. If the specified framing is less than the codec's minimum, then the minimum value is used. 2. If the specific framing is greater than the codec's maximum, then the maximum value is used 3. If the specificed framing does not meet the increment requirement, the specified framing is rounded down to the closest valid framing options.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
519
Syntax
Synopsis Retrieve an SMDI message. Description This function is used to retrieve an incoming SMDI message. It returns an ID which can be used with the SMDI_MSG() function to access details of the message. Note that this is a destructive function in the sense that once an SMDI message is retrieved using this function, it is no longer in the global SMDI message queue, and can not be accessed by any other Asterisk channels. The timeout for this function is optional, and the default is 3 seconds. When providing a timeout, it should be in milliseconds. The default search is done on the forwarding station ID. However, if you set one of the search key options in the options field, you can change this behavior. Options
t - Instead of searching on the forwarding station, search on the message desk terminal. n - Instead of searching on the forwarding station, search on the message desk number.
Syntax
SMDI_MSG(<message_id>,<component>)
Synopsis Retrieve details about an SMDI message. Description This function is used to access details of an SMDI message that was pulled from the incoming SMDI message queue using the SMDI_MSG_RETRIEVE() function. Valid message components are:
station - The forwarding station callerid - The callerID of the calling party that was forwarded type - The call type. The value here is the exact character that came in on the SMDI link. Typically, example values are: D - Direct Calls, A - Forward All Calls, B - Forward Busy Calls, N - Forward No Answer Calls
Here is an example of how to use these functions:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
520
; Retrieve the SMDI message that is associated with the number that ; was called in Asterisk. exten => _0XXX,1,Set(SMDI_MSG_ID=${SMDI_MSG_RETRIEVE(/dev/tty0,${EXTEN})}) ; Ensure that the message was retrieved. exten => _0XXX,n,GotoIf($["x${SMDI_MSG_ID}" != "x"]?processcall:hangup) exten => _0XXX,n(hangup),NoOp(No SMDI message retrieved for ${EXTEN}) ; Grab the details out of the SMDI message. exten => _0XXX,n(processcall),NoOp(Message found for ${EXTEN}) exten => _0XXX,n,Set(SMDI_EXTEN=${SMDI_MSG(${SMDI_MSG_ID},station)}) exten => _0XXX,n,Set(SMDI_CID=${SMDI_MSG(${SMDI_MSG_ID},callerid)}) ; Map SMDI message types to the right voicemail option. If it is "B", use the ; busy option. Otherwise, use the unavailable option. exten => _0XXX,n,GotoIf($["${SMDI_MSG(${SMDI_MSG_ID},type)}" == "B"]?usebusy:useunavail) exten => _0XXX,n(usebusy),Set(SMDI_VM_TYPE=b) exten => _0XXX,n,Goto(continue) exten => _0XXX,n,(useunavil),Set(SMDI_VM_TYPE=u) exten => _0XXX,n(continue),NoOp( Process the rest of the call ... )
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
521
[mailboxes] ; This section configures parameters related to MWI handling for the SMDI link. ; ; This option configures the polling interval used to check to see if the ; mailboxes have any new messages. This option is specified in seconds. ; The default value is 10 seconds. ; ;pollinginterval=10 ; ; Before specifying mailboxes, you must specify an SMDI interface. All mailbox ; definitions that follow will correspond to that SMDI interface. If you ; specify another interface, then all definitions following that will correspond ; to the new interface. ; ; Every other entry in this section of the configuration file is interpreted as ; a mapping between the mailbox ID on the SMDI link, and the local Asterisk ; mailbox name. In many cases, they are the same thing, but they still must be ; listed here so that this module knows which mailboxes it needs to pay ; attention to. ; ; Syntax: ; <SMDI mailbox ID>=<Asterisk Mailbox Name>[@Asterisk Voicemail Context] ; ; If no Asterisk voicemail context is specified, "default" will be assumed. ; ; ;smdiport=/dev/ttyS0 ;2565551234=1234@vmcontext1 ;2565555678=5678@vmcontext2 ;smdiport=/dev/ttyS1 ;2565559999=9999
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
522
'net-snmp-config --agent-libs'.
You will receive a response similar to the following:
-L/usr/lib -lnetsnmpmibs -lnetsnmpagent -lnetsnmphelpers -lnetsnmp -ldl -lrpm -lrpmio -lpopt -lz -lcrypto -lm -lsensors -L/usr/lib/lib -lwrap -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE -L/usr/local/lib /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/DynaLoader/DynaLoader.a -L/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
# Enable AgentX support master agentx # Set permissions on AgentX socket and containing # directory such that process in group 'asterisk' # will be able to connect agentXPerms 0660 0550 nobody asterisk
This assumes that you run Asterisk under group 'asterisk' (and does not care what user you run as).
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
523
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
524
astConfigUpTime OBJECT-TYPE SYNTAX TimeTicks MAX-ACCESS read-only STATUS current DESCRIPTION "Time ticks since Asterisk was started." ::= { asteriskConfiguration 1 } astConfigReloadTime OBJECT-TYPE SYNTAX TimeTicks MAX-ACCESS read-only STATUS current DESCRIPTION "Time ticks since Asterisk was last reloaded." ::= { asteriskConfiguration 2 } astConfigPid OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-only STATUS current DESCRIPTION "The process id of the running Asterisk process." ::= { asteriskConfiguration 3 } astConfigSocket OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "The control socket for giving Asterisk commands." ::= { asteriskConfiguration 4 } astConfigCallsActive OBJECT-TYPE SYNTAX Gauge32 MAX-ACCESS read-only STATUS current DESCRIPTION "The number of calls currently active on the Asterisk PBX." ::= { asteriskConfiguration 5 } astConfigCallsProcessed OBJECT-TYPE SYNTAX Counter32 MAX-ACCESS read-only STATUS current DESCRIPTION "The total number of calls processed through the Asterisk PBX since last restart." ::= { asteriskConfiguration 6 } -- asteriskModules astNumModules OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-only STATUS current DESCRIPTION "Number of modules currently loaded into Asterisk." ::= { asteriskModules 1 } -- asteriskIndications astNumIndications OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-only STATUS current DESCRIPTION "Number of indications currently defined in Asterisk." ::= { asteriskIndications 1 } astCurrentIndication OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Default indication zone to use." ::= { asteriskIndications 2 } astIndicationsTable OBJECT-TYPE SYNTAX SEQUENCE OF AstIndicationsEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "Table with all the indication zones currently know to the running Asterisk instance." ::= { asteriskIndications 3 } astIndicationsEntry OBJECT-TYPE SYNTAX AstIndicationsEntry
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
525
MAX-ACCESS not-accessible STATUS current DESCRIPTION "Information about a single indication zone." INDEX { astIndIndex } ::= { astIndicationsTable 1 } AstIndicationsEntry ::= SEQUENCE { astIndIndex Integer32, astIndCountry DisplayString, astIndAlias DisplayString, astIndDescription DisplayString } astIndIndex OBJECT-TYPE SYNTAX Integer32 (1 .. 2147483647) MAX-ACCESS read-only STATUS current DESCRIPTION "Numerical index into the table of indication zones." ::= { astIndicationsEntry 1 } astIndCountry OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Country for which the indication zone is valid, typically this is the ISO 2-letter code of the country." ::= { astIndicationsEntry 2 } astIndAlias OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "" ::= { astIndicationsEntry 3 } astIndDescription OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Description of the indication zone, usually the full name of the country it is valid for." ::= { astIndicationsEntry 4 } -- asteriskChannels astNumChannels OBJECT-TYPE SYNTAX Gauge32 MAX-ACCESS read-only STATUS current DESCRIPTION "Current number of active channels." ::= { asteriskChannels 1 } astChanTable OBJECT-TYPE SYNTAX SEQUENCE OF AstChanEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "Table with details of the currently active channels in the Asterisk instance." ::= { asteriskChannels 2 } astChanEntry OBJECT-TYPE SYNTAX AstChanEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "Details of a single channel." INDEX { astChanIndex } ::= { astChanTable 1 } AstChanEntry ::= SEQUENCE { astChanIndex Integer32, astChanName DisplayString, astChanLanguage DisplayString, astChanType DisplayString, astChanMusicClass DisplayString, astChanBridge DisplayString, astChanMasq DisplayString, astChanMasqr DisplayString, astChanWhenHangup TimeTicks, astChanApp DisplayString, astChanData DisplayString, astChanContext DisplayString,
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
526
astChanMacroContext DisplayString, astChanMacroExten DisplayString, astChanMacroPri Integer32, astChanExten DisplayString, astChanPri Integer32, astChanAccountCode DisplayString, astChanForwardTo DisplayString, astChanUniqueId DisplayString, astChanCallGroup Unsigned32, astChanPickupGroup Unsigned32, astChanState INTEGER, astChanMuted TruthValue, astChanRings Integer32, astChanCidDNID DisplayString, astChanCidNum DisplayString, astChanCidName DisplayString, astChanCidANI DisplayString, astChanCidRDNIS DisplayString, astChanCidPresentation DisplayString, astChanCidANI2 Integer32, astChanCidTON Integer32, astChanCidTNS Integer32, astChanAMAFlags INTEGER, astChanADSI INTEGER, astChanToneZone DisplayString, astChanHangupCause INTEGER, astChanVariables DisplayString, astChanFlags BITS, astChanTransferCap INTEGER } astChanIndex OBJECT-TYPE SYNTAX Integer32 (1 .. 2147483647) MAX-ACCESS read-only STATUS current DESCRIPTION "Index into the channel table." ::= { astChanEntry 1 } astChanName OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Name of the current channel." ::= { astChanEntry 2 } astChanLanguage OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Which language the current channel is configured to use -- used mainly for prompts." ::= { astChanEntry 3 } astChanType OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Underlying technology for the current channel." ::= { astChanEntry 4 } astChanMusicClass OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Music class to be used for Music on Hold for this channel." ::= { astChanEntry 5 } astChanBridge OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Which channel this channel is currently bridged (in a conversation) with." ::= { astChanEntry 6 } astChanMasq OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Channel masquerading for us." ::= { astChanEntry 7 }
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
527
astChanMasqr OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Channel we are masquerading for." ::= { astChanEntry 8 } astChanWhenHangup OBJECT-TYPE SYNTAX TimeTicks MAX-ACCESS read-only STATUS current DESCRIPTION "How long until this channel will be hung up." ::= { astChanEntry 9 } astChanApp OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Current application for the channel." ::= { astChanEntry 10 } astChanData OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Arguments passed to the current application." ::= { astChanEntry 11 } astChanContext OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Current extension context." ::= { astChanEntry 12 } astChanMacroContext OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Current macro context." ::= { astChanEntry 13 } astChanMacroExten OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Current macro extension." ::= { astChanEntry 14 } astChanMacroPri OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-only STATUS current DESCRIPTION "Current macro priority." ::= { astChanEntry 15 } astChanExten OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Current extension." ::= { astChanEntry 16 } astChanPri OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-only STATUS current DESCRIPTION "Current priority." ::= { astChanEntry 17 } astChanAccountCode OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Account Code for billing." ::= { astChanEntry 18 }
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
528
astChanForwardTo OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Where to forward to if asked to dial on this interface." ::= { astChanEntry 19 } astChanUniqueId OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Unique Channel Identifier." ::= { astChanEntry 20 } astChanCallGroup OBJECT-TYPE SYNTAX Unsigned32 MAX-ACCESS read-only STATUS current DESCRIPTION "Call Group." ::= { astChanEntry 21 } astChanPickupGroup OBJECT-TYPE SYNTAX Unsigned32 MAX-ACCESS read-only STATUS current DESCRIPTION "Pickup Group." ::= { astChanEntry 22 } astChanState OBJECT-TYPE SYNTAX INTEGER { stateDown(0), stateReserved(1), stateOffHook(2), stateDialing(3), stateRing(4), stateRinging(5), stateUp(6), stateBusy(7), stateDialingOffHook(8), statePreRing(9) } MAX-ACCESS read-only STATUS current DESCRIPTION "Channel state." ::= { astChanEntry 23 } astChanMuted OBJECT-TYPE SYNTAX TruthValue MAX-ACCESS read-only STATUS current DESCRIPTION "Transmission of voice data has been muted." ::= { astChanEntry 24 } astChanRings OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-only STATUS current DESCRIPTION "Number of rings so far." ::= { astChanEntry 25 } astChanCidDNID OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Dialled Number ID." ::= { astChanEntry 26 } astChanCidNum OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Caller Number." ::= { astChanEntry 27 } astChanCidName OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
529
"Caller Name." ::= { astChanEntry 28 } astChanCidANI OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "ANI" ::= { astChanEntry 29 } astChanCidRDNIS OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Redirected Dialled Number Service." ::= { astChanEntry 30 } astChanCidPresentation OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Number Presentation/Screening." ::= { astChanEntry 31 } astChanCidANI2 OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-only STATUS current DESCRIPTION "ANI 2 (info digit)." ::= { astChanEntry 32 } astChanCidTON OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-only STATUS current DESCRIPTION "Type of Number." ::= { astChanEntry 33 } astChanCidTNS OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-only STATUS current DESCRIPTION "Transit Network Select." ::= { astChanEntry 34 } astChanAMAFlags OBJECT-TYPE SYNTAX INTEGER { default(0), omit(1), billing(2), documentation(3) } MAX-ACCESS read-only STATUS current DESCRIPTION "AMA Flags." ::= { astChanEntry 35 } astChanADSI OBJECT-TYPE SYNTAX INTEGER { unknown(0), available(1), unavailable(2), offHookOnly(3) } MAX-ACCESS read-only STATUS current DESCRIPTION "Whether or not ADSI is detected on CPE." ::= { astChanEntry 36 } astChanToneZone OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Indication zone to use for channel." ::= { astChanEntry 37 } astChanHangupCause OBJECT-TYPE SYNTAX INTEGER { notDefined(0), unregistered(3),
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
530
normal(16), busy(17), noAnswer(19), congestion(34), failure(38), noSuchDriver(66) } MAX-ACCESS read-only STATUS current DESCRIPTION "Why is the channel hung up." ::= { astChanEntry 38 } astChanVariables OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Channel Variables defined for this channel." ::= { astChanEntry 39 } astChanFlags OBJECT-TYPE SYNTAX BITS { wantsJitter(0), deferDTMF(1), writeInterrupt(2), blocking(3), zombie(4), exception(5), musicOnHold(6), spying(7), nativeBridge(8), autoIncrementingLoop(9) } MAX-ACCESS read-only STATUS current DESCRIPTION "Flags set on this channel." ::= { astChanEntry 40 } astChanTransferCap OBJECT-TYPE SYNTAX INTEGER { speech(0), digital(8), restrictedDigital(9), audio3k(16), digitalWithTones(17), video(24) } MAX-ACCESS read-only STATUS current DESCRIPTION "Transfer Capabilities for this channel." ::= { astChanEntry 41 } astNumChanTypes OBJECT-TYPE SYNTAX Integer32 MAX-ACCESS read-only STATUS current DESCRIPTION "Number of channel types (technologies) supported." ::= { asteriskChannels 3 } astChanTypeTable OBJECT-TYPE SYNTAX SEQUENCE OF AstChanTypeEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "Table with details of the supported channel types." ::= { asteriskChannels 4 } astChanTypeEntry OBJECT-TYPE SYNTAX AstChanTypeEntry MAX-ACCESS not-accessible STATUS current DESCRIPTION "Information about a technology we support, including how many channels are currently using this technology." INDEX { astChanTypeIndex } ::= { astChanTypeTable 1 } AstChanTypeEntry ::= SEQUENCE { astChanTypeIndex Integer32, astChanTypeName DisplayString, astChanTypeDesc DisplayString, astChanTypeDeviceState Integer32, astChanTypeIndications Integer32, astChanTypeTransfer Integer32, astChanTypeChannels Gauge32
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
531
} astChanTypeIndex OBJECT-TYPE SYNTAX Integer32 (1 .. 2147483647) MAX-ACCESS read-only STATUS current DESCRIPTION "Index into the table of channel types." ::= { astChanTypeEntry 1 } astChanTypeName OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Unique name of the technology we are describing." ::= { astChanTypeEntry 2 } astChanTypeDesc OBJECT-TYPE SYNTAX DisplayString MAX-ACCESS read-only STATUS current DESCRIPTION "Description of the channel type (technology)." ::= { astChanTypeEntry 3 } astChanTypeDeviceState OBJECT-TYPE SYNTAX TruthValue MAX-ACCESS read-only STATUS current DESCRIPTION "Whether the current technology can hold device states." ::= { astChanTypeEntry 4 } astChanTypeIndications OBJECT-TYPE SYNTAX TruthValue MAX-ACCESS read-only STATUS current DESCRIPTION "Whether the current technology supports progress indication." ::= { astChanTypeEntry 5 } astChanTypeTransfer OBJECT-TYPE SYNTAX TruthValue MAX-ACCESS read-only STATUS current DESCRIPTION "Whether the current technology supports transfers, where Asterisk can get out from inbetween two bridged channels." ::= { astChanTypeEntry 6 } astChanTypeChannels OBJECT-TYPE SYNTAX Gauge32 MAX-ACCESS read-only STATUS current DESCRIPTION "Number of active channels using the current technology." ::= { astChanTypeEntry 7 } astChanScalars OBJECT IDENTIFIER ::= { asteriskChannels 5 } astNumChanBridge OBJECT-TYPE SYNTAX Gauge32 MAX-ACCESS read-only STATUS current DESCRIPTION "Number of channels currently in a bridged state."
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
532
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
533
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
534
SIP Retransmissions
What is the problem with SIP retransmits?
Sometimes you get messages in the console like these:
retrans_pkt: Hanging up call XX77yy - no reply to our critical packet. retrans_pkt: Cancelling retransmit of OPTIONs
The SIP protocol is based on requests and replies. Both sides send requests and wait for replies. Some of these requests are important. In a TCP/IP network many things can happen with IP packets. Firewalls, NAT devices, Session Border Controllers and SIP Proxys are in the signalling path and they will affect the call. SIP Call setup - INVITE-200 OK - ACK To set up a SIP call, there's an INVITE transaction. The SIP software that initiates the call sends an INVITE, then wait to get a reply. When a reply arrives, the caller sends an ACK. This is a three-way handshake that is in place since a phone can ring for a very long time and the protocol needs to make sure that all devices are still on line when call setup is done and media starts to flow.
The first reply we're waiting for is often a "100 trying". This message means that some type of SIP server has received our request and makes sure that we will get a reply. It could be the other endpoint, but it could also be a SIP proxy or SBC that handles the request on our behalf. After that, you often see a response in the 18x class, like "180 ringing" or "183 Session Progress". This typically means that our request has reached at least one endpoint and something is alerting the other end that there's a call coming in. Finally, the other side answers and we get a positive reply, "200 OK". This is a positive answer. In that message, we get an address that goes directly to the device that answers. Remember, there could be multiple phones ringing. The address is specified by the Contact: header. To confirm that we can reach the phone that answered our call, we now send an ACK to the Contact: address. If this ACK doesn't reach the phone, the call fails. If we can't send an ACK, we can't send anything else, not even a proper hangup. Call signaling will simply fail for the rest of the call and there's no point in keeping it alive. If we get an error response to our INVITE, like "Busy" or "Rejected", we send the ACK to the same address as we sent the INVITE, to confirm that we got the response.
In order to make sure that the whole call setup sequence works and that we have a call, a SIP client retransmits messages if there's too much delay between request and expected response. We retransmit a number of times while waiting for the first response. We retransmit the answer to an incoming INVITE while waiting for an ACK. If we get multiple answers, we send an ACK to each of them. If we don't get the ACK or don't get an answer to our INVITE, even after retransmissions, we will hangup the call with the first error message you see above. Other SIP requests Other SIP requests are only based on request - reply. There's no ACK, no three-way handshake. In Asterisk we mark some of these as CRITICAL - they need to go through for the call to work as expected. Some are non-critical, we don't really care what happens with them, the call will go on happily regardless. The qualification process - OPTIONS If you turn on qualify= in sip.conf for a device, Asterisk will send an OPTIONS request every minute to the device and check if it replies. Each OPTIONS request is retransmitted a number of times (to handle packet loss) and if we get no reply, the device is considered unreachable. From that moment, we will send a new OPTIONS request (with retransmits) every tenth second. Why does this happen? For some reason signalling doesn't work as expected between your Asterisk server and the other device. There could be many reasons why this happens.
A NAT device in the signalling path. A misconfigured NAT device is in the signalling path and stops SIP messages. A firewall that blocks messages or reroutes them wrongly in an attempt to assist in a too clever way. A SIP middlebox (SBC) that rewrites contact: headers so that we can't reach the other side with our reply or the ACK.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
535
A badly configured SIP proxy that forgets to add record-route headers to make sure that signalling works. Packet loss. IP and UDP are unreliable transports. If you loose too many packets the retransmits doesn't help and communication is impossible. If this happens with signaling, media would be unusable anyway.
What can I do? Turn on SIP debug, try to understand the signalling that happens and see if you're missing the reply to the INVITE or if the ACK gets lost. When you know what happens, you've taken the first step to track down the problem. See the list above and investigate your network. For NAT and Firewall problems, there are many documents to help you. Start with reading sip.conf.sample that is part of your Asterisk distribution. The SIP signalling standard, including retransmissions and timers for these, is well documented in the IETF RFC 3261. Good luck sorting out your SIP issues! /Olle E. Johansson oej (at) edvina.net, Sweden, 2008-07-22 http://www.voip-forum.com
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
536
Asterisk as client and server (TLS and TCP) Polycom Soundpoint IP Phones (TLS and TCP) - Polycom phones require that the host (ip or hostname) that is configured match the 'common name' in the certificate Minisip Softphone (TLS and TCP) Cisco IOS Gateways (TCP only) SNOM 360 (TLS only) Zoiper Biz Softphone (TLS and TCP)
sip.conf options
tlsenable=yes - Enable TLS server, default is no tlsbindaddr=<ip address> - Specify IP address to bind TLS server to, default is 0.0.0.0 tlscertfile=</path/to/certificate> - The server's certificate file. Should include the key and certificate. This is mandatory if you're going to run a TLS server. tlscafile=</path/to/certificate> - If the server your connecting to uses a self signed certificate you should have their certificate installed here so the code can verify the authenticity of their certificate. tlscapath=</path/to/ca/dir> - A directory full of CA certificates. The files must be named with the CA subject name hash value. (see man SSL_CTX_load_verify_locations for more info) tlsdontverifyserver=yes - If set to yes, don't verify the servers certificate when acting as a client. If you don't have the server's CA certificate you can set this and it will connect without requiring tlscafile to be set. Default is no. tlscipher=<SSL cipher string> - A string specifying which SSL ciphers to use or not use. A list of valid SSL cipher strings can be found at http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS
Sample config Here are the relevant bits of config for setting up TLS between 2 Asterisk servers. With server_a registering to server_b On server_a:
[general] tlsenable=yes tlscertfile=/etc/asterisk/asterisk.pem tlscafile=/etc/ssl/ca.pem ; This is the CA file used to generate both certificates register => tls://100:[email protected]:5061 [101] type=friend context=internal host=192.168.0.100 ; The host should be either IP or hostname and should ; match the 'common name' field in the servers certificate secret=test dtmfmode=rfc2833 disallow=all allow=ulaw transport=tls port=5061
On server_b:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
537
[general] tlsenable=yes tlscertfile=/etc/asterisk/asterisk.pem [100] type=friend context=internal host=dynamic secret=test dtmfmode=rfc2833 disallow=all allow=ulaw ;You can specify transport= and port=5061 for TLS, but its not necessary in ;the server configuration, any type of SIP transport will work ;transport=tls ;port=5061
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
538
${SPEECH(status)} - Returns 1 if SpeechCreate has been called. This uses the same check that applications do to see if a speech object is setup. If it returns 0 then you know you can not use other speech applications. ${SPEECH(spoke)} - Returns 1 if the speaker spoke something, or 0 if they were silent.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
539
${SPEECH(results)} - Returns the number of results that are available. ${SPEECH_SCORE(result number)} - Returns the score of a result. ${SPEECH_TEXT(result number)} - Returns the recognized text of a result. ${SPEECH_GRAMMAR(result number)} - Returns the matched grammar of the result. SPEECH_ENGINE(name)=value - Sets a speech engine specific attribute.
Dialplan Flow:
1. Create a speech recognition object using SpeechCreate() 2. Activate your grammars using SpeechActivateGrammar(Grammar Name) 3. Call SpeechStart() to indicate you are going to do speech recognition immediately 4. Play back your audio and wait for recognition using SpeechBackground(Sound File|Timeout) 5. Check the results and do things based on them 6. Deactivate your grammars using SpeechDeactivateGrammar(Grammar Name) 7. Destroy your speech recognition object using SpeechDestroy()
Dialplan Examples: This is pretty cheeky in that it does not confirmation of results. As well the way the grammar is written it returns the person's extension instead of their name so we can just do a Goto based on the result text.
Grammar: company-directory.gram
#ABNF 1.0; language en-US; mode voice; tag-format <lumenvox/1.0>; root $company_directory; $josh = ((Joshua | Josh) [Colp]):"6066"; $mark = (Mark [Spencer] | Markster):"4569"; $kevin = (Kevin [Fleming]):"2567"; $company_directory = ($josh | $mark | $kevin) { $ = $$ };
Dialplan logic
extensions.conf
[dial-by-name] exten => s,1,SpeechCreate() exten => s,2,SpeechActivateGrammar(company-directory) exten => s,3,SpeechStart() exten => s,4,SpeechBackground(who-would-you-like-to-dial) exten => s,5,SpeechDeactivateGrammar(company-directory) exten => s,6,Goto(internal-extensions-${SPEECH_TEXT(0)})
Useful Dialplan Tidbits A simple macro that can be used for confirm of a result. Requires some sound files. ARG1 is equal to the file to play back after "I heard..." is played.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
540
extensions.conf
[macro-speech-confirm] exten => s,1,SpeechActivateGrammar(yes_no) exten => s,2,Set(OLDTEXT0=${SPEECH_TEXT(0)}) exten => s,3,Playback(heard) exten => s,4,Playback(${ARG1}) exten => s,5,SpeechStart() exten => s,6,SpeechBackground(correct) exten => s,7,Set(CONFIRM=${SPEECH_TEXT(0)}) exten => s,8,GotoIf($["${SPEECH_TEXT(0)}" = "1"]?9:10) exten => s,9,Set(CONFIRM=yes) exten => s,10,Set(CONFIRMED=${OLDTEXT0}) exten => s,11,SpeechDeactivateGrammar(yes_no)
struct ast_speech *ast_speech_new(char *engine_name, int format) struct ast_speech *speech = ast_speech_new(NULL, AST_FORMAT_SLINEAR);
This will create a new speech structure that will be returned to you. The speech recognition engine name is optional and if NULL the default one will be used. As well for now format should always be AST_FORMAT_SLINEAR. Activating a grammar
int ast_speech_write(struct ast_speech *speech, void *data, int len) res = ast_speech_write(speech, fr->data, fr->datalen);
This writes audio to the speech structure that will then be recognized. It must be written signed linear only at this time. In the future other formats may be
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
541
supported. Checking for results The way the generic speech recognition API is written is that the speech structure will undergo state changes to indicate progress of recognition. The states are outlined below:
AST_SPEECH_STATE_NOT_READY - The speech structure is not ready to accept audio AST_SPEECH_STATE_READY - You may write audio to the speech structure AST_SPEECH_STATE_WAIT - No more audio should be written, and results will be available soon. AST_SPEECH_STATE_DONE - Results are available and the speech structure can only be used again by calling ast_speech_start
It is up to you to monitor these states. Current state is available via a variable on the speech structure. ( state) Knowing when to stop playback If you are playing back a sound file to the user and you want to know when to stop play back because the individual started talking use the following.
ast_test_flag(speech, AST_SPEECH_QUIET) /* This will return a positive value when the person has started talking. */
Getting results
struct ast_speech_result { char *text; int score; char *grammar; struct ast_speech_result *next; };
Freeing a set of results
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
542
int ast_speech_grammar_load(struct ast_speech *speech, char *grammar_name, char *grammar) res = ast_speech_grammar_load(speech, "builtin:yes_no", "yes_no");
Unloading a grammar on a speech structure If you load a grammar on a speech structure it is preferred that you unload it as well, or you may cause a memory leak. Don't say I didn't warn you.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
543
SQLite Tables
/* * res_config_sqlite - SQLite 2 support for Asterisk * * This module can be used as a static/RealTime configuration module, and a CDR * handler. See the Doxygen documentation for a detailed description of the * module, and the configs/ directory for the sample configuration file. */ /* * Tables for res_config_sqlite.so. */ /* * RealTime static table. */ CREATE TABLE ast_config ( id INTEGER, cat_metric INT(11) NOT NULL DEFAULT 0, var_metric INT(11) NOT NULL DEFAULT 0, commented TINYINT(1) NOT NULL DEFAULT 0, filename VARCHAR(128) NOT NULL DEFAULT '', category VARCHAR(128) NOT NULL DEFAULT 'default', var_name VARCHAR(128) NOT NULL DEFAULT '', var_val TEXT NOT NULL DEFAULT '', PRIMARY KEY (id) ); CREATE INDEX ast_config__idx__cat_metric ON ast_config(cat_metric); CREATE INDEX ast_config__idx__var_metric ON ast_config(var_metric); CREATE INDEX ast_config__idx__filename_commented ON ast_config(filename, commented); /* * CDR table (this table is automatically created if non existent). */ CREATE TABLE ast_cdr ( id INTEGER, clid VARCHAR(80) NOT NULL DEFAULT '', src VARCHAR(80) NOT NULL DEFAULT '', dst VARCHAR(80) NOT NULL DEFAULT '', dcontext VARCHAR(80) NOT NULL DEFAULT '', channel VARCHAR(80) NOT NULL DEFAULT '', dstchannel VARCHAR(80) NOT NULL DEFAULT '', lastapp VARCHAR(80) NOT NULL DEFAULT '', lastdata VARCHAR(80) NOT NULL DEFAULT '', start DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', answer DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', end DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', duration INT(11) NOT NULL DEFAULT 0, billsec INT(11) NOT NULL DEFAULT 0, disposition VARCHAR(45) NOT NULL DEFAULT '', amaflags INT(11) NOT NULL DEFAULT 0, accountcode VARCHAR(20) NOT NULL DEFAULT '', uniqueid VARCHAR(32) NOT NULL DEFAULT '', userfield VARCHAR(255) NOT NULL DEFAULT '', PRIMARY KEY (id) ); /* * SIP RealTime table. */ CREATE TABLE ast_sip ( id INTEGER, commented TINYINT(1) NOT NULL DEFAULT 0, name VARCHAR(80) NOT NULL DEFAULT '', host VARCHAR(31) NOT NULL DEFAULT '', nat VARCHAR(5) NOT NULL DEFAULT 'no', type VARCHAR(6) NOT NULL DEFAULT 'friend', accountcode VARCHAR(20) DEFAULT NULL, amaflags VARCHAR(13) DEFAULT NULL, callgroup VARCHAR(10) DEFAULT NULL, callerid VARCHAR(80) DEFAULT NULL, cancallforward CHAR(3) DEFAULT 'yes', directmedia CHAR(3) DEFAULT 'yes', context VARCHAR(80) DEFAULT NULL, defaultip VARCHAR(15) DEFAULT NULL, dtmfmode VARCHAR(7) DEFAULT NULL, fromuser VARCHAR(80) DEFAULT NULL, fromdomain VARCHAR(80) DEFAULT NULL, insecure VARCHAR(4) DEFAULT NULL, language CHAR(2) DEFAULT NULL, mailbox VARCHAR(50) DEFAULT NULL, md5secret VARCHAR(80) DEFAULT NULL, deny VARCHAR(95) DEFAULT NULL, permit VARCHAR(95) DEFAULT NULL, mask VARCHAR(95) DEFAULT NULL,
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
544
musiconhold VARCHAR(100) DEFAULT NULL, pickupgroup VARCHAR(10) DEFAULT NULL, qualify CHAR(3) DEFAULT NULL, regexten VARCHAR(80) DEFAULT NULL, restrictcid CHAR(3) DEFAULT NULL, rtptimeout CHAR(3) DEFAULT NULL, rtpholdtimeout CHAR(3) DEFAULT NULL, secret VARCHAR(80) DEFAULT NULL, setvar VARCHAR(100) DEFAULT NULL, disallow VARCHAR(100) DEFAULT 'all', allow VARCHAR(100) DEFAULT 'g729,ilbc,gsm,ulaw,alaw', fullcontact VARCHAR(80) NOT NULL DEFAULT '', ipaddr VARCHAR(15) NOT NULL DEFAULT '', port INT(11) NOT NULL DEFAULT 0, regserver VARCHAR(100) DEFAULT NULL, regseconds INT(11) NOT NULL DEFAULT 0, username VARCHAR(80) NOT NULL DEFAULT '', PRIMARY KEY (id) UNIQUE (name) ); CREATE INDEX ast_sip__idx__commented ON ast_sip(commented); /* * Dialplan RealTime table. */ CREATE TABLE ast_exten ( id INTEGER, commented TINYINT(1) NOT NULL DEFAULT 0, context VARCHAR(80) NOT NULL DEFAULT '', exten VARCHAR(40) NOT NULL DEFAULT '', priority INT(11) NOT NULL DEFAULT 0, app VARCHAR(128) NOT NULL DEFAULT '', appdata VARCHAR(128) NOT NULL DEFAULT '', PRIMARY KEY (id) );
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
545
CREATE INDEX ast_exten__idx__commented ON ast_exten(commented); CREATE INDEX ast_exten__idx__context_exten_priority ON ast_exten(context, exten, priority);
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
546
As soon as you're done editing that file, log out as the postgres user.
Make sure you have the PostgreSQL odbc driver setup in /etc/odbcinst.ini. Mine looks like:
[PostgreSQL] Description Driver Setup FileUsage = = = = ODBC for PostgreSQL /usr/lib/libodbcpsql.so /usr/lib/libodbcpsqlS.so 1
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
547
[testing] Description Driver Trace TraceFile Database Servername UserName Password Port ReadOnly RowVersioning ShowSystemTables ShowOidColumn FakeOidIndex ConnSettings
= = = = = = = = = = = = = = =
If your ODBC connectivity to PostgreSQL isn't working, you'll see an error message instead, like this:
[jsmith2@localhost tmp]$ echo "select 1" | isql -v testing [S1000][unixODBC]Could not connect to the server; Could not connect to remote socket. [ISQL]ERROR: Could not SQLConnect bash: echo: write error: Broken pipe
Compile Asterisk with support for ODBC voicemail. Go to your Asterisk source directory and run `make menuselect`. Under "Voicemail Build Options", enable "ODBC_STORAGE". See doc/README.odbcstorage for more information
Recompile Asterisk and install the new version.
Once you've recompiled and re-installed Asterisk, check to make sure res_odbc.so has been compiled.
localhost*CLI> show modules like res_odbc.so Module Description res_odbc.so ODBC Resource 1 modules loaded
Use Count 0
Now it's time to get Asterisk configured. First, we need to tell Asterisk about our ODBC setup. Open /etc/asterisk/res_odbc.conf and add the following:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
548
[postgres] enabled => yes dsn => testing pre-connect => yes
At the Asterisk CLI, unload and then load the res_odbc.so module. (You could restart Asterisk as well, but this way makes it easier to tell what's happening.) Notice how it says it's connected to "postgres", which is our ODBC connection as defined in res_odbc.conf, which points to the "testing" DSN in ODBC.
localhost*CLI> unload res_odbc.so Jan 2 21:19:36 WARNING[8130]: res_odbc.c:498 odbc_obj_disconnect: res_odbc: disconnected 0 from postgres [testing] Jan 2 21:19:36 NOTICE[8130]: res_odbc.c:589 unload_module: res_odbc unloaded. localhost*CLI> load res_odbc.so Loaded /usr/lib/asterisk/modules/res_odbc.so => (ODBC Resource) == Parsing '/etc/asterisk/res_odbc.conf': Found Jan 2 21:19:40 NOTICE[8130]: res_odbc.c:266 load_odbc_config: Adding ENV var: INFORMIXSERVER=my_special_database Jan 2 21:19:40 NOTICE[8130]: res_odbc.c:266 load_odbc_config: Adding ENV var: INFORMIXDIR=/opt/informix Jan 2 21:19:40 NOTICE[8130]: res_odbc.c:295 load_odbc_config: registered database handle 'postgres' dsn->[testing] Jan 2 21:19:40 NOTICE[8130]: res_odbc.c:555 odbc_obj_connect: Connecting postgres Jan 2 21:19:40 NOTICE[8130]: res_odbc.c:570 odbc_obj_connect: res_odbc: Connected to postgres [testing] Jan 2 21:19:40 NOTICE[8130]: res_odbc.c:600 load_module: res_odbc loaded.
You can also check the status of your ODBC connection at any time from the Asterisk CLI:
localhost*CLI> odbc show Name: postgres DSN: testing Connected: yes
Now we can setup our voicemail table in PostgreSQL. Log into PostgreSQL and type (or copy and paste) the following:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
549
--- First, let's -CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION
create our large object type, called "lo" loin (cstring) RETURNS lo AS 'oidin' LANGUAGE internal IMMUTABLE STRICT; loout (lo) RETURNS cstring AS 'oidout' LANGUAGE internal IMMUTABLE STRICT; lorecv (internal) RETURNS lo AS 'oidrecv' LANGUAGE internal IMMUTABLE STRICT; losend (lo) RETURNS bytea AS 'oidrecv' LANGUAGE internal IMMUTABLE STRICT;
CREATE TYPE lo ( INPUT = loin, OUTPUT = loout, RECEIVE = lorecv, SEND = losend, INTERNALLENGTH = 4, PASSEDBYVALUE ); CREATE CAST (lo AS oid) WITHOUT FUNCTION AS IMPLICIT; CREATE CAST (oid AS lo) WITHOUT FUNCTION AS IMPLICIT; --- If we're not already using plpgsql, then let's use it! -CREATE TRUSTED LANGUAGE plpgsql; --- Next, let's create a trigger to cleanup the large object table -- whenever we update or delete a row from the voicemessages table -CREATE FUNCTION vm_lo_cleanup() RETURNS "trigger" AS $$ declare msgcount INTEGER; begin -raise notice 'Starting lo_cleanup function for large object with oid %',old.recording; -- If it is an update action but the BLOB (lo) field was not changed, dont do anything if (TG_OP = 'UPDATE') then if ((old.recording = new.recording) or (old.recording is NULL)) then raise notice 'Not cleaning up the large object table, as recording has not changed'; return new; end if; end if; if (old.recording IS NOT NULL) then SELECT INTO msgcount COUNT(*) AS COUNT FROM voicemessages WHERE recording = old.recording; if (msgcount > 0) then raise notice 'Not deleting record from the large object table, as object is still referenced'; return new; else perform lo_unlink(old.recording); if found then raise notice 'Cleaning up the large object table'; return new; else raise exception 'Failed to cleanup the large object table'; return old; end if; end if; else raise notice 'No need to cleanup the large object table, no recording on old row'; return new; end if; end$$ LANGUAGE plpgsql; --- Now, let's create our voicemessages table -- This is what holds the voicemail from Asterisk -CREATE TABLE voicemessages ( uniqueid serial PRIMARY KEY, msgnum int4, dir varchar(80), context varchar(80), macrocontext varchar(80), callerid varchar(40), origtime varchar(40), duration varchar(20), flag varchar(8), mailboxuser varchar(80), mailboxcontext varchar(80), recording lo, label varchar(30), "read" bool DEFAULT false ); --- Let's not forget to make the voicemessages table use the trigger -CREATE TRIGGER vm_cleanup AFTER DELETE OR UPDATE ON voicemessages FOR EACH ROW EXECUTE PROCEDURE vm_lo_cleanup();
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
550
Just as a sanity check, make sure you check the voicemessages table via the isql utility.
[jsmith2@localhost ODBC]$ echo "SELECT uniqueid, msgnum, dir, duration FROM voicemessages WHERE msgnum = 1" | isql testing +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL> +------------+------------+---------------------------------------------------------------------------------+--------------------+ | uniqueid | msgnum | dir | duration | +------------+------------+---------------------------------------------------------------------------------+--------------------+ +------------+------------+---------------------------------------------------------------------------------+--------------------+ SQLRowCount returns 0
Now we can finally configure voicemail in Asterisk to use our database. Open /etc/asterisk/voicemail.conf, and look in the [general] section. I've changed the format to gsm (as I can't seem to get WAV or wav working), and specify both the odbc connection and database table to use.
[general] ; Default formats for writing Voicemail ;format=g723sf|wav49|wav format=gsm odbcstorage=postgres odbctable=voicemessages
You'll also want to create a new voicemail context called "odbctest" to do some testing, and create a sample mailbox inside that context. Add the following to the very bottom of voicemail.conf:
You can check to make sure your new mailbox exists by typing:
localhost*CLI> show voicemail users for odbctest Context Mbox User Zone odbctest 101 Example Mailbox
NewMsg 0
Now, let's add a new context called "odbc" to extensions.conf. We'll use these extensions to do some testing:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
551
setting its context to the [odbc] context we created in the previous step. The relevant section of my sip.conf file looks like:
Status OK (9 ms)
At last, we're finally ready to leave a voicemail message and have it stored in our database! (Who'd have guessed it would be this much trouble?!?) Pick up the phone, dial extension 100, and leave yourself a voicemail message. In my case, this is what appeared on the Asterisk CLI:
localhost*CLI> -- Executing VoiceMail("SIP/linksys-10228cac", "101@odbctest") in new stack -- Playing 'vm-intro' (language 'en') -- Playing 'beep' (language 'en') -- Recording the message -- x=0, open writing: /var/spool/asterisk/voicemail/odbctest/101/tmp/dlZunm format: gsm, 0x101f6534 -- User ended message by pressing # -- Playing 'auth-thankyou' (language 'en') == Parsing '/var/spool/asterisk/voicemail/odbctest/101/INBOX/msg0000.txt': Found
Now, we can check the database and make sure the record actually made it into PostgreSQL, from within the psql utility.
[jsmith2@localhost ~]$ psql Password: Welcome to psql 8.1.4, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit
asterisk=# SELECT * FROM voicemessages; uniqueid | msgnum | dir | context | macrocontext | callerid | origtime | duration | mailboxuser | mailboxcontext | recording | label | read | sip_id | pabx_id | iax_id ----------+--------+--------------------------------------------------+---------+--------------+-----------------------+-----------+----------+-------------+----------------+-----------+-------+------+--------+---------+-------26 | 0 | /var/spool/asterisk/voicemail/odbctest/101/INBOX | odbc | | "linksys" <linksys> | 1167794179 | 7 | 101 | odbctest | 16599 | | f | | | (1 row)
Did you notice the the recording column is just a number? When a recording gets stuck in the database, the audio isn't actually stored in the voicemessages table. It's stored in a system table called the large object table. We can look in the large object table and verify that the object actually exists there:
asterisk=# \lo_list Large objects ID | Description -------+------------16599 | (1 row)
In my case, the OID is 16599. Your OID will almost surely be different. Just make sure the OID number in the recording column in the voicemessages table corresponds with a record in the large object table. (The trigger we added to our voicemessages table was designed to make sure this is always the case.) We can also pull a copy of the voicemail message back out of the database and write it to a file, to help us as we debug things:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
552
We can even listen to the file from the Linux command line:
[jsmith2@localhost tmp]$ play /tmp/odcb-16599.gsm Input Filename : Sample Size : Sample Encoding: Channels : Sample Rate : /tmp/odcb-16599.gsm 8-bits gsm 1 8000 0.0%) Output Buffer: 298.36K
Last but not least, we can pull the voicemail message back out of the database by dialing extension 200 and entering "5555" at the password prompt. You should see something like this on the Asterisk CLI:
localhost*CLI> -- Executing VoiceMailMain("SIP/linksys-10228cac", "101@odbctest") in new stack -- Playing 'vm-password' (language 'en') -- Playing 'vm-youhave' (language 'en') -- Playing 'digits/1' (language 'en') -- Playing 'vm-INBOX' (language 'en') -- Playing 'vm-message' (language 'en') -- Playing 'vm-onefor' (language 'en') -- Playing 'vm-INBOX' (language 'en') -- Playing 'vm-messages' (language 'en') -- Playing 'vm-opts' (language 'en') -- Playing 'vm-first' (language 'en') -- Playing 'vm-message' (language 'en') == Parsing '/var/spool/asterisk/voicemail/odbctest/101/INBOX/msg0000.txt': Found -- Playing 'vm-received' (language 'en') -- Playing 'digits/at' (language 'en') -- Playing 'digits/10' (language 'en') -- Playing 'digits/16' (language 'en') -- Playing 'digits/p-m' (language 'en') -- Playing '/var/spool/asterisk/voicemail/odbctest/101/INBOX/msg0000' (language 'en') -- Playing 'vm-advopts' (language 'en') -- Playing 'vm-repeat' (language 'en') -- Playing 'vm-delete' (language 'en') -- Playing 'vm-toforward' (language 'en') -- Playing 'vm-savemessage' (language 'en') -- Playing 'vm-helpexit' (language 'en') -- Playing 'vm-goodbye' (language 'en')
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
553
Timing Interfaces
Asterisk Timing Interfaces
In the past, if internal timing were desired for an Asterisk system, then the only source acceptable was from DAHDI. Beginning with Asterisk 1.6.1, a new timing API was introduced which allows for various timing modules to be used. Asterisk includes the following timing modules:
Historical Note At the time of Asterisk 1.4's release, Zaptel (now DAHDI) was used to provide timing to Asterisk, either by utilizing telephony hardware installed in the computer or via ztdummy (a kernel module) when no hardware was available. When DAHDI was first released, the ztdummy kernel module was renamed to dahdi_dummy. As of DAHDI Linux 2.3.0 the dahdi_dummy mod ule has been removed and its functionality moved into the main dahdi kernel module. As long as the dahdi module is loaded, it will provide timing to Asterisk either through installed telephony hardware or utilizing the kernel timing facilities when separate hardware is not available.
res_timing_timerfd uses a timing mechanism provided directly by the Linux kernel. This timing interface is only available on Linux systems using a kernel version at least 2.6.25 and a glibc version at least 2.8. This interface has the benefit of being very efficient, but at the time this is being written, it is a relatively new feature on Linux, meaning that its availability is not widespread. res_timing_kqueue uses the Kqueue event notification system introduced with FreeBSD 4.1. It can be used on operating systems that support Kqueue, such as OpenBSD and Mac OS X. Because Kqueue is not available on Linux, this module will not compile or be available there.
Customizations/Troubleshooting
Now that you know Asterisk's default preferences for timing modules, you may decide that you have a different preference. Maybe you're on a timerfd-capable system but you would prefer to get your timing from DAHDI since you already are using DAHDI to drive your hardware. Alternatively, you may have been directed to this document due to an error you are currently experiencing with Asterisk. If you receive an error message regarding timing not working correctly, then you can use one of the following suggestions to disable a faulty timing module.
1. Don't build the timing modules you know you will not use. You can disable the compilation of any of the timing modules using menusele ct. The modules are listed in the "Resource Modules" section. Note that if you have already built Asterisk and have received an error about a timing module not working properly, it is not sufficient to disable it from being built. You will need to remove the module from your modules directory (by default, /usr/lib/asterisk/modules) to make sure that it does not get loaded again. 2. Build, but do not load the timing modules you know you will not use. You can edit modules.conf using noload directives to disable the loading of specific timing modules by default. Based on the note in the section above, you may realize that your Asterisk setup does not
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
554
2. require internal timing at all. If this is the case, you can safely noload all timing modules.
Some confusion has arisen regarding the fact that non-DAHDI timing interfaces are available now. One common misconception which has arisen is that since timing can be provided elsewhere, DAHDI is no longer required for using the MeetMe application. Unfortunately, this is not the case. In addition to providing timing, DAHDI also provides a conferencing engine which the MeetMe application requires. Starting with Asterisk 1.6.2, however, there is a new application, ConfBridge, which is capable of conference bridging without the use of DAHDI's built-in mixing engine.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
555
./configure --with-hoard=/usr/src/hoard-371/src/
Note that we don't specify the full path to libhoard.so, just the directory where it resides. Enable Hoard in menuselect Run 'make menuselect' in the root of the asterisk source distribution. Under 'Compiler Flags' select the 'USE_HOARD_ALLOCATOR' option. If the option is not available (shows up with XXX next to it) this means that configure was not able to find libhoard.so. Check that the path you passed to the --with-hoard option is correct. Re-run ./configure with the correct option and then repeat this step. Make and install asterisk Run the standard build commands:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
556
Video Console
Video Console Support in Asterisk
Some console drivers (at the moment chan_oss.so) can be built with support for sending and receiving video. In order to have this working you need to perform the following steps: Enable building the video_console support The simplest way to do it is add this one line to channels/Makefile:
chan_oss.so: _ASTCFLAGS+=-DHAVE_VIDEO_CONSOLE
Install prerequisite packages The video_console support relies on the presence of SDL, SDL_image and ffmpeg libraries, and of course on the availability of X11 On Linux, these are supplied by
;[general](+,my_video,skin2)
You also need to manually copy the two files
images/kpad2.jpg images/font.png
into the places specified in oss.conf, which in the sample are set to
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
557
[general](+) videosupport=yes allow=h263 ; this or other video formats allow=h263p ; this or other video formats
You can add other video formats e.g. h261, h264, mpeg if they are supported by your version of libavcodec. Run the Program Run asterisk in console mode e.g. asterisk -vdc If video console support has been successfully compiled in, then you will see the "console startgui" command available on the CLI interface. Run the command, and you should see a window like this http://info.iet.unipi.it/~luigi/asterisk_video_console.jpg To exit from this window, in the console run "console stopgui". If you want to start a video call, you need to configure your dialplan so that you can reach (or be reachable) by a peer who can support video. Once done, a video call is the same as an ordinary call: "console dial ...", "console answer", "console hangup" all work the same. To use the GUI, and also configure video sources, see the next section. Video Sources Video sources are declared with the "videodevice=..." lines in oss.conf where the ... is the name of a device (e.g. /dev/video0 ...) or a string starting with X11 which identifies one instance of an X11 grabber. You can have up to 9 sources, displayed in thumbnails in the gui, and select which one to transmit, possibly using Picture-in-Picture. For webcams, the only control you have is the image size and frame rate (which at the moment is the same for all video sources). X11 grabbers capture a region of the X11 screen (it can contain anything, even a live video) and use it as the source. The position of the grab region can be configured using the GUI below independently for each video source. The actual video sent to the remote side is the device selected as "primary" (with the mouse, see below), possibly with a small 'Picture-in-Picture' of the "secondary" device (all selectable with the mouse). GUI Commands and Video Sources (most of the text below is taken from channels/console_gui.c) The GUI is made of 4 areas: remote video on the left, local video on the right, keypad with all controls and text windows in the center, and source device thumbnails on the top. The top row is not displayed if no devices are specified in the config file.
________________________________________________________________ | ______ ______ ______ ______ ______ ______ ______ | | | tn.1 | | tn.2 | | tn.3 | | tn.4 | | tn.5 | | tn.6 | | tn.7 | | | |______| |______| |______| |______| |______| |______| |______| | | ______ ______ ______ ______ ______ ______ ______ | | |______| |______| |______| |______| |______| |______| |______| | | _________________ __________________ _________________ | | | | | | | | | | | | | | | | | | | | | | | | | | | remote video | | | | local video | | | | | | | | ______ | | | | | | keypad | | | PIP || | | | | | | | |______|| | | |_________________| | | |_________________| | | | | | | | | | | |__________________| | |________________________________________________________________|
The central section is built using an image (jpg, png, maybe gif too) for the skin and other GUI elements. Comments embedded in the image indicate to what function each area is mapped to. Another image (png with transparency) is used for the font. Mouse and keyboard events are detected on the whole surface, and handled differently according to their location:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
558
Center/right click on the local/remote window are used to resize the corresponding window Clicks on the thumbnail start/stop sources and select them as primary or secondary video sources Drag on the local video window are used to move the captured area (in the case of X11 grabber) or the picture-in-picture position Keystrokes on the keypad are mapped to the corresponding key; keystrokes are used as keypad functions, or as text input if we are in text-input mode. Drag on some keypad areas (sliders etc.) are mapped to the corresponding functions (mute/unmute audio and video, enable/disable Picture-in-Picture, freeze the incoming video, dial numbers, pick up or hang up a call, ...)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
559
Video Telephony
Asterisk and Video telephony
Asterisk supports video telephony in the core infrastructure. Internally, it's one audio stream and one video stream in the same call. Some channel drivers and applications has video support, but not all. Codecs and formats Asterisk supports the following video codecs and file formats. There's no video transcoding so you have to make sure that both ends support the same video format. Codec H.263 H.264 H.261 Format read/write read/write Passthrough only Notes
Note that the file produced by Asterisk video format drivers is in no generic video format. Gstreamer has support for producing these files and converting from various video files to Asterisk video+audio files. Note that H.264 is not enabled by default. You need to add that in the channel configuration file. Channel Driver Support Channel Driver SIP Module chan_sip.so Notes The SIP channel driver (chan_sip.so) has support for video Supports video calls (over trunks too) Forwards video calls as a proxy channel Forwards video calls as a proxy channel Has support for video display/decoding, see video_console.txt
Applications This is not yet a complete list. These dialplan applications are known to handle video:
Voicemail - Video voicemail storage (does not attach video to e-mail) Record - Records audio and video files (give audio format as argument) Playback - Plays a video while being instructed to play audio Echo - Echos audio and video back to the user
There is a development group working on enhancing video support for Asterisk. If you want to participate, join the asterisk-video mailing list on http://lists.digium.com Updates to this file are more than welcome!
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
560
Dependencies To use pbx_lua, the lua development libraries must be installed before Asterisk is configured and built. You can get these libraries directly from h ttp://lua.org, but it is easier to install them using your distribution's package management tool. The package is probably named liblua5.1-dev, liblua-dev, or lua-devel depending on your linux distribution.
extensions.lua
extensions = { default = { ["100"] = function(context, extension) app.playback("please-hold") app.dial("SIP/100", 60) end; ["101"] = function(c, e) app.dial("SIP/101", 60) end; }
The extensions.lua file can be reloaded by reloading the pbx_lua module.
Runtime errors are logged and the channel on which the error occurred is hung up.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
561
Extension Patterns
Extension pattern matching syntax on logic works the same for extensions.conf and extensions.lua.
extensions.conf
[users] exten => _1XX,1,Dial(SIP/${EXTEN}) exten => _2XX,1,Voicemail(${EXTEN:1})
extensions.lua
extensions = {} extensions.users = {} extensions.users["_1XX"] = function(c, e) app.dial("SIP/" .. e) end extensions.users["_2XX"] = function(c, e) app.voicemail("1" .. e:sub(2)) end
Context Includes
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
562
extensions.conf
[users] exten => 100,1,Noop exten => 100,n,Dial("SIP/100") [demo] exten => s,1,Noop exten => s,n,Playback(demo-congrats) [default] include => demo include => users
extensions.lua
extensions = { users = { [100] = function() app.dial("SIP/100") end; }; demo = { ["s"] = function() app.playback(demo-congrats) end; }; default = { include = {"demo", "users"}; }; }
Loops extensions.conf
exten exten exten exten exten => => => => => 100,1,Noop 100,n,Set(i=0) 100,n,While($[i < 10]) 100,n,Verbose(i = ${i}) 100,n,EndWhile
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
563
extensions.lua
i = 0 while i < 10 do app.verbose("i = " .. i) end
Variables extensions.conf
exten => 100,1,Set(my_variable=my_value) exten => 100,n,Verbose(my_variable = ${my_variable})
extensions.lua
channel.my_variable = "my_value" app.verbose("my_variable = " .. channel.my_variable:get())
Applications extensions.conf
exten => 100,1,Dial("SIP/100",,m)
extensions.lua
app.dial("SIP/100", nil, "m")
Macros/GoSub
Macros can be defined in pbx_lua by naming a context 'macro-*' just as in extensions.conf, but generally where you would use macros or gosub in ext ensions.conf you would simply use a function in lua.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
564
extensions.conf
[macro-dial] exten => s,1,Noop exten => s,n,Dial(${ARG1}) [default] exten => 100,1,Macro(dial,SIP/100)
extensions.lua
extensions = {} extensions.default = {} function dial(resource) app.dial(resource) end extensions.default[100] = function() dial("SIP/100") end
Goto
While Goto is an extenstions.conf staple, it should generally be avoided in pbx_lua in favor of functions.
extensions.conf
[default] exten => 100,1,Goto(102,1) exten => 102,1,Playback("demo-thanks") exten => 102,n,Hangup
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
565
extensions.lua
extensions = {} extensions.default = {} function do_hangup() app.playback("demo-thanks") app.hangup() end extensions.default[100] = function() do_hangup() end
The app.goto() function will not work as expected in pbx_lua in Asterisk 1.8. If you must use app.goto() you must manually return control back to asterisk using return from the dialplan extension function, otherwise execution will continue after the call to app.goto(). Calls to app .goto() should work as expected in Asterisk 10 but still should not be necessary in most cases.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
566
Dialplan Applications
extensions.lua
app.playback("please-hold") app.dial("SIP/100", nil, "m")
Any dialplan application can be executed using the app table. Application names are case insensitive. Arguments are passed to dialplan applications just as arguments are passed to functions in lua. String arguments must be quoted as they are lua strings. Empty arguments may be passed as nil or as empty strings.
Channel Variables
Set a Variable
channel.my_variable = "my_value"
After this the channel variable ${my_variable} contains the value "my_value".
Read a Variable
value = channel.my_variable:get()
Any channel variable can be read and set using the channel table. Local and global lua variables can be used as they normally would and are completely unrelated to channel variables.
value = channel.my_variable -- does not work as expected (value:get() could be used to get the value after this line)
If the variable name contains characters that lua considers special use the [] operator to access them.
Dialplan Functions
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
567
If the function name contains characters that lua considers special use the [] operator to access them.
channel.FAXOPT("modems") = "v17,v27,v29" -- syntax error value = channel.FAXOPT("modems") -- does not work as expected (value:get() could be used to get the value after this line)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
568
extensions.lua
extensions = {} extensions.default = {} function sip_exten(e) return function() app.dial("SIP/" .. e) end end extensions.default[100] = sip_exten(100) extensions.default[101] = sip_exten(101)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
569
function print(...) local msg = "" for i=1,select('#', ...) do if i == 1 then msg = msg .. tostring(select(i, ...)) else msg = msg .. "\t" .. tostring(select(i, ...)) end end app.verbose(msg) end
Compile extensions.lua
The luac program can be used to compile your extensions.lua file into lua bytecode. This will slightly increase performance as pbx_lua will no longer need to parse extensions.lua on load. The luac compiler will also detect and report any syntax errors. To use luac, rename your extensions.lua f ile and then run luac as follows.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
570
extensions.lua
hints = { default = { ["100"] = "SIP/100"; }; office = { ["500"] = "SIP/500"; }; home = { ["200"] = "SIP/200"; ["201"] = "SIP/201"; }; }
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
571
Less Clutter
Instead of defining every extension inline, you can use this method to create a neater extensions.lua file. Since the extensions table and each context are both normal lua tables, you can treat them as such and build them piece by piece.
extensions.lua
-- this function serves as an extension function directly function call_user(c, user) app.dial("SIP/" .. user, 60) end -- this function returns an extension function function call_sales_queue(queue) return function(c, e) app.queue(queue) end end e = {} e.default = {} e.default.include = {"users", "sales"} e.users = {} e.users["100"] = call_user e.users["101"] = call_user e.sales = {} e.sales["5000"] = call_sales_queue("sales1") e.sales["6000"] = call_sales_queue("sales2") extensions = e
Less Clutter v2
In this example, we use a fancy function to register extensions.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
572
extensions.lua
function register(context, extension, func) if not extensions then extensions = {} end if not extensions[context] then extensions[context] = {} end extensions[context][extension] = func end function include(context, included_context) if not extensions then extensions = {} end if not extensions[context] then extensions[context] = {} end if not extensions[context].include then extensions[context].include = {} end table.insert(extensions[context].include, included_context) end -- this function serves as an extension function directly function call_user(c, user) app.dial("SIP/" .. user, 60) end -- this function returns an extension function function call_sales_queue(queue) return function(c, e) app.queue(queue) end end include("default", "users") include("default", "sales") register("users", "100", call_user) register("users", "101", call_user) register("sales", "5000", call_sales_queue("sales1")) register("sales", "6000", call_sales_queue("sales2")) register("sales", "7000", function() app.queue("sales3") end)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
573
extensions.default["1234"]("default", "1234")
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
574
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
575
Introduction
This chapter aims to explain how to use some of the features available to manipulate party ID information. It will not delve into specific channel configuration options described in the respective sample configuration files. The party ID information can consist of Caller ID, Connected Line ID, redirecting to party ID information, and redirecting from party ID information. Meticulous control is needed particularly when interoperating between different channel technologies.
Caller ID: The Caller ID information describes who is originating a call. Connected Line ID: The Connected Line ID information describes who is connected to the other end of a call while a call is established. Unlike Caller ID, the connected line information can change over the life of a call when call transfers are performed. The connected line information can also change in either direction because either end could transfer the call. For ISDN it is known as Connected Line Identification Presentation (COLP), Connected Line Identification Restriction (COLR), and Explicit Call Transfer (ECT). For SIP it is known either as P-Asserted-Identity or Remote-Party-Id. Redirecting information: When a call is forwarded, the call originator is informed that the call is redirecting-to a new destination. The new destination is also informed that the incoming call is redirecting-from the forwarding party. A call can be forwarded repeatedly until a new destination answers it or a forwarding limit is reached.
Tools available
Asterisk contains several tools for manipulating the party ID information for a call. Additional information can be found by using the 'core show function' or 'core show application' console commands at the Asterisk CLI. The following list identifies some of the more common tools for manipulating the party ID information:
CALLERID(datatype,caller-id) CONNECTEDLINE(datatype,i) REDIRECTING(datatype,i) Dial() and Queue() dialplan application 'I' option Interception macros Channel driver specific configuration options.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
576
sent when the call is answered. You can use it to send new connected line information to the remote party on the channel when a call is transferred. The CONNECTEDLINE information is passed when the call is answered and when the call is transferred.
It is up to the channel technology to determine when to act upon connected line updates before the call is answered. ISDN will just store the updated information until the call is answered. SIP will immediately update the caller with a Re-INVITE.
Since the connected line information can be sent while a call is connected, you may need to prevent the channel driver from acting on a partial update. The 'i' option is used to inhibit the channel driver from sending the changed information immediately.
Setup the REDIRECTING(to-xxx) values to be sent to the caller. Setup the REDIRECTING(from-xxx) values to be sent to the new destination. Increment the REDIRECTING(count). Set the REDIRECTING(reason). Dial() the new destination.
Interception macros
WARNING Interception macros have been deprecated in Asterisk 11 due to deprecation of Macro. Users of the interception functionality should plan to migrate to Interception routines.
The interception macros give the administrator an opportunity to alter connected line and redirecting information before the channel driver is given the information. If the macro does not change a value then that is what is going to be passed to the channel driver. The tag string available in CALLERID, CONNECTEDLINE, and REDIRECTING is useful for the interception macros to provide some information about where the information originally came from.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
577
The 'i' option of the CONNECTEDLINE dialplan function should always be used in the CONNECTED_LINE interception macros. The interception macro always passes the connected line information on to the channel driver when the macro exits. Similarly, the 'i' option of the REDIRECTING dialplan function should always be used in the REDIRECTING interception macros.
${REDIRECTING_CALLEE_SEND_MACRO} Macro to call before sending a redirecting update to the callee. This macro may never be needed since the redirecting updates should only go from the callee to the caller direction. It is available for completeness. ${REDIRECTING_CALLEE_SEND_MACRO_ARGS} Arguments to pass to ${REDIRECTING_CALLEE_SEND_MACRO}. ${REDIRECTING_CALLER_SEND_MACRO} Macro to call before sending a redirecting update to the caller. ${REDIRECTING_CALLER_SEND_MACRO_ARGS} Arguments to pass to ${REDIRECTING_CALLER_SEND_MACRO}. ${CONNECTED_LINE_CALLEE_SEND_MACRO} Macro to call before sending a connected line update to the callee. ${CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS} Arguments to pass to ${CONNECTED_LINE_CALLEE_SEND_MACRO}. ${CONNECTED_LINE_CALLER_SEND_MACRO} Macro to call before sending a connected line update to the caller. ${CONNECTED_LINE_CALLER_SEND_MACRO_ARGS} Arguments to pass to ${CONNECTED_LINE_CALLER_SEND_MACRO}.
Interception routines
As Interception routines are implemented internally using the Gosub application, all routines should end with an explicit call to the Return applica tion.
The interception routines give the administrator an opportunity to alter connected line and redirecting information before the channel driver is given the information. If the routine does not change a value then that is what is going to be passed to the channel driver. The tag string available in CALLERID, CONNECTEDLINE, and REDIRECTING is useful for the interception routines to provide some information about where the information originally came from. The 'i' option of the CONNECTEDLINE dialplan function should always be used in the CONNECTED_LINE interception routines. The interception routine always passes the connected line information on to the channel driver when the routine returns. Similarly, the 'i' option of the REDIRECTING dialplan function should always be used in the REDIRECTING interception routines.
Note that Interception routines do not attempt to draw a distinction between caller/callee. As it turned out, it was not a good thing to distinguish since transfers make a mockery of caller/callee.
${REDIRECTING_SEND_SUB} Subroutine to call before sending a redirecting update to the party. ${REDIRECTING_SEND_SUB_ARGS} Arguments to pass to ${REDIRECTING_CALLEE_SEND_SUB}. ${CONNECTED_LINE_SEND_SUB} Subroutine to call before sending a connected line update to the party. ${CONNECTED_LINE_SEND_SUB_ARGS} Arguments to pass to ${CONNECTED_LINE_SEND_SUB}.
Manipulation examples
The following examples show several common scenarios in which you may need to manipulate party ID information from the dialplan.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
578
Simple redirection
exten => 1000,1,NoOp ; For Q.SIG or ISDN point-to-point we should determine the COLR for this ; extension and send it if the call was redirected here. exten => 1000,n,GotoIf($[${REDIRECTING(count)}>0]?redirected:notredirected) exten => 1000,n(redirected),Set(REDIRECTING(to-num,i)=${CALLERID(dnid)}) exten => 1000,n,Set(REDIRECTING(to-num-pres)=allowed) exten => 1000,n(notredirected),NoOp ; Determine that the destination has forwarded the call. ; ... exten => 1000,n,Set(REDIRECTING(from-num,i)=1000) exten => 1000,n,Set(REDIRECTING(from-num-pres,i)=allowed) exten => 1000,n,Set(REDIRECTING(to-num,i)=2000) ; The DivertingLegInformation3 message is needed because at this point ; we do not know the presentation (COLR) setting of the redirecting-to ; party. exten => 1000,n,Set(REDIRECTING(count,i)=$[${REDIRECTING(count)} + 1]) exten => 1000,n,Set(REDIRECTING(reason,i)=cfu) ; The call will update the redirecting-to presentation (COLR) when it ; becomes available with a redirecting update. exten => 1000,n,Dial(DAHDI/g1/2000,20) exten => 1000,n,Hangup
IVR that updates connected name on each selection made. Disguise the true number of an individual with a generic company number. Use interception macros to make outbound connected number E.164 formatted. You can do a lot more in an interception macro than just manipulate party information...
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
579
Troubleshooting tips
For CONNECTEDLINE and REDIRECTING, check the usage of the 'i' option. Check channel configuration settings. The default settings may not be what you want or expect. Check packet captures. Your equipment may not support what Asterisk sends.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
580
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
581
The arrows indicate the direction of audio flow. Each channel has a write path (the top arrow) and a read path (the bottom arrow). In this setup, PLC can be used when sending audio to A, but it cannot be used when sending audio to B. The reason is simple, the write path to A's channel contains a slin step, but the write path to B contains no slin step. Such a translation setup is perfectly valid, and Asterisk can potentially set up such a path depending on circumstances. When we use PLC, however, we want slin audio to be present on the write paths of both A and B. A visual representation of what we want is the following: Fig. 2
A ----------- B <-ulaw<-slin| |slin->GSM-> | Asterisk | ulaw->slin->| |<-slin<-GSM -----------
In this scenario, the write paths for both A and B begin with slin, and so PLC may be applied to either channel. This translation behavior has, in the past been doable with the transcode_via_sln option in asterisk.conf. Recent changes to the PLC code have also made the genericplc option in codecs.conf imply the transcode_via_sln option. The result is that by enabling genericplc in codecs.conf, the translation path set up in Fig. 2 should automatically be used.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
582
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
583
1. 2. 3. 4.
Enable genericplc in the plc section of codecs.conf Enable (and potentially force) jitter buffers on channels Two channels must be bridged together for PLC to be used (no Meetme or one-legged calls) The audio must be translated between the two channels and must have slin as a step in the translation process.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
584
PLC Tips
One of the restrictions mentioned is that PLC will only be used when two audio channels are bridged together. Through the use of Local channels, you can create a bridge even if the call is, for all intents and purposes, one-legged. By using a combination of the /n and /j suffixes for a Local channel, one can ensure that the Local channel is not optimized out of the talk path and that a jitter buffer is applied to the Local channel as well. Consider the following simple dialplan:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
585
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
586
Configuration of phoneprov.conf
The configuration file, phoneprov.conf, is used to set up the built-in variables SERVER and SERVER_PORT, to define a default phone profile to use, and to define different phone profiles available for provisioning.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
587
[polycom] staticdir => configs/ mime_type => text/xml setvar => CUSTOM_CONFIG=/var/lib/asterisk/phoneprov/configs/custom.cfg static_file => bootrom.ld,application/octet-stream static_file => bootrom.ver,plain/text static_file => sip.ld,application/octet-stream static_file => sip.ver,plain/text static_file => sip.cfg static_file => custom.cfg ${TOLOWER(${MAC})}.cfg => 000000000000.cfg ${TOLOWER(${MAC})}-phone.cfg => 000000000000-phone.cfg config/ ${TOLOWER(${MAC})} => polycom.xml ${TOLOWER(${MAC})}-directory.xml => 000000000000-directory.xml
A static_file is set by specifying the file name, relative to AST_DATA_DIR/phoneprov. The mime-type of the file can optionally be specified after a comma. If staticdir is set, all static files will be relative to the subdirectory of AST_DATA_DIR/phoneprov specified. Since phone-specific config files generally have file names based on phone-specifc data, dynamic filenames in res_phoneprov can be defined with Asterisk dialplan function and variable substitution. In the above example, ${TOLOWER(${MAC})}.cfg = 000000000000.cfg would define a relative URI to be served that matches the format of MACADDRESS.cfg, all lower case. A request for that file would then point to the template found at AST_DATA_DIR/phoneprov/000000000000.cfg. The template can be followed by a comma and mime-type. Notice that the dynamic filename (URI) can contain contain directories. Since these files are dynamically generated, the config file itself does not reside on the filesystem-only the template. To view the generated config file, open it in a web browser. If the config file is XML, Firefox should display it. Some browsers will require viewing the source of the page requested. A default mime-type for the profile can be defined by setting mime-type. If a custom variable is required for a template, it can be specified with setvar. Variable substitution on this value is done while building the route list, so ${USERNAME} would expand to the username of the users.conf user that registers the dynamic filename.
Any dialplan function that is used for generation of dynamic file names MUST be loaded before res_phoneprov. Add "preload = modulename.so" to modules.conf for required functions. In the example above, "preload = func_strings.so" would be required.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
588
Configuration of users.conf
The asterisk-gui sets up extensions, SIP/IAX2 peers, and a host of other settings. User-specific settings are stored in users.conf. If the asterisk-gui is not being used, manual entries to users.conf can be made.
Individual Users
To enable auto-provisioning of a phone, the user in users.conf needs to have:
[6001] callwaiting = yes context = numberplan-custom-1 hasagent = no hasdirectory = yes hasiax = no hasmanager = no hassip = yes hasvoicemail = yes host = dynamic mailbox = 6001 threewaycalling = yes deletevoicemail = no autoprov = yes profile = polycom directmedia = no nat = no fullname = User Two ; ${DISPLAY_NAME} secret = test ; ${SECRET} username = 6001 ; ${USERNAME} macaddress = deadbeef4dad ; ${MAC} label = 6001 ; ${LABEL} cid_number = 6001 ; ${CALLERID}
The variables above, are the user-specfic variables that can be substituted into dynamic filenames and config templates.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
589
<?xml version="1.0" standalone="yes"?> <APPLICATION APP_FILE_PATH="sip.ld" CONFIG_FILES="${IF($[${STAT(e,${CUSTOM_CONFIG})}] ? "custom.cfg, ")}config/${TOLOWER(${MAC})}, sip.cfg" MISC_FILES="" LOG_FILE_DIRECTORY="" />
This template uses dialplan functions, expressions, and a couple of variables to generate a config file to instruct the Polycom where to pull other needed config files. If a phone with MAC address 0xDEADBEEF4DAD requests this config file, and the filename that is stored in variable CUSTOM_CONFIG does not exist, then the generated output would be:
<?xml version="1.0" standalone="yes"?> <APPLICATION APP_FILE_PATH="sip.ld" CONFIG_FILES="config/deadbeef4dad, sip.cfg" MISC_FILES="" LOG_FILE_DIRECTORY="" />
The Polycom phone would then download both sip.cfg (which would be registered in phoneprov.conf as a static file) and config/deadbeef4dad (which would be registered as a dynamic file pointing to another template, polycom.xml). res_phoneprov also registers its own dialplan function: PP_EACH_USER. This function was designed to be able to print out a particular string for each user that res_phoneprov knows about. An example use of this function is the template for a Polycom contact directory:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
590
[general] enabled = yes bindaddr = 192.168.1.1 ; Your IP here bindport = 8088 ; Or port 80 if it is the only http server running on the machine
With phoneprov.conf and users.conf in place, start Astersik. From the CLI, type "http show status". An example output:
HTTP Server Status: Prefix: /asterisk Server Enabled and Bound to 192.168.1.1:8088 Enabled URI's: /asterisk/httpstatus => Asterisk HTTP General Status /asterisk/phoneprov/... => Asterisk HTTP Phone Provisioning Tool /asterisk/manager => HTML Manager Event Interface /asterisk/rawman => Raw HTTP Manager Event Interface /asterisk/static/... => Asterisk HTTP Static Delivery /asterisk/mxml => XML Manager Event Interface Enabled Redirects: None. POST mappings: None.
There should be a phoneprov URI listed. Next, from the CLI, type "phoneprov show routes" and verify that the information there is correct. An example output for Polycom phones woud look like:
Static routes Relative URI Physical location sip.ver configs/sip.ver sip.ld configs/sip.ld bootrom.ver configs/bootrom.ver sip.cfg configs/sip.cfg bootrom.ld configs/bootrom.ld custom.cfg configs/custom.cfg Dynamic routes Relative URI Template deadbeef4dad.cfg 000000000000.cfg deadbeef4dad-directory.xml 000000000000-directory.xml deadbeef4dad-phone.cfg 000000000000-phone.cfg config/deadbeef4dad polycom.xml
With the above examples, the phones would be pointed to: http://192.168.1.1:8080/asterisk/phoneprov for pulling config files. Templates would all be placed in AST_DATA_DIR/phoneprov and static files would be placed in AST_DATA_DIR/phoneprov/configs. Examples of valid URIs would be:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
591
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
592
License Information
License Information
Asterisk is distributed under the GNU General Public License version 2 and is also available under alternative licenses negotiated directly with Digium, Inc. If you obtained Asterisk under the GPL, then the GPL applies to all loadable Asterisk modules used on your system as well, except as defined below. The GPL (version 2) is included in this source tree in the file COPYING. This package also includes various components that are not part of Asterisk itself; these components are in the 'contrib' directory and its subdirectories. These components are also distributed under the GPL version 2 as well. Digium, Inc. (formerly Linux Support Services) holds copyright and/or sufficient licenses to all components of the Asterisk package, and therefore can grant, at its sole discretion, the ability for companies, individuals, or organizations to create proprietary or Open Source (even if not GPL) modules which may be dynamically linked at runtime with the portions of Asterisk which fall under our copyright/license umbrella, or are distributed under more flexible licenses than GPL. If you wish to use our code in other GPL programs, don't worry - there is no requirement that you provide the same exception in your GPL'd products (although if you've written a module for Asterisk we would strongly encourage you to make the same exception that we do). Specific permission is also granted to link Asterisk with OpenSSL, OpenH323 and/or the UW IMAP Toolkit and distribute the resulting binary files. In addition, Asterisk implements two management/control protocols: the Asterisk Manager Interface (AMI) and the Asterisk Gateway Interface (AGI). It is our belief that applications using these protocols to manage or control an Asterisk instance do not have to be licensed under the GPL or a compatible license, as we believe these protocols do not create a 'derivative work' as referred to in the GPL. However, should any court or other judiciary body find that these protocols do fall under the terms of the GPL, then we hereby grant you a license to use these protocols in combination with Asterisk in external applications licensed under any license you wish. The 'Asterisk' name and logos are trademarks owned by Digium, Inc., and use of them is subject to our trademark licensing policies. If you wish to use these trademarks for purposes other than simple redistribution of Asterisk source code obtained from Digium, you should contact our licensing department to determine the necessary steps you must take. For more information on this policy, please read: http://www.digium.com/en/company/profile/trademarkpoli cy.php If you have any questions regarding our licensing policy, please contact us: +1.877.344.4861 (via telephone in the USA) +1.256.428.6000 (via telephone outside the USA) +1.256.864.0464 (via FAX inside or outside the USA) IAX2/pbx.digium.com (via IAX2) [email protected] (via email) Digium, Inc. 445 Jan Davis Drive NW Huntsville, AL 35806 United States
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
593
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
594
PLEASE READ THE FOLLOWING IMPORTANT SECURITY RELATED INFORMATION. IMPROPER CONFIGURATION OF ASTERISK COULD ALLOW UNAUTHORIZED USE OF YOUR FACILITIES, POTENTIALLY INCURRING SUBSTANTIAL CHARGES.
Asterisk security involves both network security (encryption, authentication) as well as dialplan security (authorization - who can access services in your pbx). If you are setting up Asterisk in production use, please make sure you understand the issues involved.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
595
Network Security
Network Security
If you install Asterisk and use the "make samples" command to install a demonstration configuration, Asterisk will open a few ports for accepting VoIP calls. Check the channel configuration files for the ports and IP addresses. If you enable the manager interface in manager.conf, please make sure that you access manager in a safe environment or protect it with SSH or other VPN solutions. For all TCP/IP connections in Asterisk, you can set ACL lists that will permit or deny network access to Asterisk services. Please check the "permit" and "deny" configuration options in manager.conf and the VoIP channel configurations - i.e. sip.conf and iax.conf. The IAX2 protocol supports strong RSA key authentication as well as AES encryption of voice and signaling. The SIP channel supports TLS encryption of the signaling, as well as SRTP (encrypted media).
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
596
Dialplan Security
Dialplan Security
First and foremost remember this:
USE THE EXTENSION CONTEXTS TO ISOLATE OUTGOING OR TOLL SERVICES FROM ANY INCOMING CONNECTIONS.
You should consider that if any channel, incoming line, etc can enter an extension context that it has the capability of accessing any extension within that context. Therefore, you should NOT allow access to outgoing or toll services in contexts that are accessible (especially without a password) from incoming channels, be they IAX channels, FX or other trunks, or even untrusted stations within you network. In particular, never ever put outgoing toll services in the "default" context. To make things easier, you can include the "default" context within other private contexts by using:
[longdistance] exten => _91NXXNXXXXXX,1,Dial(DAHDI/g2/${EXTEN:1}) include => local [local] exten => _9NXXNXXX,1,Dial(DAHDI/g2/${EXTEN:1}) include => default [default] exten => 6123,Dial(DAHDI/1)
DON'T FORGET TO TAKE THE DEMO CONTEXT OUT OF YOUR DEFAULT CONTEXT. There isn't really a security reason, it just will keep people from wanting to play with your Asterisk setup remotely.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
597
Log Security
Log Security
Please note that the Asterisk log files, as well as information printed to the Asterisk CLI, may contain sensitive information such as passwords and call history. Keep this in mind when providing access to these resources.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
598
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
599
Telephony Hardware
A PBX is only really useful if you can get calls into it. Of course, you can use Asterisk with VoIP calls (SIP, H.323, IAX, etc.), but you can also talk to the real PSTN through various cards. Supported Hardware is divided into two general groups: DAHDI devices and non-DAHDI devices. The DAHDI compatible hardware supports pseudo-TDM conferencing and all call features through chan_dahdi, whereas non-DAHDI compatible hardware may have different features.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
600
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
601
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
602
Digium, Inc. **B410P - also compatible with mISDN beroNet http://www.beronet.com **BN4S0 - 4 Port BRI card (TE/NT) **BN8S0 - 8 Port BRI card (TE/NT) Billion Card - Single Port BRI card (TE (/NT with crossed cable))
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
603
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
604
Secure Calling
Top-level page for articles about securing VoIP calls using encryption.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
605
Channel-specific configuration
Currently the IAX2 and SIP channels support the call security features in Asterisk. Both channel-specific configuration files (iax2.conf and sip.conf) support the encryption=yes setting. For IAX2, this setting causes Asterisk to offer encryption when placing or receiving a call. To force encryption with IAX2, the forceencrypt=yes option is required. Due to limitations of SDP, encryption=yes in sip.conf results in a call with only a secure media offer, therefor forceencrypt=yes would be redundant in sip.conf. If a peer is defined as requiring encryption but the endpoint does not support it, the call will fail with a HANGUPCAUSE of 58 (bearer capability does not exist).
exten => exten => exten => exten => exten => exten => exten => prompt) exten => exten => exten => exten => exten =>
123,1,NoOp(We got a call) 123,n,Set(CHANNEL(secure_bridge_signaling)=1) 123,n,Set(CHANNEL(secure_bridge_media)=1) 123,n,Dial(SIP/somebody) 123,n,NoOp(HANGUPCAUSE=${HANGUPCAUSE}) 123,n,GotoIf($["${HANGUPCAUSE}"="58"]?encrypt_fail) 123,n,Hangup ; notify user that retrying via insecure channel (user-provided 123,n(encrypt_fail),Playback(secure-call-fail-retry) 123,n,Set(CHANNEL(secure_bridge_signaling)=0) 123,n,Set(CHANNEL(secure_bridge_media)=0) 123,n,Dial(SIP/somebody) 123,n,Hangup
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
606
Part 1 (TLS)
Transport Layer Security (TLS) provides encryption for call signaling. It's a practical way to prevent people who aren't Asterisk from knowing who you're calling. Setting up TLS between Asterisk and a SIP client involves creating key files, modifying Asterisk's SIP configuration to enable TLS, creating a SIP peer that's capable of TLS, and modifying the SIP client to connect to Asterisk over TLS. Keys First, let's make a place for our keys.
mkdir /etc/asterisk/keys
Next, use the "ast_tls_cert" script in the "contrib/scripts" Asterisk source directory to make a self-signed certificate authority and an Asterisk certificate.
./ast_tls_cert -C pbx.mycompany.com -O "My Super Company" -d /etc/asterisk/keys
The "-C" option is used to define our host - DNS name or our IP address. The "-O" option defines our organizational name. The "-d" option is the output directory of the keys. 1. 2. 3. 4. 5. You'll be asked to enter a pass phrase for /etc/asterisk/keys/ca.key, put in something that you'll remember for later. This will create the /etc/asterisk/keys/ca.crt file. You'll be asked to enter the pass phrase again, and then the /etc/asterisk/keys/asterisk.key file will be created. The /etc/asterisk/keys/asterisk.crt file will be automatically generated. You'll be asked to enter the pass phrase a third time, and the /etc/asterisk/keys/asterisk.pem will be created, a combination of the asterisk.key and asterisk.crt files.
The "-m client" option tells the script that we want a client certificate, not a server certificate. The "-c /etc/asterisk/keys/ca.crt" option specifies which Certificate Authority (ourselves) that we're using. The "-k /etc/asterisk/keys/ca.key" provides the key for the above-defined Certificate Authority. The "-C" option, since we're defining a client this time, is used to define the hostname or IP address of our SIP phone The "-O" option defines our organizational name. The "-d" option is the output directory of the keys." The "-o" option is the name of the key we're outputting. 1. You'll be asked to enter the pass phrase from before to unlock /etc/asterisk/keys/ca.key.
Now, let's check the keys directory to see if all of the files we've built are there. You should have:
asterisk.crt asterisk.csr asterisk.key asterisk.pem malcolm.crt malcolm.csr malcolm.key malcolm.pem ca.cfg ca.crt ca.key tmp.cfg
Next, copy the malcolm.pem and ca.crt files to the computer running the Blink soft client.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
607
The Asterisk SIP configuration Now, let's configure Asterisk to use TLS. In the sip.conf configuration file, set the following:
tlsenable=yes tlsbindaddr=0.0.0.0 tlscertfile=/etc/asterisk/keys/asterisk.pem tlscafile=/etc/asterisk/keys/ca.crt tlscipher=ALL tlsclientmethod=tlsv1 ;none of the others seem to work with Blink as the client
Here, we're enabling TLS support. We're binding it to our local IPv4 wildcard (the port defaults to 5061 for TLS). We've set the TLS certificate file to the one we created above. We've set the Certificate Authority to the one we created above. TLS Ciphers have been set to ALL, since it's the most permissive. And we've set the TLS client method to TLSv1, since that's the preferred one for RFCs and for most clients. Configuring a TLS-enabled SIP peer within Asterisk Next, you'll need to configure a SIP peer within Asterisk to use TLS as a transport type. Here's an example:
[malcolm] type=peer secret=malcolm ;note that this is NOT a secure password host=dynamic context=local dtmfmode=rfc2833 disallow=all allow=g722 transport=tls context=local
Notice the transport option. The Asterisk SIP channel driver supports three types: udp, tcp and tls. Since we're configuring for TLS, we'll set that. It's also possible to list several supported transport types for the peer by separating them with commas. Configuring a TLS-enabled SIP client to talk to Asterisk Next, we'll configure Blink. First, let's add a new account.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
608
Then, we need to modify the Account Preferences, and under the SIP Settings, we need to set the outbound proxy to connect to the TLS port and transport type on our Asterisk server. In this case, there's an Asterisk server running on port 5061 on host 10.24.13.233.
Now, we need to point the TLS account settings to the client certificate (malcolm.pem) that we copied to our computer.
Then, we'll point the TLS server settings to the ca.crt file that we copied to our computer.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
609
Press "close," and you should see Blink having successfully registered to Asterisk.
Depending on your Asterisk CLI logging levels, you should see something like:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
610
-- Registered SIP 'malcolm' at 10.24.250.178:5061 > Saved useragent "Blink 0.22.2 (MacOSX)" for peer malcolm
Notice that we registered on port 5061, the TLS port. Now, make a call. You should see a small secure lockbox in your Blink calling window to indicate that the call was made using secure (TLS) signaling:
Part 2 (SRTP)
Now that we've got TLS enabled, our signaling is secure - so no one knows what extensions on the PBX we're dialing. But, our media is still not secure - so someone can snoop our RTP conversations from the wire. Let's fix that. SRTP support is provided by libsrtp. libsrtp has to be installed on the machine before Asterisk is compiled, otherwise you're going to see something like:
[Jan 24 09:29:16] ERROR[10167]: chan_sip.c:27987 setup_srtp: No SRTP module loaded, can't setup SRTP session.
on your Asterisk CLI. If you do see that, install libsrtp (and the development headers), and then reinstall Asterisk (./configure; make; make install). With that complete, let's first go back into our peer definition in sip.conf. We're going to add a new encryption line, like:
[malcolm] type=peer secret=malcolm ;note that this is NOT a secure password host=dynamic context=local dtmfmode=rfc2833 disallow=all allow=g722 transport=tls encryption=yes context=local
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
611
Reload Asterisk's SIP configuration (sip reload), make a call, and voil:
We're making secure calls with TLS (signaling) and SRTP (media).
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
612
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
613
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
614
SLA Configuration
How-to configure SLA in Asterisk
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
615
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
616
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
617
[line4] type=trunk device=Local/disa@line4_outbound [line4] exten => 12564286000,1,SLATrunk(line4) [line4_outbound] exten => disa,1,Disa(no-password,line4_outbound) exten => _1NXXNXXXXXX,1,Dial(SIP/${EXTEN}@mytrunk)
So, when a station picks up their phone and connects to line 4, they are connected to the local dialplan. The Disa application plays dialtone to the phone and collects digits until it matches an extension. In this case, once the phone dials a number like 12565551212, the call will proceed out the SIP trunk.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
618
Add the SIP channel as a station in sla.conf. Configure the phone in sip.conf. If automatic dialplan configuration was used by enabling the "autocontext" option in sla.conf, then this entry in sip.conf should have the same context setting. On the phone itself, there are various things that must be configured to make everything work correctly. Let's say this phone is called "station1" in sla.conf, and it uses trunks named "line1" and line2". Two line buttons must be configured to subscribe to the state of the following extensions: - station1_line1 - station1_line2 The line appearance buttons should be configured to dial the extensions that they are subscribed to when they are pressed. If you would like the phone to automatically connect to a trunk when it is taken off hook, then the phone should be automatically configured to dial "station1" when it is taken off hook.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
619
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
620
[line1] type=trunk device=DAHDI/1 autocontext=line1 [line2] type=trunk device=DAHDI/2 autocontext=line2 [station] type=station trunk=line1 trunk=line2 autocontext=sla_stations [station1](station) device=SIP/station1 [station2](station) device=SIP/station2 [station3](station) device=SIP/station3
With this configuration, the dialplan is generated automatically. The first DAHDI channel should have its context set to "line1" and the second should be set to "line2" in dahdi.conf. In sip.conf, station1, station2, and station3 should all have their context set to "sla_stations". For reference, here is the automatically generated dialplan for this situation:
[line1] exten => s,1,SLATrunk(line1) [line2] exten => s,2,SLATrunk(line2) [sla_stations] exten => station1,1,SLAStation(station1) exten => station1_line1,hint,SLA:station1_line1 exten => station1_line1,1,SLAStation(station1_line1) exten => station1_line2,hint,SLA:station1_line2 exten => station1_line2,1,SLAStation(station1_line2) exten => station2,1,SLAStation(station2) exten => station2_line1,hint,SLA:station2_line1 exten => station2_line1,1,SLAStation(station2_line1) exten => station2_line2,hint,SLA:station2_line2 exten => station2_line2,1,SLAStation(station2_line2) exten => station3,1,SLAStation(station3) exten => station3_line1,hint,SLA:station3_line1 exten => station3_line1,1,SLAStation(station3_line1) exten => station3_line2,hint,SLA:station3_line2 exten => station3_line2,1,SLAStation(station3_line2)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
621
[line1] type=trunk device=Local/disa@line1_outbound [line2] type=trunk device=Local/disa@line2_outbound [station] type=station trunk=line1 trunk=line2 [station1](station) device=SIP/station1 [station2](station) device=SIP/station2 [station3](station) device=SIP/station3
extensions.conf:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
622
[macro-slaline] exten => s,1,SLATrunk(${ARG1}) exten => s,n,Goto(s-${SLATRUNK_STATUS},1) exten => s-FAILURE,1,Voicemail(1234,u) exten => s-UNANSWERED,1,Voicemail(1234,u) [line1] exten => s,1,Macro(slaline,line1) [line2] exten => s,2,Macro(slaline,line2) [line1_outbound] exten => disa,1,Disa(no-password,line1_outbound) exten => _1NXXNXXXXXX,1,Dial(DAHDI/1/${EXTEN}) exten => 8500,1,VoicemailMain(1234) [line2_outbound] exten => disa,1,Disa(no-password|line2_outbound) exten => _1NXXNXXXXXX,1,Dial(DAHDI/2/${EXTEN}) exten => 8500,1,VoicemailMain(1234) [sla_stations] exten => station1,1,SLAStation(station1) exten => station1_line1,hint,SLA:station1_line1 exten => station1_line1,1,SLAStation(station1_line1) exten => station1_line2,hint,SLA:station1_line2 exten => station1_line2,1,SLAStation(station1_line2) exten => station2,1,SLAStation(station2) exten => station2_line1,hint,SLA:station2_line1 exten => station2_line1,1,SLAStation(station2_line1) exten => station2_line2,hint,SLA:station2_line2 exten => station2_line2,1,SLAStation(station2_line2) exten => station3,1,SLAStation(station3) exten => station3_line1,hint,SLA:station3_line1 exten => station3_line1,1,SLAStation(station3_line1) exten => station3_line2,hint,SLA:station3_line2 exten => station3_line2,1,SLAStation(station3_line2)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
623
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
624
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
625
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
626
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
627
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
628
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
629
Introduction to SMS
The SMS module for Asterisk was developed by Adrian Kennard, and is an implementation of the ETSI specification for landline SMS, ETSI ES 201 912, which is available from http://www.etsi.org. Landline SMS is starting to be available in various parts of Europe, and is available from BT in the UK. However, Asterisk would allow gateways to be created in other locations such as the US, and use of SMS capable phones such as the Magic Messenger. SMS works using analogue or ISDN lines.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
630
; Mobile Terminated, RX. This is used when an incoming call from the SMS arrives ; with the queue (called number and sub address) in ${EXTEN} ; Running an app after receipt of the text allows the app to find all messages ; in the queue and handle them, e.g. email them. ; The app may be something like smsq --process=somecommand --queue=${EXTEN} to ; run a command for each received message ; See below for usage [smsmtrx] exten = _X.,1,SMS(${EXTEN},a) exten = _X.,2,System("someapptohandleincomingsms ${EXTEN}") exten = _X.,3,Hangup ; ; Mobile originated, RX. This is receiving a message from a device, e.g. ; a Magic Messenger on a sip extension ; Running an app after receipt of the text allows the app to find all messages ; in the queue and handle then, e.g. sending them to the public SMSC ; The app may be something like smsq --process=somecommand --queue=${EXTEN} ; to run a command for each received message ; See below for example usage [smsmorx] exten = _X.,1,SMS(${EXTEN},sa) exten = _X.,2,System("someapptohandlelocalsms ${EXTEN}") exten = _X.,3,Hangup
smsmtrx is normally accessed by an incoming call from the SMSC. In the UK this call is from a CLI of 080058752X0 where X is the sub address. As such a typical usage in the extensions.conf at the point of handling an incoming call is:
smsmorx is normally accessed by a call from a local sip device connected to a Magic Messenger. It could however by that you are operating Asterisk as a message centre for calls from outside. Either way, you look at the called number and goto smsmorx. In the UK, the SMSC number that would be dialed is 1709400X where X is the caller sub address. As such typical usage in extension.config at the point of handling a call from a sip phone is:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
631
SMS Background
Short Message Service (SMS), or texting is very popular between mobile phones. A message can be sent between two phones, and normally contains 160 characters. There are ways in which various types of data can be encoded in a text message such as ring tones, and small graphic, etc. Text messaging is being used for voting and competitions, and also SPAM... Sending a message involves the mobile phone contacting a message centre (SMSC) and passing the message to it. The message centre then contacts the destination mobile to deliver the message. The SMSC is responsible for storing the message and trying to send it until the destination mobile is available, or a timeout. Landline SMS works in basically the same way. You would normally have a suitable text capable landline phone, or a separate texting box such as a Magic Messenger on your phone line. This sends a message to a message centre your telco provides by making a normal call and sending the data using 1200 Baud FSK signaling according to the ETSI spec. To receive a message the message centre calls the line with a specific calling number, and the text capable phone answers the call and receives the data using 1200 Baud FSK signaling. This works particularly well in the UK as the calling line identity is sent before the first ring, so no phones in the house would ring when a message arrives.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
632
New queues for sent messages, one file for each destination address and message reference. New field in message format, user reference, allowing applications to tie up their original message with a report. Handling of the delivery confirmation/rejection and connecting to the outgoing message - the received message file would then have fields for the original outgoing message and user reference allowing applications to handle confirmations better.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
633
oa - Originating address The phone number from which the message came Present on mobile terminated messages and is the CLI for morx messages da - Destination Address The phone number to which the message is sent Present on mobile originated messages scts - The service centre time stamp Format YYYY-MM-DDTHH:MM:SS Present on mobile terminated messages pid - One byte decimal protocol ID See GSM specs for more details Normally 0 or absent dcs - One byte decimal data coding scheme If omitted, a sensible default is used (see below) See GSM specs for more details mr - One byte decimal message reference Present on mobile originated messages, added by default if absent srr - 0 or 1 for status report request Does not work in UK yet, not implemented in app_sms yet rp - 0 or 1 return path See GSM specs for details vp - Validity period in seconds Does not work in UK yet udh - Hex string of user data header prepended to the SMS contents, excluding initial length byte. Consistent with ud, this is specified as udh# rather than udh= If blank, this means that the udhi flag will be set but any user data header must be in the ud field ud - User data, may be text, or hex, see below
udh is specified as as udh# followed by hex (2 hex digits per byte). If present, then the user data header indicator bit is set, and the length plus the user data header is added to the start of the user data, with padding if necessary (to septet boundary in 7 bit format). User data can hold an USC character codes U+0000 to U+FFFF. Any other characters are coded as U+FEFF ud can be specified as ud= followed by UTF-8 encoded text if it contains no control characters, i.e. only (U+0020 to U+FFFF). Any invalid UTF-8 sequences are treated as is (U+0080-U+00FF). ud can also be specified as ud# followed by hex (2 hex digits per byte) containing characters U+0000 to U+00FF only. ud can also be specified as ud## followed by hex (4 hex digits per byte) containing UCS-2 characters. When written by app_sms (e.g. incoming messages), the file is written with ud= if it can be (no control characters). If it cannot, the a comment line ;ud= is used to show the user data for human readability and ud# or ud## is used.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
634
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
635
SMS Terminology
SMS - Short Message Service i.e. text messages SMSC - Short Message Service Centre The system responsible for storing and forwarding messages MO - Mobile Originated A message on its way from a mobile or landline device to the SMSC MT - Mobile Terminated A message on its way from the SMSC to the mobile or landline device RX - Receive A message coming in to the Asterisk box TX - Transmit A message going out of the Asterisk box
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
636
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
637
Using SMSq
smsq is a simple helper application designed to make it easy to send messages from a command line. it is intended to run on the Asterisk box and have direct access to the queue directories for SMS and for Asterisk. In its simplest form you can send an SMS by a command such as smsq 0123456789 This is a test to 0123456789 This would create a queue file for a mobile originated TX message in queue 0 to send the text "This is a test to 0123456789" to 0123456789. It would then place a file in the /var/spool/asterisk/outgoing directory to initiate a call to 17094009 (the default message centre in smsq) attached to application SMS with argument of the queue name (0). Normally smsq will queue a message ready to send, and will then create a file in the Asterisk outgoing directory causing Asterisk to actually connect to the message centre or device and actually send the pending message(s). Using --process, smsq can however be used on received queues to run a command for each file (matching the queue if specified) with various environment variables set based on the message (see below); smsq options:
--help Show help text --usage Show usage --queue -q Specify a specific queue In no specified, messages are queued under queue "0" --da -d Specify destination address --oa -o Specify originating address This also implies that we are generating a mobile terminated message --ud -m Specify the actual message --ud-file -f Specify a file to be read for the context of the message A blank filename (e.g. --ud-file= on its own) means read stdin. Very useful when using via ssh where command line parsing could mess up the message. --mt -t Mobile terminated message to be generated --mo Mobile originated message to be generated Default --tx Transmit message Default --rx -r Generate a message in the receive queue --UTF-8 Treat the file as UTF-8 encoded (default) --UCS-1 Treat the file as raw 8 bit UCS-1 data, not UTF-8 encoded --UCS-2 Treat the file as raw 16 bit bigendian USC-2 data --process Specific a command to process for each file in the queue Implies --rx and --mt if not otherwise specified. Sets environment variables for every possible variable, and also ud, ud8 (USC-1 hex), and ud16 (USC-2 hex) for each call. Removes files. --motx-channel Specify the channel for motx calls May contain X to use sub address based on queue name or may be full number Default is Local/1709400X --motx-callerid Specify the caller ID for motx calls The default is the queue name without -X suffix --motx-wait Wait time for motx call Default 10 --motx-delay Retry time for motx call Default 1 --motx-retries Retries for motx call Default 10 --mttx-channel Specify the channel for mttx calls Default is Local/ and the queue name without -X suffix --mtttx-callerid Specify the callerid for mttx calls May include X to use sub address based on queue name or may be full number Default is 080058752X0 --mttx-wait Wait time for mttx call Default 10 --mttx-delay Retry time for mttx call Default 30 --mttx-retries Retries for mttx call Default 100 --default-sub-address The default sub address assumed (e.g. for X in CLI and dialled numbers as above) when none added (-X) to queue Default 9 --no-dial -x Create queue, but do not dial to send message --no-wait Do not wait if a call appears to be in progress This could have a small window where a message is queued but not sent, so regular calls to smsq should be done to pick up any missed messages --concurrent How many concurrent calls to allow (per queue), default 1 --mr -n Message reference --pid -p Protocol ID --dcs Data coding scheme --udh Specific hex string of user data header specified (not including the initial length byte) May be a blank string to indicate header is included in the user data already but user data header indication to be set. --srr Status report requested --rp Return path requested --vp Specify validity period (seconds) --scts Specify timestamp (YYYY-MM-DDTHH:MM:SS) --spool-dir Spool dir (in which sms and outgoing are found) Default /var/spool/asterisk
Other arguments starting '' or '' are invalid and will cause an error. Any trailing arguments are processed as follows:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
638
If the message is mobile originating and no destination address has been specified, then the first argument is assumed to be a destination address If the message is mobile terminating and no destination address has been specified, then the first argument is assumed to be the queue name If there is no user data, or user data file specified, then any following arguments are assumed to be the message, which are concatenated. If no user data is specified, then no message is sent. However, unless --no-dial is specified, smsq checks for pending messages and generates an outgoing anyway
When smsq attempts to make a file in /var/spool/asterisk/outgoing, it checks if there is already a call queued for that queue. It will try several filenames, up to the --concurrent setting. If these files exist, then this means Asterisk is already queued to send all messages for that queue, and so Asterisk should pick up the message just queued. However, this alone could create a race condition, so if the files exist then smsq will wait up to 3 seconds to confirm it still exists or if the queued messages have been sent already. The --no-wait turns off this behaviour. Basically, this means that if you have a lot of messages to send all at once, Asterisk will not make unlimited concurrent calls to the same message centre or device for the same queue. This is because it is generally more efficient to make one call and send all of the messages one after the other.
smsq can be used with no arguments, or with a queue name only, and it will check for any pending messages and cause an outgoing if there are any. It only sets up one outgoing call at a time based on the first queued message it finds. A outgoing call will normally send all queued messages for that queue. One way to use smsq would be to run with no queue name (so any queue) every minute or every few seconds to send pending message. This is not normally necessary unless --no-dial is selected. Note that smsq does only check motx or mttx depending on the options selected, so it would need to be called twice as a general check. UTF-8 is used to parse command line arguments for user data, and is the default when reading a file. If an invalid UTF-8 sequence is found, it is treated as UCS-1 data (i.e, as is). The --process option causes smsq to scan the specified queue (default is mtrx) for messages (matching the queue specified, or any if queue not specified) and run a command and delete the file. The command is run with a number of environment variables set as follows. Note that these are unset if not needed and not just taken from the calling environment. This allows simple processing of incoming messages
- $queue Set if a queue specified $?srr srr is set (to blank) if srr defined and has value 1. $?rp rp is set (to blank) if rp defined and has value 1. $ud User data, UTF-8 encoding, including any control characters, but with nulls stripped out Useful for the content of emails, for example, as it includes any newlines, etc. $ude User data, escaped UTF-8, including all characters, but control characters \n, \r, \t, \f, \xxx and \ is escaped as
Useful guaranteed one line printable text, so useful in Subject lines of emails, etc $ud8 Hex UCS-1 coding of user data (2 hex digits per character) Present only if all user data is in range U+0000 to U+00FF $ud16 Hex UCS-2 coding of user data (4 hex digits per character) other Other fields set using their field name, e.g. mr, pid, dcs, etc. udh is a hex byte string
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
639
Voicemail
All things voicemail
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
640
Upgrade Notice The msg_id column is new in Asterisk 11. Existing installations should add this column to their schema when upgrading to Asterisk 11. Existing voicemail messages will have this value populated when the messages are initially manipulated by app_voicemail in Asterisk 11.
The database name (from /etc/asterisk/res_odbc.conf) is in the odbcstorage variable in the general section of voicemail.conf. You may modify the voicemessages table name by using odbctable=table_name in voicemail.conf.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
641
Listening to a voicemail on the phone will set its state to "read" in a user's mailbox automatically. Deleting a voicemail on the phone will delete it from the user's mailbox automatically. Accessing a voicemail recording email message will turn off the message waiting indicator (MWI) on the user's phone. Deleting a voicemail recording email will also turn off the message waiting indicator, and delete the message from the voicemail system.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
642
Additionally, you may wish to build on a 64-bit machine, in which case you need to add -fPIC to EXTRACFLAGS. So, building on a 64-bit machine with SSL support would look something like:
$ make slx EXTRACFLAGS="-fPIC -I/usr/include/openssl"
Once this completes you can proceed with the Asterisk build; there is no need to run 'make install'.
Compiling Asterisk
Configure with ./configure -with-imap=/usr/src/imap or wherever you built the UWashington IMAP Toolkit. This directory will be searched for a source installation. If no source installation is found there, then a package installation of the IMAP c-client will be searched for in this directory. If one is not found, then configure will fail. A second configure option is to not specify a directory (i.e. ./configure -with-imap). This will assume that you have the imap-2007e source installed in the ../imap directory relative to the Asterisk source. If you do not have this source, then configure will default to the "system" option defined in the next paragraph A third option is ./configure -with-imap=system. This will assume that you have installed a dynamically linked version of the c-client library (most likely via a package provided by your distro). This will attempt to link agains -lc-client and will search for c-client headers in your include path starting with the imap directory, and upon failure, in the c-client directory. When you run 'make menuselect', choose 'Voicemail Build Options' and the IMAP_STORAGE option should be available for selection. After selecting the IMAP_STORAGE option, use the 'x' key to exit menuselect and save your changes, and the build/install Asterisk normally.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
643
imapserver=<name or IP address of IMAP mail server> imapport=<IMAP port, defaults to 143> imapflags=<IMAP flags, "novalidate-cert" for example> imapfolder=<IMAP folder to store messages to> imapgreetings=<yes or no> greetingsfolder=<IMAP folder to store greetings in if imapgreetings is enabled> expungeonhangup=<yes or no> authuser=<username> authpassword=<password> opentimeout=<TCP open timeout in seconds> closetimeout=<TCP close timeout in seconds> readtimeout=<TCP read timeout in seconds> writetimeout=<TCP write timeout in seconds>
The "imapfolder" can be used to specify an alternative folder on your IMAP server to store voicemails in. If not specified, the default folder 'INBOX' will be used. The "imapgreetings" parameter can be enabled in order to store voicemail greetings on the IMAP server. If disabled, then they will be stored on the local file system as normal. The "greetingsfolder" can be set to store greetings on the IMAP server when "imapgreetings" is enabled in an alternative folder than that set by "imapfolder" or the default folder for voicemails. The "expungeonhangup" flag is used to determine if the voicemail system should expunge all messages marked for deletion when the user hangs up the phone. Each mailbox definition should also have imapuser=imap username. For example:
4123=>4123,James Rothenberger,[email protected],,attach=yes|imapuser=jar
The directives "authuser" and "authpassword" are not needed when using Kerberos. They are defined to allow Asterisk to authenticate as a single user that has access to all mailboxes as an alternative to Kerberos.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
644
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
645
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
646
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
647
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
648
X-Asterisk-VM-Message-Num X-Asterisk-VM-Server-Name X-Asterisk-VM-Context X-Asterisk-VM-Extension X-Asterisk-VM-Priority X-Asterisk-VM-Caller-channel X-Asterisk-VM-Caller-ID-Num X-Asterisk-VM-Caller-ID-Name X-Asterisk-VM-Duration X-Asterisk-VM-Category X-Asterisk-VM-Orig-date X-Asterisk-VM-Orig-time X-Asterisk-VM-Message-ID
Upgrade Notice The X-Asterisk-VM-Message-ID header is new in Asterisk 11. Existing voicemail messages from older versions of Asterisk will have this header added to the message when the messages are manipulated by app_voicemail in Asterisk 11.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
649
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
650
Asterisk GUI
Introduction to Asterisk GUI
Asterisk GUI is a framework for the creation of graphical interfaces for configuring Asterisk. Some sample graphical interfaces for specific vertical markets are included for reference or for actual use and extension.
Introduction to Asterisk GUI Software License Download Support Installation and Configuration Installation Configuration http.conf: manager.conf Access Troubleshooting Development Debugging Hide Menu Categories
Software License
Asterisk GUI HTML and Javascript files Copyright (C) 2006-2011 Digium, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2 only. This software is also available under commercial terms from Digium, Inc. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Please contact Digium for information on alternative licensing arrangements for Asterisk GUI.
Download
While package release is inconsistent and infrequent, you can always get a current copy of Asterisk GUI from subversion. The current stable version will always be under branches and is currently located in branches/2.0.
Support
Please note that Asterisk GUI is not officially supported, though bugs, patches, and feature requests may be submitted at http://issues.asterisk.org and should reference the Asterisk GUI project. You may also find peer support in the #asterisk-gui IRC channel and the Asterisk GUI forum.
Configuration
You may install sample configuration files by doing "make samples". Also you will need to edit your Asterisk configuration files to enable Asterisk GUI properly, specifically:
http.conf:
Enable http.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
651
[general] enabled=yes enablestatic=yes #bindaddr=0.0.0.0 # allow GUI to be accessible from all IP addresses. bindaddr=127.0.0.1 # require access from the machine Asterisk is running on bindport=8088
manager.conf
Enable manager access.
Access
Access Asterisk GUI via a URL formatted in the following way, where $IP is the IP address on which both Asterisk and Asterisk GUI are installed, $PORT is bindport from http.conf, and $PREFIX is the prefix from http.conf, and it can be omitted if blank.
http://$IP:$PORT/$PREFIX/static/config/index.html
Troubleshooting
Check your filesystem permissions:
$ chown -R asterisk:asterisk /etc/asterisk/ /var/lib/asterisk /usr/share/asterisk # if asterisk runs as the user "asterisk" $ chmod 644 /etc/asterisk/*
Check that the bindaddr value in /etc/asterisk/http.conf matches the IP address of the machine you're using to access Asterisk GUI, not necessarily the IP address Asterisk GUI is running on. Check on the Asterisk CLI that Asterisk is receiving the values you've set.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
652
amelia*CLI> http show status HTTP Server Status: Prefix: /asterisk Server Enabled and Bound to 0.0.0.0:8088 Enabled URI's: /asterisk/httpstatus => Asterisk HTTP General Status /asterisk/phoneprov/... => Asterisk HTTP Phone Provisioning Tool /asterisk/amanager => HTML Manager Event Interface w/Digest authentication /asterisk/arawman => Raw HTTP Manager Event Interface w/Digest authentication /asterisk/manager => HTML Manager Event Interface /asterisk/rawman => Raw HTTP Manager Event Interface /asterisk/static/... => Asterisk HTTP Static Delivery /asterisk/amxml => XML Manager Event Interface w/Digest authentication /asterisk/mxml => XML Manager Event Interface Enabled Redirects: None. amelia*CLI> manager show settings Global Settings: ---------------Manager (AMI): Web Manager (AMI/HTTP): TCP Bindaddress: HTTP Timeout (minutes): TLS Enable: TLS Bindaddress: TLS Certfile: TLS Privatekey: TLS Cipher: Allow multiple login: Display connects: Timestamp events: Channel vars: Debug: Block sockets:
Yes Yes No No No
Check that the ports you've specified are open by using telnet from another computer.
config_upgraded = yes
Check the last modified date of /etc/asterisk/http.conf. Asterisk GUI updates the timestamp on this file every time it is loaded. If the timestamp is not getting updated, your HTTP request is either not making it to Asterisk or it is not being processed correctly by Asterisk. This indicates a configuration error. Check that the user Asterisk runs as has a login shell. Asterisk GUI depends on Asterisk being able to use the System application.
su - asterisk
If you installed Asterisk GUI via 'yum' or 'apt-get', you may need to symlink /var/lib/asterisk/static-http to /usr/share/asterisk/static-h ttp. Unfortunately /usr/share/asterisk/static-http will already exist, but fortunately it does not contain any useful files.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
653
Development
Debugging
To turn on debug messages, open config/js/session.js. On line 30, set "log" to "true":
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
654
Historical Pages
What is a Historical Page?
A Historical Page is old documentation that no longer applies to the current version of Asterisk. Ways of doing things have changed, perhaps, or a particular bit of functionality is no longer available / supported / recommended.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
655
Jabber in Asterisk
This information applies to Asterisk 10 and earlier versions. XMPP Support for Asterisk 11 has been completely rewritten
XMPP (Jabber) is an XML based protocol primarily for presence and messaging. It is an open standard and there are several open server implementations, such as ejabberd, jabberd(2), openfire, and others, as well as several open source clients, Psi, gajim, gaim etc. XMPP differs from other IM applications as it is immensly extendable. This allows us to easily integrate Asterisk with XMPP. The Asterisk XMPP Interface is provided by res_jabber.so. res_jabber allows for Asterisk to connect to any XMPP (Jabber) server and is also used to provide the connection interface for chan_jingle and chan _gtalk. Functions (JABBER_STATUS, JABBER_RECEIVE) and applications (JabberSend) are exposed to the dialplan. You'll find examples of how to use these functions/applications hereafter. We assume that 'asterisk-xmpp' is properly configured in jabber.conf. JabberSend JabberSend sends an XMPP message to a buddy. Example:
extensions.ael
context default { _XXXX => { JabberSend(asterisk-xmpp,[email protected],${CALLERID(name)} is calling ${EXTEN}); Dial(SIP/${EXTEN}, 30); Hangup(); } }
JABBER_STATUS
As of Asterisk 1.6.0, the corresponding application JabberStatus is still available, but marked as deprecated in favor of this function.
JABBER_STATUS stores the status of a buddy in a dialplan variable for further use. Here is an AEL example of how to use it:
extensions.ael
1234 => { Set(STATUS=${JABBER_STATUS(asterisk-xmpp,[email protected])}); if (${STATUS}=1) { NoOp(User is online and active, ring his Gtalk client.); Dial(Gtalk/asterisk-xmpp/[email protected]); } else { NoOp(Prefer the SIP phone); Dial(SIP/1234); } }
JABBER_RECEIVE JABBER_RECEIVE waits (up to X seconds) for a XMPP message and returns its content. Used along with JabberSend (or SendText, provided it's implemented in the corresponding channel type), JABBER_RECEIVE helps Asterisk interact with users while calls flow through the dialplan. JABBER_RECEIVE/JabberSend are not tied to the XMPP media modules chan_gtalk and chan_jingle, and can be used anywhere in the dialplan. In the following example, calls targeted to extension 1234 (be it accessed from SIP, DAHDI or whatever channel type) are controlled by user [email protected]. Asterisk notifies him that a call is coming, and asks him to take an action. This dialog takes place over an XMPP chat.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
656
extensions.ael
context from-ext { 1234 => { Answer(); JabberSend(asterisk-xmpp,[email protected],Call from $CALLERID(num) - choose an option to process the call); JabberSend(asterisk-xmpp,[email protected],1 : forward to cellphone); JabberSend(asterisk-xmpp,[email protected],2 : forward to work phone); JabberSend(asterisk-xmpp,[email protected],Default action : forward to your voicemail); Set(OPTION=${JABBER_RECEIVE(asterisk-xmpp,[email protected],20)}); switch (${OPTION}) { case 1: JabberSend(asterisk-xmpp,[email protected],(Calling cellphone...); Dial(SIP/987654321); break; case 2: JabberSend(asterisk-xmpp,[email protected],(Calling workphone...); Dial(SIP/${EXTEN}); break; default: Voicemail(${EXTEN}|u) } } }
When calling from a GoogleTalk or Jingle client, the CALLERID(name) is set to the XMPP id of the caller (i.e. his JID). In the following example, Asterisk chats back with the caller identified by the caller id. We also take advantage of the SendText implementation in chan_gtalk (available in chan_jingle, and chan_sip as well), to allow the caller to establish SIP calls from his GoogleTalk client:
extensions.ael
context gtalk-in { s => { NoOp(Caller id : ${CALLERID(all)}); Answer(); SendText(Please enter the number you wish to call); Set(NEWEXTEN=${JABBER_RECEIVE(asterisk-xmpp,${CALLERID(name)})}); SendText(Calling ${NEWEXTEN} ...); Dial(SIP/${NEWEXTEN); Hangup(); } }
The maintainer of res_jabber is Philippe Sultan <[email protected]>.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
657
Prerequisites
Asterisk communicates with Google Voice and Google Talk using the chan_gtalk Channel Driver and the res_jabber Resource module. Before proceeding, please ensure that both are compiled and part of your installation. Compilation of res_jabber and chan_gtalk for use with Google Talk / Voice are dependant on the iksemel library files as well as the OpenSSL development libraries presence on your system. Calling using Google Voice or via the Google Talk web client requires the use of Asterisk 1.8.1.1 or greater. The 1.6.x versions of Asterisk only support calls made using the legacy GoogleTalk external client. For basic calling between Google Talk web clients, you need a Google Mail account. For calling to and from the PSTN, you will need a Google Voice account. In your Google account, you'll want to change the Chat setting from the default of "Automatically allow people that I communicate with often to chat with me and see when I'm online" to the second option of "Only allow people that I've explicitly approved to chat with me and see when I'm online." IPv6 is currently not supported. Use of IPv4 is required. Google Voice can now be used with Google Apps accounts.
Gtalk configuration
The chan_gtalk Channel Driver is configured with the gtalk.conf configuration file, typically located in /etc/asterisk. What follows is the minimum required configuration for successful operation. Minimum Gtalk Configuration
[general] context=local allowguest=yes bindaddr=0.0.0.0 externip=216.208.246.1 [guest] disallow=all allow=ulaw context=local connection=asterisk
1. 2. 3. 4.
That calls will terminate to or originate from the local context; context=local That guest calls are allowd; allowguest=yes That RTP sessions will be bound to a local address (an IPv4 address must be present); bindaddr=0.0.0.0 (optional) That your external (the one outside of your NAT) IP address is defined; externip=216.208.246.1
1. 2. 3. 4.
That no codecs are allowed; disallow=all That the ulaw codec is explicitly allowed; allow=ulaw That calls received by the guest user will be terminated into the local context; context=local That the Jabber connection used for guest calls is called "asterisk;" connection=asterisk
Jabber Configuration
The res_jabber Resource is configured with the jabber.conf configuration file, typically located in /etc/asterisk. What follows is the minimum required configuration for successful operation. Minimum Jabber Configuration
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
658
[general] autoregister=yes [asterisk] type=client serverhost=talk.google.com [email protected]/Talk secret=your_google_password port=5222 usetls=yes usesasl=yes statusmessage="I am an Asterisk Server" timeout=100
1. Debug mode is enabled, so that XMPP messages can be seen on the Asterisk CLI; debug=yes 2. Automated buddy pruning is disabled, otherwise buddies will be automatically removed from your list; autoprune=no 3. Automated registration of users from the buddy list is enabled; autoregister=yes
The asterisk section of this configuration specifies several items.
1. The type is set to client, as we're connecting to Google as a service; type=client 2. The serverhost is Google's talk server; serverhost=talk.google.com 3. Our username is configured as [email protected]/resource, where our resource is "Talk;" [email protected]/Talk 4. Our password is configured using the secret option; secret=your_google_password 5. Google's talk service operates on port 5222; port=5222 6. TLS encryption is required by Google; usetls=yes 7. Simple Authentication and Security Layer (SASL) is used by Google; usesasl=yes 8. We set a status message so other Google chat users can see that we're an Asterisk server; statusmessage="I am an Asterisk Server" 9. We set a timeout for receiving message from Google that allows for plenty of time in the event of network delay; timeout=100
Phone configuration
Now, let's place a phone into the same context as the Google calls. The configuration of a SIP device for this purpose would, in sip.conf, typically located in /etc/asterisk, look something like:
[malcolm] type=peer secret=my_secure_password host=dynamic context=local
Dialplan configuration
Incoming calls Next, let's configure our dialplan to receive an incoming call from Google and route it to the SIP phone we created. To do this, our dialplan, extensions.conf, typically located in /etc/asterisk, would look like:
exten exten exten exten => => => => s,1,Answer() s,n,Wait(2) s,n,SendDTMF(1) s,n,Dial(SIP/malcolm,20)
Note that you might have to adjust the "Wait" time from 2 (in seconds) to something larger, like 8, depending on the current mood of Google. Otherwise, your incoming calls might not be successfully picked up.
This example uses the "s" unmatched extension, because Google does not forward any DID when it sends the call to Asterisk. In this example, we're Answering the call, Waiting 2 seconds, sending the DTMF "1" back to Google, and then dialing the call. We do this, because inbound calls from Google enable, even if it's disabled in your Google Voice control panel, call screening. Without this SendDTMF event, you'll have to confirm with Google whether or not you want to answer the call.
Using Google's voicemail Another method for accomplishing the sending of the DTMF event is to use the D dial option. The D option tells Asterisk to send a specified
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
659
DTMF string after the called party has answered. DTMF events specified before a colon are sent to the called party. DTMF events specified after a colon are sent to the calling party. In this example then, one does not need to actually answer the call first. This means that if the called party doesn't answer, Google will resort to sending the call to one's Google Voice voicemail box, instead of leaving it at Asterisk.
Filtering Caller ID The inbound CallerID from Google is going to look a bit nasty, e.g.:
[email protected]/srvres-MTAuMjE4LjIuMTk3Ojk4MzM=
Your VoIP client (SIPDroid) might not like this, so let's simplify that Caller ID a bit, and make it more presentable for your phone's display. Here's the example that we'll step through:
exten exten exten exten => => => => s,1,Set(crazygooglecid=${CALLERID(name)}) s,n,Set(stripcrazysuffix=${CUT(crazygooglecid,@,1)}) s,n,Set(CALLERID(all)=${stripcrazysuffix}) s,n,Dial(SIP/malcolm,20,D(:1))
First, we set a variable called crazygooglecid to be equal to the name field of the CALLERID function. Next, we use the CUT function to grab everything that's before the @ symbol, and save it in a new variable called stripcrazysuffix. We'll set this new variable to the CALLERID that we're going to use for our Dial. Finally, we'll actually Dial our internal destination.
Outgoing calls Outgoing calls to Google Talk users take the form of:
exten => 100,1,Dial(gtalk/asterisk/[email protected])
Where the technology is "gtalk," the dialing peer is "asterisk" as defined in jabber.conf, and the dial string is the Google account name. Outgoing calls made to Google Voice take the form of:
exten => _1XXXXXXXXXX,1,Dial(gtalk/asterisk/+${EXTEN}@voice.google.com)
Where the technology is "gtalk," the dialing peer is "asterisk" as defined in jabber.conf, and the dial string is a full E.164 number (plus character followed by country code, followed by the rest of the digits).
exten => exten => now.") exten => exten => exten =>
s,1,Answer() s,n,SendText("If you know the extension of the party you wish to reach, dial it s,n,Background(if-u-know-ext-dial) s,n,Set(OPTION=${JABBER_RECEIVE(asterisk,${CALLERID(name)::15},5)}) s,n,Dial(SIP/${OPTION},20)
Note that with the JABBER_RECEIVE function, we're receiving the text from asterisk which we defined earlier in this page as our connection to Google. We're also specifying with ${CALLERID(name)::15} that we want to strip off the last 15 characters from the CallerID name string - which is the number of characters that Google is appending, as of this writing, to represent an internal call ID number, and that we want to wait 5 seconds for a response.
Webinar
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
660
A Webinar was conducted on Tuesday, March 24, 2011 detailing Asterisk configuration for calling using Google as well as several usage cases. A copy of the slides, in PDF format, is available here - Google Calling Webinar - Public.pdf
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
661
Asterisk Versions
There are multiple supported feature frozen releases of Asterisk. Once a release series is made available, it is supported for some period of time. During this initial support period, releases include changes to fix bugs that have been reported. At some point, the release series will be deprecated and only maintained with fixes for security issues. Finally, the release will reach its End of Life, where it will no longer receive changes of any kind. The type of release defines how long it will be supported. A Long Term Support (LTS) release will be fully supported for 4 years, with one additional year of maintenance for security fixes. Standard releases are supported for a shorter period of time, which will be at least one year of full support and an additional year of maintenance for security fixes. The following table shows the release time lines for all releases of Asterisk, including those that have reached End of Life. Release Series 1.2.X 1.4.X 1.6.0.X 1.6.1.X 1.6.2.X 1.8.X 10.X 11.x 12.x 13.x LTS Standard Standard Standard LTS Standard LTS Standard LTS Release Type Release Date 2005-11-21 2006-12-23 2008-10-01 2009-04-27 2009-12-18 2010-10-21 2011-12-15 2012-10-25 2013-10 (tentative) 2014-10 (tentative) Security Fix Only 2007-08-07 2011-04-21 2010-05-01 2010-05-01 2011-04-21 2014-10-21 2012-12-15 2016-10-25 2014-10 (tentative) 2018-10 (tentative) EOL 2010-11-21 2012-04-21 2010-10-01 2011-04-27 2012-04-21 2015-10-21 2013-12-15 2017-10-25 2015-10 (tentative) 2019-10 (tentative)
New releases of Asterisk will be made roughly once a year, alternating between standard and LTS releases. Within a given release series that is fully supported, bug fix updates are provided roughly every 4 weeks. For a release series that is receiving only maintenance for security fixes, updates are made on an as needed basis. If you're not sure which one to use, choose either the latest release for the most up to date features, or the latest LTS release for a platform that may have less features, but will usually be around longer. The schedule for Asterisk releases is visualized below (which is subject to change at any time):
For developers, it is useful to be aware of when the feature freeze for a particular branch will occur. The feature freeze for a branch will occur 3 months prior to the release of a new Asterisk version, and a reminder announcement will be posted to the asterisk-dev mailing list approximately 60 days prior to the feature freeze. Asterisk versions are slated to be released the 3rd Wednesday of October. The feature freeze for a branch will occur the 3rd Wednesday of July. An announcement reminder will be posted to the asterisk-dev mailing list the 3rd Wednesday of May.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
662
Feature Freeze Announcement Reminder Feature Freeze of Asterisk Branch First Release of Asterisk from Branch
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
663
Core
Most modules in Asterisk are in the Core state, which means issues found with these modules can freely be reported to the Asterisk issue tracker, where the issue will be triaged and placed into a queue for resolution.
Extended
This module is supported by the Asterisk community, and may or may not have an active developer. Issues reported against these modules may have a low level of support. Some extended modules have active community developers monitoring issues though.
Deprecated
The module will remain in the tree, but there is a better way to do it. After two release cycles issues that have been deprecated for some time will be listed in an email to the Asterisk-Dev list where the community will have an opportunity to comment on whether a deprecated module: still compiles, works sufficiently well, and is still being utilized in a system where there is a justification for not using the preferred module.
MODULEINFO Configurations
At the top of modules there is the ability to set meta information about that module. Currently we have the following tags:
<support_level> Example: <support_level>deprecated</support_level> -- This module would be deprecated. Maintenance of this module may not exist. It is possible this module could eventually be tagged as deprecated, or removed from the tree entirely. <replacement> Example: <replacement>func_odbc</replacement> -- The replacement for this module is the func_odbc module. This is used when the <support_level> is set to deprecated.
Menuselect Display
The following two images show the suggested menuselect output based on the addition of the <support_level> and <replacement> tags. This would be a new line that has not been used before, and therefore would be added to menuselect as that new line.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
664
If the deprecated value is used, then the value between the <replacement> tags will replace the value of app_superQ as shown in the image below. The text surrounding app_superQ would be static (same for all modules that used deprecated).
If the <support_level> tag is used, then the value of extended would cause the additional text of ** EXTENDED ** to be displayed.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
665
Display in menuselect-newt for supported modules. If no <support_level> is specified, then it is assumed the module is supported:
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
666
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
667
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
668
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
669
Your issue may not be a bug or could have been fixed already. Run through the checklist below to verify you have done your due diligence.
Verify you are on a supported version of Asterisk: https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions, i.e. a version of Asterisk that has not reached End of Life Are you using the latest version of your Asterisk branch? Please check the release notes for newer versions of Asterisk to see if there is a potential fix for your issue. Even if you can't identify a fix in a newer version, it is preferable that you upgrade when reasonable to do so. Release notes are available in the UPGRADE.txt, CHANGES and ChangeLog files within the root directory of your particular point release. http://svnview.digium.com/svn/asterisk/tags/ Are you using the latest third party software, firmware, model, etc? If the error scenario involves phones, third party databases or other software, be sure it is all up to date and check their documentation. Have you asked for help in the community? (mailing lists, IRC, forums) You can locate all these services here: http://www.asterisk.o rg/community Have you searched the Asterisk documentation in case this behavior is expected? The documentation is located here: https://wiki.a sterisk.org/wiki/display/AST/Home Have you searched the Asterisk bug tracker to see if an issue is already filed for this potential bug? https://issues.asterisk.org/jira you'll find the search field in the top right of the page. Can you reproduce the problem? If you can't find a way to simulate or reproduce the issue, then at least get the system to a point where it's capturing relevant debug during the times the seemingly random failure occurs. Yes that could mean running debug for days or weeks if necessary.
Specific: Pertaining to a certain, clearly defined issue with data to provide evidence of said issue Reproducible: Not random - you have some idea when this issue occurs and how to make it happen again Concise: Brief but comprehensive. Don't provide an essay on what you think is wrong. Provide only the facts and debug output that supports them.
Bug New feature Improvement Information request (This type is not currently used, and your issue is likely to be closed or redefined)
Concise and descriptive summary Accurate and descriptive, not prescriptive. Provide the facts of what is happening and leave out assumptions as to what the issue might be. Good example: "Crash occurs when exactly twelve SIP channels hang up at the same time inside of a queue" Bad Examples: "asterisk crashes" , "problem with queue", "asterisk doesn't work", "channel hangups cause crash" Operating System detail (Linux distribution, kernel version, architecture etc) Asterisk version (exact branch and point release, such as 1.8.12.0) Information on any third party software involved in the scenario (database software, libraries, etc) Frequency and timing of the issue (does this occur constantly, is there a trigger? Every 5 minutes? seemingly random?)
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
670
Symptoms described in specific detail ("No audio in one direction on only inbound calls", "choppy noise on calls where trans-coding takes place") Steps required to reproduce the issue (tell the developer exactly how to reproduce the issue, just imagine you are making steps for a manual) Workarounds in detail with specific steps (if you found a workaround for a serious issue, please include it for others who may be affected) Debugging output - You'll almost always want to include extensions.conf, and config files for any involved component of Asterisk. Depending on the issue you'll also need SIP traces for anything involving a SIP channel plus backtraces and valgrind output for crashes or memory issues. Unless the issue is extremely trivial, you'll need to also include an Asterisk debug log, including DEBUG and VERBOSE type messages with at least a level of 5. You can find instructions HERE and HERE.
Be courteous. Do not paste debug output in the description or a comment, instead please attach any debugging output as text files and reference them by file name.
The issue can't be reproduced from the original report. The report lacks sufficient information to investigate, and you haven't responded to our requests for specific information. The issue may exist, but can't be fixed due to underlying architecture or infrastructure issues. The issue is not a bug, but is a support request. The reporter will be directed to community resources for support.
If insufficient commentary or debug information was given in the ticket then bug marshals will request additional information from the reporter. If there are questions posted as follow-ups to your bug or patch, please try to answer them - the system automatically sends email to you for every update on a bug you reported. If the original reporter of the patch/bug does not reply within some period of time (usually 14 days) and there are outstanding questions, the bug/patch may get closed out, which would be unfortunate. The developers have a lot on their plate and only so much time to spend managing inactive issues with insufficient information. If your bug was closed, but you get additional debug or data later on, you can always contact a bug marshal in #asterisk-bugs on irc.freenode.net to have them re-open the issue.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
671
1. Patches can always be merged by a member of the Asterisk Developer Community. Folks with commit access are those who have shown a willingness to work with the review process and are trusted shepherds of the project. Anyone with commit access can take ownership of a proposed patch and work to get it included in trunk - hence why the asterisk-dev mailing list is the best place to discuss patches. 2. Digium works through the queue of all issues on the tracker, both bugs and improvements. There's typically hundreds of issues in the backlog, including the work that the Asterisk Developer Community commits to at AstriDevCon every year. As such, we try to address as much as we can but there's no guarantee that we will get to any one issue.
Meaning
The issue has not been acknowledged yet. First a bug marshal needs to verify it's a valid report. Check the comments!
Open\Reopened
Issue has been acknowledged and is waiting for a developer to take it on. Typically we can't provide an ETA for development as priorities are complex and change constantly.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
672
A developer is working on this issue. Check the comments! Check the comments. This issue is waiting on the "Assignee" to provide feedback needed for it to move forward. Once feedback is provided you need to click "Send Back". Issue has been closed. Check the "Resolution" field for further information. The intended resolution was reached, but additional tasks may remain before the issue can be completely closed out.
Closed
Complete
Watch an issue: You can receive E-mails whenever an issue is updated. You'll see a "watch" link on the actual JIRA issue, click that!
When using the "Attach Files" form on a particular issue, be sure to select the "Yes, this is a code or documentation contribution" radio button. If you don't have a user license agreement, you'll see the message " You dont appear to have a current, signed submission license agreement on file. Please sign one before attempting to upload a code or documentation contribution." To sign a submission license agreement, use the "Sign a license Agreement" link at the top navigation bar in JIRA. The license agreement will be reviewed by Digium's legal department, then you'll be notified by E-mail of acceptance or rejection. If accepted you can now repeat the upload process and you'll be able to upload the code with a proper license associated to your account and showing by the attachment.
If you upload a patch and do not mark it as a code submission, and a bug marshal or developer later determines it to be a code submission, they may have to delete your patch and ask you to re-upload it, properly marking it as a code submission so that your license will be associated.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
673
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
674
Asterisk Community
Asterisk Community Services Community Services Signup IRC Mailing Lists
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
675
Issue Tracking Wiki Code Review Version Control Source Browsing Mailing Lists
There is a regular maintenance window every Monday from 9:00 PM to 10:00 PM Central Time, during which services may have intermittent availability while we apply patches, upgrades, etc. If maintenance is required outside of this window, notice will be sent to the asterisk-announce mailing list. If any of the community services are unavailable outside of a scheduled maintenance time, please notify the Asterisk development team.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
676
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
677
IRC
IRC
Use http://www.freenode.net IRC server to connect with Asterisk developers and users in realtime.
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
678
Mailing Lists
There are several mailing lists where community members can go do discuss Asterisk. Some of the key lists are: List asterisk-addons-commits asterisk-announce asterisk-biz Asterisk-BSD asterisk-bugs asterisk-commits asterisk-dev asterisk-doc asterisk-embedded asterisk-gui asterisk-gui-commits asterisk-ha-clustering Asterisk-i18n asterisk-security asterisk-speech-rec asterisk-users asterisk-video asterisk-wiki-changes asterisknow svn-commits Test-results Description SVN commits to the Asterisk addons project Asterisk releases and community service announcements Commercial and Business-Oriented Asterisk Discussion Asterisk on BSD discussion Bugs SVN commits to the Asterisk project Discussions about the development of Asterisk. #Development List Note Discussions regarding The Asterisk Documentation Project Asterisk Embedded Development Asterisk GUI project discussion SVN commits to the Asterisk-GUI project Asterisk High Availability and Clustering List - Non-Commercial Discussion Discussion of Asterisk internationalization Asterisk Security Discussion Use of speech recognition in Asterisk Discussions about the use and configuration of Asterisk. Development discussion of video media support in Asterisk Changes to the Asterisk space on wiki.asterisk.org AsteriskNOW Discussion SVN commits to the Digium repositories Results from automated testing
Content is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
679