; 2003-04-24 05:06 GMT jtodd@loligo.com ; ; This is the extensions.conf file for John Todd's Asterisk ; server. Asterisk can be found on http://www.asterisk.org/ ; ; More recent versions of this file can be found on: ; http://www.loligo.com/asterisk/ ; ; ; To view this file with none of my comments, simply use ; grep -v \; extensions.conf ; to remove comments. I only create comments one per ; line, even though trailing comments are permitted. ; ; This file determines where calls are routed when they are ; handed to Asterisk by one of various VOIP or analog call ; presentation channels. Configuration for those channels ; are found elsewhere in the /etc/asterisk directory, and ; examples can be found in my directory, listed above. ; ; This configuration (and all supporting files) assumes the ; use of an X100P analog FXO card, BUT IT IS NOT REQUIRED. ; I use the card to terminate my house line and weave it into ; the dialplans below. It can be removed without much ; difficulty. For details on the ~$100 card, see: ; http://www.digium.com/ ; ; Config notes: ; - in /usr/src/zaptel/Makefile, set KFLAGS+=-DECHO_CAN_MARK2 ; - in /usr/src/zaptel/Makefile, set KFLAGS+=-DAGGRESSIVE_SUPPRESSOR ; ; I compile with these two echo cancellation flags as it seems they ; sound better with SIP phones interacting with Zap (analog) devices. ; ; ; Known Bugs, Problems, Weirdnesses, etc.: ; ; 1) ATA-186 phones fail to stay registered. Something within ; Asterisk is causing ATA-186 phones to stop sending REGISTER ; requests after ~2 hours. Experiments with 30 through 240 ; second timeouts on the ciscos have similar results. Phone ; registry times out, calls fail. (2003-04-14 - unsure if this ; is fixed via Asterisk or via the ATA-186 v2.16 20030411 update) ; ; 2) DTMF relay through ATA-186 phones on SIP calls. I'm ; uncertain if this is an ATA-186 issue or not; some in-depth ; prodding seems to show that it's an Asterisk problem, or lack ; of a feature. DTMF reaches Asterisk, codes are shown on the ; console (in-band RFC2833) but are not played out the remote ; SIP channel; only slight garbled noise is heard. Analog ; replay works fine (ATA -> Asterisk -> X100P) Perhaps an ; origination problem with RFC2833 in-band signalling within ; Asterisk. I've tried changing to in-band signalling on the ; ATA-186 (AudioMode: 0x00050005) without success as well. ; 2003-02-17: calls originating with PSTN -> iconnect -> * -> ATA ; seem to transmit DTMF correctly in the ATA -> * -> ... ; direction. Just when calls are originated with the ATA ; does DTMF not get sent from the ATA, so this is looking ; more like an * problem. ; 2003-02-19: not so fast. I can hear the DTMF from inbound ; calls via SIP, but * is not recognizing the tones. Thus, ; DTMF transmission and reception does not seem to work for me. ; 2003-04-14: This seems to be just problematic with iconnecthere. ; Others claim to have made it work, but requests for config ; examples have gone unanswered. ; ; 3) Timers for register= commands should be selectable on a ; per-peer basis. (Packet8, as an example, requires 15 second ; REGISTER intervals. My SIP peers don't. Least common ; denominator sucks; glad I don't use Packet8 now.) ; ; 5) In my call recording macros, I can't get the "h" extensions to ; work correctly if the originating leg hangs up first. The ; macro runs only the first item in the priority list, and then ; quits. See my mail to the list about this. ; (asterisk-users 2003-04-20 "Macros not working as expected with ; extension "h" in some circumstances") ; ; 6) I'd really like to be able to know what kind of errors are being ; produced, so I can do some reasonable reporting to the end user. ; This is really becoming a big problem with handling SIP ; connection failures or the huge variety of problems that seem ; to crop up with VOIP. See my mail to the list on this for ; a variable that would be handed back to the call flow so that ; the configuration could be modified accordingly ; (asterisk-dev 2003-04-06 "Call completion/error codes and ; extensions.conf call flow") ; ; 7) The ability to press a key in mid-call and have something happen ; needs to be slightly extended. I'd like to have a DTMF digit of ; my choosing create a jump to another extension (like "h" and ; "s" maybe it could be a special extension like "t"?) and then ; I would like the ability to re-connect the conversation. This ; would be for things like turning on call recording, turning up ; the volume, starting a timer, starting a quick conference with pre-selected ; particpants, playing a short file, etc. ; (asterisk-users 2003-04-07 "Comments on 'transfer' feature request") ; ; ; To-Do: ; - get one-key conference going between extensions so we ; can talk to friends/relatives on different phones but ; without complexity of meeting rooms (note: hinges on ; a feature request that I've put in for mid-call DTMF ; auto-transfers.) ; - create external gateway for access to voicemail system ; - create external gateway to DISA (so I can call Asterisk ; from my cell phone, and dial to SIP peers) ; - create quantum teleporter; achieve financial independence ; ; Thanks to: Mark Spencer, Nathan Lutchansky, Martin Pycko, ; Tim Stewart, and the Open Source Asterisk development team for putting ; up with my questions, adding featuers, and dealing with ; my bug discoveries. ; ; ; ; ; ; ; The "General" category is for certain variables. All other categories ; are interpreted as extension contexts ; [general] ; ; If static is set to no, or omitted, then the pbx_config will rewrite ; this file when extensions are modified. Remember that all comments ; made in the file will be lost when that happens. ; ; XXX Not yet implemented XXX ; static=yes ; ; ; if stati=yes and writeprotect=no, you can save dialplan by ; CLI command 'save dialplan' too ; writeprotect=yes ; The [globals] context is where you can set variables that ; can be referenced elsewhere in the dialplan with ${VARIABLE} ; ; I decided that for ease of reference, I should create a variable ; called "PHONE1" that I could set to the phone where I normally ; am found. I then set "ME" to be my extention, raw, for use ; with voicemail forwarding. ; ; Variable "PHONE2" is the other ATA-186 in the house. ; ; Variable "DIALOUTANALOG" is the analog interface (FXO) card ; in the PC on my desk. See zapta.conf for config details. ; ; Variable "FWDUSERID" is my User ID from Free World Dialup. ; ; Variable "IAXINFO" is the username:password for my account ; at Gnophone's IAXTEL. (http://www.iaxtel.com/directory/) ; ; Variable "MYIAXTELNUMBER" is my number at IAXTEL. Yes, ; 700-555-1212 is really, actually my number (as opposed to ; all the bogus numbers I've scattered through this file to ; anonymize the configuration.) I expect a lot of calls for ; people wanting "directory assistance" :-) ; ; I create variables here so that if I decide to update my ; extensions list, or my dial-out interface list, it's just ; a simple variable change here at the top of the file. ; [globals] PHONE1=SIP/2203 PHONE1VM=2203 PHONE2=SIP/2204 PHONE3=SIP/2205 DIALOUTANALOG=Zap/1 FWDUSERID=11001 FWDUSERNAME=John Todd IPTELUSERID=1234567 IPTELUSERNAME=jtodd@loligo.com ICONNECT1=14155551212 MYNAME=John Todd MYASN=32767 IAXINFO=someusername:somepasswordhere MYIAXTELNUMBER=17005551212 MYHOMEPHONE=5036661212 MYCELLPHONE=13127771212 ; These variables are to avoid the irritating problem ; with inability to use regexp's on strings that have ; not been defined. ; CALLFILENAME=foo FOO=foo ; Any context starting with "macro-" is treated as ; a macro. Since I dial out through iconnect fairly ; frequently, I'll create a macro here for that routine. ; Note that I have to strip off any unwanted prefix ; characters before I call this macro, since iconnect ; only wants numbers in the form 1xxxyyyzzzz ; ; The system plays back an invalid extension recording if ; for some reason the call fails or errors out. ; ; I haven't yet encountered calling someone who has had ; a busy signal. I am uncertain what will happen with ; the "busy" logic I put in, but I figured I'd throw ; it in there anyway to give the correct response to ; the user. ; ; This macro takes two arguments: ARG1 is the phone number ; to be dialed (including leading "1") and ARG2 is the ; number of seconds that we should wait for an answer. ; ; Note: Due to iconnect's quality sucking rocks over the ; last few days, I've switched to nufone via IAX for ; actual calls. Sorry if this is confusing... ; [macro-dialiconnect] exten => s,1,SetCallerID(${ICONNECT1}) exten => s,2,SetCIDName(${MYNAME}) exten => s,3,Dial(IAX/jtodd@nufone/${ARG1},100,T) ;exten => s,3,Dial(SIP/${ARG1}@iconnect,${ARG2}) exten => s,4,Playback(new/acnt-or-cir-busy-now) exten => s,5,Hangup exten => s,104,Playback(new/acnt-or-cir-busy-now) exten => s,105,Wait,3 exten => s,106,Playtones(congestion) exten => s,107,Wait,30 exten => s,108,Playback(new/are-you-still-here) exten => s,108,Hangup ; When I dial something that throws an error, I expect ; to get a re-order (fast busy) tone. Well, since this ; system is more intelligent than that, I'd like to hear ; a bit more about what kind of error happened. However, ; that isn't in the system yet, so I have to play an "all-circuits-busy" ; message that I recorded myself. I'd really rather know ; what the SIP (or ISDN, or whatever) error code was so that ; I could play a message appropriate to the error (hint, hint, kram) ; [macro-fastbusy] exten => s,1,Answer exten => s,2,Wait 1 exten => s,3,Playback(new/all-circuits-busy) exten => s,4,Wait(30) exten => s,5,Hangup [macro-record-on] ; This routine is called as a macro before a "Dial" statement, in order ; to record a call into a set of files. It is used hand-in-hand with ; the "macro-record-cleanup" routine. ; I use an AGI to get the base filenames, which are created using the ; date in form YYYYMMDD-HHMMSS which is then added to the ${EXTEN} and ; ${CALLERIDNUM} strings to form the complete filename. ; ; Call this routine with Macro(record-on,${EXTEN},${CALLERIDNUM}) ; ; Note that I set CALLERIDNUM=foo up in my [globals] section, due ; to the inability of Asterisk to compare against the null case. ; Long story, but you really should have that variable set up in ; [globals] if you use this. ; ; Note: Legality of call recording varies by nation and state. Consult ; a very good lawyer before turning this on, or preface all your in/out ; calls with 'This call may be recorded.' to give yourself some minimal ; grounds to stand on (though that may not be enough.) ; ; Contents of the file /var/lib/asterisk/agi-bin/set-timestamp.agi: ; ; #!/bin/sh ; longtime=`date +%Y%m%d-%H%M%S` ; echo SET VARIABLE timestamp $longtime ; ; I could just use the built in ${DATETIME} to create a timestamp, ; but I really hate the date format used (DDMMYYYY) since it is ; silly. (least specific to most specific, left to right is the ; best way to create timestamps, IMHO) ; exten => s,1,AGI(set-timestamp.agi) exten => s,2,SetVar(CALLFILENAME=${timestamp}-${ARG2}-${ARG1}) exten => s,3,Monitor(wav,${CALLFILENAME}) [macro-record-cleanup] ; ; ; If we have recorded a call, it is to our advantage to change the ; format of the call from a two-file system (blah-in.wav blah-out.wav) ; into a single file that contains both legs of the call, and then ; compress the call into some reasonably small filesize using gsm ; compression. This routine should be called out of the "h" priority ; in a context. If the call was not recorded, this macro will ; not cause any harm, so calling it on each hangup isn't a problem. ; ; ; First, did we record this call? If ${CALLFILENAME} is equal to ; the variable ${FOO} (remember, we set them to be equal to "foo" ; up in the [globals] section) then we can be fairly certain that ; this call wasn't recorded, so just jump to the end of this macro ; and return out of routine. Otherwise, post-process the sound ; files into something more space efficient (one gsm file) ; exten => s,1,SetVar(MONITORDIR=/var/spool/asterisk/monitor) exten => s,2,GotoIf($[${CALLFILENAME} = ${FOO}]?6:3) ; ; ; This part of the routine mixes the in and out .wav files into one .wav, and then ; cleans up the original files (removes them) ; ; wmix is part of Wavetools-1.0 (http://tph.tuwien.ac.at/~oemer/tgz/wavetools-1.0.tgz) ; ; Turn the two in/out .wav files into a single .wav file with both channels exten => s,3,System(/usr/local/bin/wmix ${MONITORDIR}/${CALLFILENAME}-in.wav ${MONITORDIR}/${CALLFILENAME}-out.wav > ${MONITORDIR}/${CALLFILENAME}) ; ; Remove the old .wav files - we don't need them anymore. exten => s,4,System(/bin/rm ${MONITORDIR}/${CALLFILENAME}-in.wav ${MONITORDIR}/${CALLFILENAME}-out.wav) ; ; This part of the routine compresses the .wav files into a .gsm file for ; better storage (about 1/5 the size of a .wav file). Use "untoast" to restore ; to normal wav file format. (toast and untoast are fairly standard on Linux systems) ; exten => s,5,System(/usr/bin/toast -F ${MONITORDIR}/${CALLFILENAME}) ; ; End of routine, return to calling point (note: NoOp required for GotoIf ; called from priority 2) exten => s,6,NoOp ; The [intern] context is where I pass all calls ; that are dialed by the SIP phones in my house/office. ; I name these phones in the sip.conf file when I define the ; SIP peers. ; ; This context is the "main" context that gets used for outbound ; calls out of the house. It, in turn, calls other contexts ; which contain bits and pieces of other places that it's possible ; to dial from my house phone. I've split them up into many sub-segments ; so that they are re-usable if I should decide to allow other ; persons or organizations access some of those dialplan parts ; in some future configuration. My older extensions.conf had many ; fewer contexts, but I have opted to build this version with more ; flexible use of "include" commands to make my life easier for ; future configuration chores. ; ; First, I set up the configurations for call recording here, and then ; due to programmatical reasons I use a "Goto" to reset my priority ; and jump to the "real" context of [intern-post]. At the moment, I ; simply have a NoOp in priority 1, but I could just as easily put ; a pre-call answer, or call the record-on macro, or whatever. ; [intern] exten => _.,1,NoOp ;exten => _.,1,Macro(record-on,${EXTEN},${CALLERIDNUM}) exten => _.,2,Goto(intern-post,${EXTEN},1) ; After we set up some initial housekeeping things in the [intern] context, ; the [intern-post] context is jumped to, which is where the true dialplans ; are kept. ; [intern-post] ; Make sure that if we are recording the channel, we properly clean up the ; recorded files after a hangup. exten => h,1,Macro(record-cleanup) ; Send calls to operator (private PSTN gateway, analog line in my house) include => operator ; Send 911 calls to emergency outbound (private PSTN gateway, analog line in my house) include => e911 ; If someone dials a "9" in front of their number, send out via analog (private PSTN gateway) include => forced-analog ; If someone dials an "8" in front of their number, send to inoc-dba (semi-private directory) include => inoc-dba-out ; If someone dials a "7" in front of their number, send to Free World Dialup (free directory) include => fwd-out ; if someone dials a "6" in front of their number, send out via iconnect (commercial PSTN gateway) include => iconnect-forced ; if someone dials a "5" in front of their number, send out via coloco (private PSTN gateway) include => coloco-forced ; if someone dials "411" send them to the appropriate information operator via analog (private PSTN gateway) include => information ; if someone dials "3" in front of their number, send out via iptel (free directory) include => iptel-forced ; handle passing calls to (mostly) _22. numbers via my own IAX peer network (private pbx-pbx network) ; Others probably want to comment this out. include => iax-outbound ; If someone dials one of the 22xx numbers that are local (SIP phones in my house) include => local ; If someone dials a number in the local (free) area codes for this server (analog line for my house) include => pstn-local ; If someone dials a number in the local (toll) area for this server (11NPAXXXYYYY) (analog line for my house) include => pstn-local-toll ; If someone dials a toll-free number (analog line for my house) include => toll-free ; If someone dials a number that is local to my Coloco gateway, send it there (private PSTN gateway) ; Others probably want to comment this out. include => coloco-local ; If someone dials a "1700" number, send them to the IAXTEL server (free directory) include => iaxtel-out [operator] ; Handle calls to the Operator ("0") ; ; All Operator calls go to the analog line, since ; that is the only place that there is an operator ; on duty. At some point, this extension will lead ; a particular person in the office. ; ; Note that one can reach the operator by dialing "90" ; according to the pattern sets below, but I include ; just a single "0" as this system will be used by ; persons who are not used to dialing prefixes for ; their phone calls. ; ; I have to build an international dialing plan ; shortly to use a different iconnect account, which ; has international rate plans. Currently, the system ; simply does not allow interational dialing (011...) ; unless it's sent out to the local analog via the "9" ; prefix below. ; exten => 0,1,Dial(${DIALOUTANALOG}/${EXTEN},70) exten => 0,2,Macro(fastbusy) exten => 0,102,Playback(ss-noservice) exten => 0,103,Macro(fastbusy) [e911] ; EMERGENCY OUTBOUND ; ; United States dialing supports "911" emergency calls ; which are routed to the "closest" emergency contact center. ; ; Of course, you need to make sure that the center to which ; you are connecting is actually able to do something useful ; for the dialer; it doesn't make sense to have your NY branch ; offices dialing a 911 center in San Francisco. ; ; Note: The ATA-186 is auto-configured to send "911" ; directly to the SIP server with no delay. Be very, very ; careful when experimenting with this - the system does not ; follow standard rules with 911 calls. ; ; If you're !(USA), feel free to comment this context out entirely. ; exten => 911,1,Dial(${DIALOUTANALOG}/${EXTEN}) exten => 911,2,Macro(fastbusy) [forced-analog] ; This is for failure-case outbound dialing. If for some reason ; the outbound SIP connections aren't working, but aren't giving errors ; (i.e.: my path to larger Internet is dead) then I can short-circuit ; my way to the local analog dial port by dialing "91npaxxxyyyy" and ; the call will be shunted out the analog port. This is for when ; the inevitable cry of "IT DOESN'T WORK!!" is screamed from the ; living room by She Who Makes Calls. ; exten => _9.,1,Dial(${DIALOUTANALOG}/${EXTEN:1},70,Tt) exten => _9.,2,Macro(fastbusy) exten => _9.,102,Macro(fastbusy) [inoc-dba-out] ; Next, look to see if it's an INOC-DBA number. All INOC-DBA ; dial strings are dialed like this: 812345*223 where 12345 is ; the AS of the recipient and 223 is the extension of the person ; with whom I wish to speak. ; ; If any numbers begin with an "8" character, they are pointed ; at the INOC-DBA SIP server. The ${EXTEN:1} serves to strip ; the first digit from the dialed string out (the "8" in this ; case.) I could have done the same thing with the StripMSD,1 ; application, but that just adds another step in the dial ; process. ; ; NOTE: It is important to use SetCallerID first, THEN use ; the SetCIDName application, or data is lost. Bug. ; ; NOTE: If the INOC-DBA server responds with a "404 Not Found" ; error during the dial, the call will be returned and sent ; to step #4, which plays an "invalid extension" message. ; A 404 error can be due to someone's phone not being currently ; registered with INOC-DBA, or just a completely bogus and ; unknown number - there is no way to tell which caused the ; error reply. ; exten => _8.,1,SetCallerID(${MYASN}) exten => _8.,2,SetCIDName(${MYNAME}) exten => _8.,3,Dial(SIP/${EXTEN:1}@inoc-dba) exten => _8.,4,Playback(invalid) exten => _8.,5,Hangup [fwd-out] ; Check to see if the called number starts with a "7" and ; if so, set the call parameters and bounce the call to the ; Free World Dialup SIP server. ; ; Someone said that the CallerID and CIDName needed to be changed ; for FWD, so I did. Doesn't seem to cause harm, so... ; ; NOTE: Calls to unknown users will result in "invalid extension" ; message being played. ; exten => _7.,1,SetCallerID(${FWDUSERID}) exten => _7.,2,SetCIDName(${FWDUSERNAME}) exten => _7.,3,Dial(SIP/${EXTEN:1}@fwd) exten => _7.,4,Playback(invalid) exten => _7.,5,Hangup [iconnect-forced] ; Experimental "forced" dialing through iconnect to make calls ; prefixed with "6" go out the iconnect channel. This is to ; test some functionality for inbound connections; feel free ; to comment it out. ; ; Dial out on iconnect and wait for 70 seconds for a connect ; ; If no connection in 70 seconds, jump to fastbusy macro ; exten => _61XXXXXXXXXX,1,Macro(dialiconnect,${EXTEN:1},70) exten => _61XXXXXXXXXX,2,Macro(fastbusy) [coloco-forced] ; Force things out the Coloco connection if the number begins with "5" ; I have found that I do a lot of weird stuff with testing, so forcing ; calls out various paths for testing is necessary. ; exten => _51XXXXXXXXXX,1,Dial(SIP/${EXTEN:1}@coloco,70) exten => _51XXXXXXXXXX,2,Macro(fastbusy) [information] ; If the user is dialing information (411) then send call ; directly out to the analog line, unless busy, then ; dump at an unavailable recording ; ; If analog line errors out and goes to step 2, play ; fastbusy macro. ; exten => 411,1,Dial(${DIALOUTANALOG}/${EXTEN} exten => 411,2,Macro(fastbusy) exten => 411,102,Playback(ss-noservice) exten => 411,103,Macro(fastbusy) [iptel-forced] ; If the user is calling 3xxx... then we assume that they are calling ; an IPTEL extension, and send accordingly. ; ; See more details on http://www.iptel.org/user/index.php ; exten => _3.,1,SetCallerID(${IPTELUSERID}) exten => _3.,2,SetCIDName(${IPTELUSERNAME}) exten => _3.,3,Dial(SIP/${EXTEN:1}@iptel) exten => _3.,4,Playback(invalid) exten => _3.,5,Hangup [pstn-local] ; Next, check for numbers that are available "locally" out of ; my analog line connected to the house. In area code 503, ; you must dial an area code in front of all numbers, and ; a "1" is not possible in front of local numbers. Annoying. ; ; Thus, this rule matches "15035551212" but will dial "5035551212" ; ; If the first line (DIALOUTANALOG) is busy, then fail over ; and dial out the iconnecthere SIP peer. This ensures harmony ; in the household when She is one one line and I require the phone. :) ; ; Note that the iconnect Dial doesn't strip the first digit, since ; we need the single "1" prefix in those outbound calls. ; ; The list is duplicated for area code "971", which is an overlay ; for 503 ; exten => _1503.,1,Dial(${DIALOUTANALOG}/${EXTEN:1}) exten => _1503.,2,Macro(fastbusy) exten => _1503.,102,Macro(dialiconnect,${EXTEN},70) exten => _1971.,1,Dial(${DIALOUTANALOG}/${EXTEN:1}) exten => _1971.,2,Macro(fastbusy) exten => _1971.,102,Macro(dialiconnect,${EXTEN},70) [pstn-local-toll] ; Well, what about calls that are long distance in my local (503) area? ; I handle this by dialing them as "115035551212" and the system will ; then match and remove the first "1" digit. Ugly, but it works. ; ; The question is, of course, "should these go via iconnect"? I don't ; have the costs in front of me, but I may well remove this whole logic ; path once I figure it out. ; ; Ex: This rule will match '115036661313" and will dial "15036661313" ; ; Again, fail over to iconnect peer if analog busy, but this time ; we're going to strip the first digit, since "11" is not a valid ; prefix for iconnecthere calls. ; ; If there is some "other" type of error, dump to a fast busy. ; ; The list is duplicated for area code "971", which is an overlay ; for 503. ; ; exten => _11503.,1,Dial(${DIALOUTANALOG}/${EXTEN:1}) exten => _11503.,2,Macro(fastbusy) exten => _11503.,102,Macro(dialiconnect,${EXTEN:1},70) exten => _11971.,1,Dial(${DIALOUTANALOG}/${EXTEN:1}) exten => _11971.,2,Macro(fastbusy) exten => _11971.,102,Macro(dialiconnect,${EXTEN:1},70) [toll-free] ; Dial toll-free numbers (800, 877, 888, 866, 855) from the analog line ; and roll over to iconnect peer if analog is busy. ; ; In case of "other" type of error, dump to a fast busy. ; exten => _1888.,1,Dial(${DIALOUTANALOG}/${EXTEN}) exten => _1888.,2,Macro(fastbusy) exten => _1888.,102,Macro(dialiconnect,${EXTEN},70) exten => _1877.,1,Dial(${DIALOUTANALOG}/${EXTEN}) exten => _1877.,2,Macro(fastbusy) exten => _1877.,102,Macro(dialiconnect,${EXTEN},70) exten => _1866.,1,Dial(${DIALOUTANALOG}/${EXTEN}) exten => _1866.,2,Macro(fastbusy) exten => _1866.,102,Macro(dialiconnect,${EXTEN},70) exten => _1855.,1,Dial(${DIALOUTANALOG}/${EXTEN}) exten => _1855.,2,Macro(fastbusy) exten => _1855.,102,Macro(dialiconnect,${EXTEN},70) exten => _1800.,1,Dial(${DIALOUTANALOG}/${EXTEN}) exten => _1800.,2,Macro(fastbusy) exten => _1800.,102,Macro(dialiconnect,${EXTEN},70) [coloco-local] ; I do consulting for Coloco, Inc. (http://www.coloco.com/) for VOIP ; (also known as Baltimore Washington Telephone Inc.) based in Laurel, MD. ; They sell server co-location, IP bandwidth, and they have an SS7 switch ; located in the same room as the servers, making PRI cross-connects ; very well-priced for inbound and outbound calling. Quite a few call ; centers and dial service providers have their equipment located there. ; ; So I have several gateway machines there running both Asterisk as well ; as just Cisco 3640's running with the T1 VOIP interface cards. I use ; these as experimental gateways, and for working on customer problems. ; ; Now, this is the list of area codes that should be shunted out the SIP ; gateway in Laurel. The area codes of 301, 410, 703, and 240 are "local" ; to the gateway in Laurel, so I select them manually. ; ; See "sip.conf" for details on how I set up the "coloco" SIP peer ; ; If the dial to Coloco fails, then jump to iconnect. ; ; If iconnect fails, dump to fast busy. ; ; I really should put some announcements in between call spillovers ; so that I can tell when my call is going one way or the other, but ; I'm not certain that would be tremendously useful. Maybe later... ; ; If you have no other SIP peers that have visibility into local ; area codes, feel free to comment these lines out entirely. ; ; ; 301 is Suburban MD, DC Metro exten => _1301.,1,Dial(SIP/${EXTEN}@coloco) exten => _1301.,2,Macro(dialiconnect,${EXTEN},70) exten => _1301.,3,Macro(fastbusy) ; 410 is Baltimore Metro and Eastern Shore, MD exten => _1410.,1,Dial(SIP/${EXTEN}@coloco) exten => _1410.,2,Macro(dialiconnect,${EXTEN},70) exten => _1410.,3,Macro(fastbusy) ; 703 is Northern Virgina, DC Metro exten => _1703.,1,Dial(SIP/${EXTEN}@coloco) exten => _1703.,2,Macro(dialiconnect,${EXTEN},70) exten => _1703.,3,Macro(fastbusy) ; 240 is Suburban MD, DC Metro overlay exten => _1240.,1,Dial(SIP/${EXTEN}@coloco) exten => _1240.,2,Macro(dialiconnect,${EXTEN},70) exten => _1240.,3,Macro(fastbusy) ; 202 is Washington DC exten => _1202.,1,Dial(SIP/${EXTEN}@coloco) exten => _1202.,2,Macro(dialiconnect,${EXTEN},70) exten => _1202.,3,Macro(fastbusy) [iaxtel-out] ; This dials users on the Gnophone IAX server. Since they ; so conveniently have all their users in the "700" area code, ; I put this in my section that deals with dialing non-prefixed ; "long distance" calls, even though the channel used is an IAX ; connection. See http://x.linux-support.net/directory/ to ; sign up. ; ; The 700 area code is actually allocated in the NANPA, but I don't ; think I'll be ringing up any defense department or FEMA locations ; in the near future, so overlap is OK as far as I'm concerned. ; ; The configs for the IAX channel sessions are located in the file ; /etc/asterisk/iax.conf ; ; For some reason, exten => _1700NXXXXXX,1,SetCallerID(${MYIAXTELNUMBER}) exten => _1700NXXXXXX,2,SetCIDName(${MYNAME}) exten => _1700NXXXXXX,3,Dial(IAX/${IAXINFO}@iaxtel.com/${EXTEN}@iaxtel) ; All calls that have a "1" at the front are North American ; dialing prefixes, and should be sent to my iconnecthere account. ; ; This is normally the last inclusion context in a larger context, ; since everything "more specific" should have been picked out of the ; dial plan before reaching this point. ; ; These guys have a decent deal on LD minutes; something like $4.95 ; for 400 minutes of LD anywhere in the US lower 48 states, and ; they have international plans as well. ; ; They have had some really wacky problems with Asterisk lately, where ; I've been getting strange crosstalk RTP sessions from other people's ; conversations. I thought that crosstalk was something I abandoned ; when I moved away from POTs lines, but apparently not. Anyway, for ; $4.95, it's not a bad deal. ; ; They also offer optional inbound dialing; see other parts of ; this config file for notes on that. ; ; see sip.conf for details on configuration of outbound iconnecthere ; SIP peer and configs ; ; If we get an error on the dial or if we get a busy, play a congestion tone. ; exten => _1XXXXXXXXXX,1,Macro(dialiconnect,${EXTEN},70) exten => _1XXXXXXXXXX,2,Macro(fastbusy) exten => _1XXXXXXXXXX,103,Macro(fastbusy) [iax-outbound] ; This context is a hack to get calls to transfer to my "remote" sites, which ; are either remote offices or friends who have kept their dial plans ; in some way non-overlapping with mine. I should be using the "switch" ; parameter for these, but I prefer static mappings for the time being... ; ; I use airport names as standard naming convention, because I'm from ; an ISP background where standardization of large POP layouts is ; fairly important. I use the closest airport to the geographic location ; of the Asterisk server in question. Sometimes this is a large airport ; but it can also be small ; ; All 26xx extensions go to the "HMB1" location (Half Moon Bay, CA) exten => _26.,1,Dial(IAX/pdx1@hmb1/${EXTEN}) ; ; All 24xx extensions go to the sjc1 location (San Jose, CA) exten => _24.,1,Dial(IAX/pdx1@sjc1/${EXTEN}) ; ; Any calls to 14109850123 go to my testbed platform in Baltimore #1 (Baltimore, MD) ; This is a special case so I can ensure my monkeys are answering. exten => 14109850123,1,Dial(IAX/pdx1@bwi1/${EXTEN}) ; ; All _225x extensions go to the Baltimore location #2 (Baltimore, MD) exten => _225.,1,Dial(IAX/pdx1@bwi2/${EXTEN}) ; The [inbound-analog] context is where calls coming in from the ; zaptel X100P analog circuit are passed. Right now, this ; is a very simple dial plan that rings my two SIP phones. ; ; First, send the call through Zapateller. If there's no callerid, ; the system will answer the line, play a quick two-tone "re-order" ; signal which will cause many telemarketer systems to register the ; number as "out of order" and remove it from their lists. If the ; caller is a human, they'll jump to the next step... ; ; Next, if desired, start recording the call with the record-on ; macro. See my notes on legality. Make sure to clean up the ; calls with the record-cleanup macro in the "h" extension. ; Since I don't have the "called" number at this point (I only ; have "s") I will fill in what normally is ${EXTEN} in the ; macro call with the static ${MYHOMEPHONE} variable. ; Recording commented out and replaced by NoOp. ; ; The PrivacyManager will only work if the caller has no caller ID ; information in the inbound call. The PrivacyManager application ; will then give the caller 3 attempts to enter in a 10 digit phone ; number. That number then becomes the CallerID, and the call ; process is continued. ; ; Ring both SIP phones in the house that are "general" lines. ; ; If the lines ring for >20 seconds, play an amusing message and ; then dial the "u"navaialable voicemail box. ; If the lines are busy, dial the "b"usy voicemail box. ; ; See the file zapata.conf for how to configure the Zaptel X100P ; to forward calls to this context when called ; [inbound-analog] exten => s,1,Zapateller(answer|nocallerid) exten => s,2,NoOp ;exten => s,2,Macro(record-on,${MYHOMEPHONE},${CALLERIDNUM}) exten => s,3,PrivacyManager exten => s,4,Dial(${PHONE1}&${PHONE2},15,Ttm) exten => s,5,Answer exten => s,6,Wait(1) exten => s,7,Playback(new/hello) exten => s,8,Playback(new/marisa-john-not-in-momnt) exten => s,9,Playback(new/theyre-rattlesnake-wrstling) exten => s,10,Voicemail(u${PHONE1VM}) exten => s,11,Hangup exten => s,108,Wait(2) exten => s,109,Voicemail(b${PHONE1VM}) exten => s,110,Hangup exten => h,1,Macro(record-cleanup) ; Inbound calls from Gnophone (also known as "iaxtel") are routed ; to the [from-iaxtel] context. See the iax.conf file to see ; how this is done. ; ; I treat these calls just like most of my [from-sip] calls, and ; dump them here. ; ; Yes, I got 7005551212 in their dialplan; that's not a ficticious number. ; [from-iaxtel] exten => s,1,Dial(${PHONE1},15) exten => s,2,Voicemail(u${PHONE1VM}) exten => s,3,Hangup exten => s,102,Voicemail(b${PHONE1VM}) exten => s,103,Hangup exten => 17005551212,1,Dial(${PHONE1},15) exten => 17005551212,2,Voicemail(u${PHONE1VM}) exten => 17005551212,3,Hangup exten => 17005551212,102,Voicemail(b${PHONE1VM}) exten => 17005551212,103,Hangup ; All inbound SIP gateways (FWD, inoc-dba, iconnect, etc.) will ; be pointed at this context from sip.conf ; ; All these calls go right to extension 2203. In the near future, ; I will change this to a recorded greeting before transfer, or ; perhaps put the caller in phone-jail for a little while. ;-) ; ; I have split "from-sip" into two components due to the programmatic ; requirements of the "Goto" statement. Before any phone call is ; handled, I do some housekeeping and variable setting on the call. ; Future expansion in this area might be a call to a big LED board ; on my wall that announces the caller ID, or a synthesized voice ; that announces caller ID over a speaker, or whatever. The current ; option here is the "record the call" option, which I've commented ; out and put a "NoOp" in it's place. ; Essentially, the Goto resets the priority and extension to which ; the call is sent. ; [from-sip] exten => _.,1,NoOp ;exten => _.,1,Macro(record-on,${EXTEN},${CALLERIDNUM}) exten => _.,2,Goto(from-sip-post,${EXTEN},1) [from-sip-post] ; Handle hangup routines to clean up recording files when we close ; the call out if that was turned on... ; exten => h,1,Macro(record-cleanup) ; Now, what do we do with the incoming SIP calls? We parse them ; based on the number that the SIP peer says they're calling. ; From iptel.org ; exten => 1234567,1,Dial(${PHONE1},10) exten => 1234567,2,Playback(transfer) exten => 1234567,3,Macro(dialiconnect,${MYCELLPHONE},20) exten => 1234567,4,Voicemail(u${PHONE1VM}) exten => 1234567,5,Hangup exten => 1234567,102,Voicemail(b${PHONE1VM}) exten => 1234567,103,Hangup ; Calls inbound from iconnect come here, as they will hit the Asterisk ; server with "my" number as the inbound called-ID. ; ; NOTE: The transfer to my cell phone only rings for 20 seconds, which ; is not enough time for the voicemail on my phone to pick up. I want ; callers to get the voicemail from asterisk instead of my 'real' voicemail ; on the cellphone. ; ; If my desk phone is busy in step #1, jump right to voicemail since that ; means that I'm doing something at my desk, and sending them to my cell phone ; would just be an interruption. ; exten => 14155551212,1,Dial(${PHONE1},20,Ttm) exten => 14155551212,2,Playback(transfer) exten => 14155551212,3,Macro(dialiconnect,${MYCELLPHONE},20) exten => 14155551212,4,Voicemail(u${PHONE1VM}) exten => 14155551212,5,Hangup exten => 14155551212,102,Voicemail(b${PHONE1VM}) exten => 14155551212,103,Hangup ; Inbound calls from INOC-DBA SIP peer ; are routed to this extension. See sip.conf ; for more details on INOC-DBA peer. ; My AS number is 32767 (not really), so any inbound ; calls for that extension should end up ; on $PHONE1 (2203) which is my desk ATA-186 ; ; NOTE: The transfer to my cell phone only rings for 20 seconds, which ; is not enough time for the voicemail on my phone to pick up. I want ; callers to get the voicemail from asterisk instead of my 'real' voicemail ; on the cellphone. ; ; If my desk phone is busy in step #1, jump right to voicemail since that ; means that I'm doing something at my desk, and sending them to my cell phone ; would just be an interruption. ; exten => 32767,1,Dial(${PHONE1},10) exten => 32767,2,Playback(transfer) exten => 32767,3,Macro(dialiconnect,${MYCELLPHONE},20) exten => 32767,4,Voicemail(u${PHONE1VM}) exten => 32767,5,Hangup exten => 32767,102,Voicemail(b${PHONE1VM}) exten => 32767,103,Hangup ; Calls inbound for FWD end up here, since 11001 is my FWD # ; ; I don't bother to forward to my cell phone for these calls. ; exten => 11001,1,Dial(${PHONE1},15) exten => 11001,2,Voicemail(u${PHONE1VM}) exten => 11001,3,Hangup exten => 11001,102,Voicemail(b${PHONE1VM}) exten => 11001,103,Hangup ; My inbound line from Coloco is 2402221212 and that is what ; shows up as the "called" ID when the Cisco passes calls to me. ; Thus, I have to match against that "originally dialed" number ; in this context, since that peer will be sending it only. ; ; See the file sip.conf for details on how I configured the ; coloco SIP peer ; ; I play a "Ringing" tone due to some problems with call process ; sounds, but for some reason the Ringing application doesn't ; work well either.... hmm... (bug!) ; exten => 12402221212,1,Answer exten => 12402221212,2,Ringing exten => 12402221212,3,Dial(${PHONE1},25) exten => 12402221212,4,Playback(new/thk-u-calling-10-20-com) exten => 12402221212,5,Playback(new/nbdy-avail-to-take-call) exten => 12402221212,6,Playback(new/someone-will-call-back) exten => 12402221212,7,Voicemail(u${PHONE1VM}) exten => 12402221212,8,Hangup exten => 12402221212,104,Voicemail(b${PHONE1VM}) exten => 12402221212,105,Hangup ; The [local] context is where I put all of the locally dialable ; numbers. These entries could be made in each context where I ; reference them, but that would be redundant. ; ; Mostly, they are used from context [intern] right now, but I'm sure ; I'll include them in other contexts later. ; ; Note: due to my wacky/kludgey prefix dialing crap, all the "internal" ; extensions that are local to this system must begin with a "2" ; This means that voicemail, echo, all users, etc. must have an extension ; that starts with the digit "2" or one of the other dialplans will ; snag the call and do whatever with it. This is sub-optimal for a ; system with hundreds of extensions, but for my purposes it works ; just fine. ; Furthermore, all of "my" extensions begin with 220, since I don't ; expect to have more than 10 phones. My friends can then have ; extension plans with 221X or 222X or whatever, and we won't ; overlap. ; ; [local] ; First extension (office) in the house ; ; Note that I try to keep extension names and numbers ; identical. You don't need to be bound to this ; method. ; ; Note that many internal extensions do not time out to voicemail. ; ; 2203 is my Nortel deskphone via an ATA-186 ; exten => 2203,1,Dial(${PHONE1},30,t) exten => 2203,2,Playback(invalid) exten => 2203,3,Hangup exten => 2203,102,Voicemail(2203) exten => 2203,103,Hangup ; This is the second extension in the house, ; connected to the vtech wireless via ATA-186 ; exten => 2204,1,Dial(${PHONE2},30,Ttm) exten => 2204,2,Playback(invalid) exten => 2204,3,Hangup exten => 2204,102,Voicemail(2204) exten => 2204,103,Hangup ; This is the Cisco 7960 ; ; Strangely the musiconhold doesn't work while ringing. ; exten => 2205,1,Dial(${PHONE3},30,t) exten => 2205,2,Playback(invalid) exten => 2205,3,Hangup exten => 2205,102,Voicemail(2205) exten => 2205,103,Hangup ; Dial 2500 from any phone to go to the voicemail system ; exten => 2500,1,Wait,2 exten => 2500,2,VoicemailMain exten => 2500,3,Hangup ; These are my testing extensions. Nothing ; bad will happen if you comment them out. ; ; Actually, *I* should really comment them out, but ; I leave them in for playing around with sounds, etc. ; exten => 2001,1,Answer exten => 2001,2,Wait,1 exten => 2001,3,mp3player(/var/lib/asterisk/mohmp3/Bad-Moon-Rising.mp3) ;exten => 2001,3,Playback(new/wolverine-hunting) ;exten => 2001,3,Playtones(congestion) exten => 2001,4,Wait,20 exten => 2001,5,Hangup exten => 4000,1,Answer exten => 4000,2,Playback(new/password) exten => 4000,3,AGI(agi-test.agi,${pass}) exten => 4000,4,Hangup exten => 4001,1,Playback(new/password) exten => 4001,2,SetMusicOnHold,loud exten => 4001,3,WaitMusicOnHold,30 exten => 4001,4,Hangup