[globals]


; Three link2voip outgoing trunks.
; Use the one with the fewest hops.

; US (Dallas, Texas)
[macro-diallink2voipUS]
exten => s,1,Dial(SIP/${ARG1}@link2voip-us1,120)
exten => s,2,Goto(s-${DIALSTATUS},1)
exten => s-ANSWER,1,Hangup
exten => s-CONGESTION,1,Dial(SIP/${ARG1}@link2voip-us2,120)
exten => s-CONGESTION,2,Goto(ss-${DIALSTATUS},1)
exten => s-CANCEL,1,Hangup
exten => s-BUSY,1,Busy(30)
exten => s-CHANUNAVAIL,1,Dial(SIP/${ARG1}@link2voip-us2,120)
exten => s-CHANUNAVAIL,2,Goto(ss-${DIALSTATUS},1)
exten => ss-ANSWER,1,Hangup
exten => ss-CONGESTION,1,Congestion(30)
exten => ss-CANCEL,1,Hangup
exten => ss-BUSY,1,Busy(30)
exten => ss-CHANUNAVAIL,1,Congestion(30)

; NL (Amsterdam)
[macro-diallink2voipNL]
exten => s,1,Dial(SIP/${ARG1}@link2voip-nl1,120)
exten => s,2,Goto(s-${DIALSTATUS},1)
exten => s-ANSWER,1,Hangup
exten => s-CONGESTION,1,Dial(SIP/${ARG1}@link2voip-nl2,120)
exten => s-CONGESTION,2,Goto(ss-${DIALSTATUS},1)
exten => s-CANCEL,1,Hangup
exten => s-BUSY,1,Busy(30)
exten => s-CHANUNAVAIL,1,Dial(SIP/${ARG1}@link2voip-nl2,120)
exten => s-CHANUNAVAIL,2,Goto(ss-${DIALSTATUS},1)
exten => ss-ANSWER,1,Hangup
exten => ss-CONGESTION,1,Congestion(30)
exten => ss-CANCEL,1,Hangup
exten => ss-BUSY,1,Busy(30)
exten => ss-CHANUNAVAIL,1,Congestion(30)

; CA (Edmonton, Alberta)
[macro-diallink2voipCA]
exten => s,1,Dial(SIP/${ARG1}@link2voip-ca1,120)
exten => s,2,Goto(s-${DIALSTATUS},1)
exten => s-ANSWER,1,Hangup
exten => s-CONGESTION,1,Dial(SIP/${ARG1}@link2voip-ca2,120)
exten => s-CONGESTION,2,Goto(ss-${DIALSTATUS},1)
exten => s-CANCEL,1,Hangup
exten => s-BUSY,1,Busy(30)
exten => s-CHANUNAVAIL,1,Dial(SIP/${ARG1}@link2voip-ca2,120)
exten => s-CHANUNAVAIL,2,Goto(ss-${DIALSTATUS},1)
exten => ss-ANSWER,1,Hangup
exten => ss-CONGESTION,1,Congestion(30)
exten => ss-CANCEL,1,Hangup
exten => ss-BUSY,1,Busy(30)
exten => ss-CHANUNAVAIL,1,Congestion(30)



[from-trunk]
; route incoming calls from the PSTN
exten => s,1,Answer
exten => 17074700739,1,Dial(SIP/wiredPhone)		; "hotline"
exten => 17074700741,1,Dial(SIP/IMSI310410186585295)	; 8890
exten => 17074700742,1,Dial(SIP/zoiper)
exten => 17074700743,1,Dial(SIP/IMSI310410186585294)	; 5110
exten => 17074700746,1,Dial(SIP/IMSI234100223456161)	; Treo
exten => 31208080896,1,Dial(SIP/IMSI310410186585289)	; 3310



#include "extensions.local.conf"

[sip-external]

; check for local extensions first
include => sip-local

; other Asterisk server(s)
exten => _611,1,Dial(SIP/5078322417@vgw1.link2voip.com)
exten => _9XXXX,1,Dial(SIP/${EXTEN:-4}@192.168.0.15)
;exten => 8099,1,Dial(SIP/8099@65.44.243.130)

; outgoing trunk access
; NANP
; toll fraud blockers
exten => _1809NXXXXXX,1,Goto(unassigned,s,1);
exten => _809NXXXXXX,2,Goto(unassigned,s,1);
; general case
exten => _NXXNXXXXXX,2,Macro(diallink2voipNL,1${EXTEN})
exten => _1NXXNXXXXXX,1,Macro(diallink2voipNL,${EXTEN})
; international
exten => _011.,1,Macro(diallink2voipNL,${EXTEN})

