[globals]
DAHDI_CPE_GROUP=G1
DAHDI_NET_GROUP=g4
DAHDI_PH_1_GROUP=g2
DAHDI_PH_2_GROUP=g3

USER_A=100
USER_B=200
USER_C=201
PH_1=400
PH_2=500

; Hint syntax:
;exten => 400,hint,device-name(device-caller-id-name)
;exten => 400,hint,DAHDI/i2/400(caller-id-name)
;
; The hint device-name is used for the default device state status.
; The hint device-caller-id-name is used to set the outgoing channel caller id name string.
;
;exten => 400,n,NoOp(HINT is ${HINT})
; HINT is DAHDI/i2/400
;exten => 400,n,NoOp(HINTNAME is ${HINTNAME})
; HINTNAME is caller-id-name

; ************************************************************************

[general]
autofallthrough=yes
userscontext=stdexten_ctx
;userscontext=sip_site_b

; ************************************************************************

[macro-displaycli]
exten => s,1,NoOp(CALLERID(dnid) is ${CALLERID(dnid)})
exten => s,n,NoOp(CALLERID(dnid-subaddr-valid) is ${CALLERID(dnid-subaddr-valid)})
exten => s,n,NoOp(CALLERID(dnid-subaddr) is ${CALLERID(dnid-subaddr)})
;exten => s,n,NoOp(CALLERID(ani-all) is ${CALLERID(ani-all)})
exten => s,n,NoOp(CALLERID(all) is ${CALLERID(all)})
exten => s,n,NoOp(CALLERID(ton) is ${CALLERID(ton)})
;exten => s,n,NoOp(CALLERID(name-charset) is ${CALLERID(name-charset)})
;exten => s,n,NoOp(CALLERID(name-pres) is ${CALLERID(name-pres)})
;exten => s,n,NoOp(CALLERID(num-pres) is ${CALLERID(num-pres)})
exten => s,n,NoOp(CALLERID(pres) is ${CALLERID(pres)})
exten => s,n,NoOp(CALLERID(subaddr-valid) is ${CALLERID(subaddr-valid)})
exten => s,n,NoOp(CALLERID(subaddr) is ${CALLERID(subaddr)})
exten => s,n,NoOp(CALLERID(tag) is ${CALLERID(tag)})
exten => s,n,NoOp(CALLERID(rdnis) is ${CALLERID(rdnis)})

;BUGBUG test dumping --v
;exten => s,n,NoOp(CALLERID(ani-all) is ${CALLERID(ani-all)})
;exten => s,n,NoOp(CALLERID(ani-num-valid) is ${CALLERID(ani-num-valid)})
;exten => s,n,NoOp(CALLERID(ani) is ${CALLERID(ani)})
;exten => s,n,NoOp(CALLERID(ani-num) is ${CALLERID(ani-num)})
;exten => s,n,NoOp(CALLERID(ani-ton) is ${CALLERID(ani-ton)})
;exten => s,n,NoOp(CALLERID(ani-num-plan) is ${CALLERID(ani-num-plan)})
;exten => s,n,NoOp(CALLERID(ani-num-pres) is ${CALLERID(ani-num-pres)})
;exten => s,n,NoOp(CALLERID(ani-name-valid) is ${CALLERID(ani-name-valid)})
;exten => s,n,NoOp(CALLERID(ani-name) is ${CALLERID(ani-name)})
;exten => s,n,NoOp(CALLERID(ani-name-charset) is ${CALLERID(ani-name-charset)})
;exten => s,n,NoOp(CALLERID(ani-name-pres) is ${CALLERID(ani-name-pres)})
;exten => s,n,NoOp(CALLERID(ani-subaddr-valid) is ${CALLERID(ani-subaddr-valid)})
;exten => s,n,NoOp(CALLERID(ani-subaddr) is ${CALLERID(ani-subaddr)})
;exten => s,n,NoOp(CALLERID(ani-subaddr-type) is ${CALLERID(ani-subaddr-type)})
;exten => s,n,NoOp(CALLERID(ani-subaddr-odd) is ${CALLERID(ani-subaddr-odd)})
;exten => s,n,NoOp(CALLERID(ani-pres) is ${CALLERID(ani-pres)})
;exten => s,n,NoOp(CALLERID(ani-tag) is ${CALLERID(ani-tag)})

;exten => s,n,NoOp(CALLERID(dnid-num) is ${CALLERID(dnid-num)})
;exten => s,n,NoOp(CALLERID(dnid-num-plan) is ${CALLERID(dnid-num-plan)})
;exten => s,n,NoOp(CALLERID(dnid-subaddr-valid) is ${CALLERID(dnid-subaddr-valid)})
;exten => s,n,NoOp(CALLERID(dnid-subaddr) is ${CALLERID(dnid-subaddr)})
;exten => s,n,NoOp(CALLERID(dnid-subaddr-type) is ${CALLERID(dnid-subaddr-type)})
;exten => s,n,NoOp(CALLERID(dnid-subaddr-odd) is ${CALLERID(dnid-subaddr-odd)})

;exten => s,n,NoOp(CALLERID(all) is ${CALLERID(all)})
;exten => s,n,NoOp(CALLERID(num-valid) is ${CALLERID(num-valid)})
;exten => s,n,NoOp(CALLERID(num) is ${CALLERID(num)})
;exten => s,n,NoOp(CALLERID(ton) is ${CALLERID(ton)})
;exten => s,n,NoOp(CALLERID(num-plan) is ${CALLERID(num-plan)})
;exten => s,n,NoOp(CALLERID(num-pres) is ${CALLERID(num-pres)})
;exten => s,n,NoOp(CALLERID(name-valid) is ${CALLERID(name-valid)})
;exten => s,n,NoOp(CALLERID(name) is ${CALLERID(name)})
;exten => s,n,NoOp(CALLERID(name-charset) is ${CALLERID(name-charset)})
;exten => s,n,NoOp(CALLERID(name-pres) is ${CALLERID(name-pres)})
;exten => s,n,NoOp(CALLERID(subaddr-valid) is ${CALLERID(subaddr-valid)})
;exten => s,n,NoOp(CALLERID(subaddr) is ${CALLERID(subaddr)})
;exten => s,n,NoOp(CALLERID(subaddr-type) is ${CALLERID(subaddr-type)})
;exten => s,n,NoOp(CALLERID(subaddr-odd) is ${CALLERID(subaddr-odd)})
;exten => s,n,NoOp(CALLERID(pres) is ${CALLERID(pres)})
;exten => s,n,NoOp(CALLERID(tag) is ${CALLERID(tag)})

;exten => s,n,NoOp(CALLERID(rdnis) is ${CALLERID(rdnis)})
;BUGBUG test dumping --^

[macro-displayredir]
exten => s,1,NoOp(REDIRECTING(from-all) is ${REDIRECTING(from-all)})
exten => s,n,NoOp(REDIRECTING(from-ton) is ${REDIRECTING(from-ton)})
;exten => s,n,NoOp(REDIRECTING(from-name-charset) is ${REDIRECTING(from-name-charset)})
;exten => s,n,NoOp(REDIRECTING(from-name-pres) is ${REDIRECTING(from-name-pres)})
;exten => s,n,NoOp(REDIRECTING(from-num-pres) is ${REDIRECTING(from-num-pres)})
exten => s,n,NoOp(REDIRECTING(from-pres) is ${REDIRECTING(from-pres)})
exten => s,n,NoOp(REDIRECTING(from-subaddr-valid) is ${REDIRECTING(from-subaddr-valid)})
exten => s,n,NoOp(REDIRECTING(from-subaddr) is ${REDIRECTING(from-subaddr)})
exten => s,n,NoOp(REDIRECTING(from-tag) is ${REDIRECTING(from-tag)})

exten => s,n,NoOp(REDIRECTING(to-all) is ${REDIRECTING(to-all)})
exten => s,n,NoOp(REDIRECTING(to-ton) is ${REDIRECTING(to-ton)})
;exten => s,n,NoOp(REDIRECTING(to-name-charset) is ${REDIRECTING(to-name-charset)})
;exten => s,n,NoOp(REDIRECTING(to-name-pres) is ${REDIRECTING(to-name-pres)})
;exten => s,n,NoOp(REDIRECTING(to-num-pres) is ${REDIRECTING(to-num-pres)})
exten => s,n,NoOp(REDIRECTING(to-pres) is ${REDIRECTING(to-pres)})
exten => s,n,NoOp(REDIRECTING(to-subaddr-valid) is ${REDIRECTING(to-subaddr-valid)})
exten => s,n,NoOp(REDIRECTING(to-subaddr) is ${REDIRECTING(to-subaddr)})
exten => s,n,NoOp(REDIRECTING(to-tag) is ${REDIRECTING(to-tag)})

;exten => s,n,NoOp(REDIRECTING(orig-all) is ${REDIRECTING(orig-all)})
;exten => s,n,NoOp(REDIRECTING(orig-ton) is ${REDIRECTING(orig-ton)})
;;exten => s,n,NoOp(REDIRECTING(orig-name-charset) is ${REDIRECTING(orig-name-charset)})
;;exten => s,n,NoOp(REDIRECTING(orig-name-pres) is ${REDIRECTING(orig-name-pres)})
;;exten => s,n,NoOp(REDIRECTING(orig-num-pres) is ${REDIRECTING(orig-num-pres)})
;exten => s,n,NoOp(REDIRECTING(orig-pres) is ${REDIRECTING(orig-pres)})
;exten => s,n,NoOp(REDIRECTING(orig-subaddr-valid) is ${REDIRECTING(orig-subaddr-valid)})
;exten => s,n,NoOp(REDIRECTING(orig-subaddr) is ${REDIRECTING(orig-subaddr)})
;exten => s,n,NoOp(REDIRECTING(orig-tag) is ${REDIRECTING(orig-tag)})

;BUGBUG test dumping --v
;exten => s,n,NoOp(REDIRECTING(orig-all) is ${REDIRECTING(orig-all)})
;exten => s,n,NoOp(REDIRECTING(orig-num-valid) is ${REDIRECTING(orig-num-valid)})
;exten => s,n,NoOp(REDIRECTING(orig-num) is ${REDIRECTING(orig-num)})
;exten => s,n,NoOp(REDIRECTING(orig-ton) is ${REDIRECTING(orig-ton)})
;exten => s,n,NoOp(REDIRECTING(orig-num-plan) is ${REDIRECTING(orig-num-plan)})
;exten => s,n,NoOp(REDIRECTING(orig-num-pres) is ${REDIRECTING(orig-num-pres)})
;exten => s,n,NoOp(REDIRECTING(orig-name-valid) is ${REDIRECTING(orig-name-valid)})
;exten => s,n,NoOp(REDIRECTING(orig-name) is ${REDIRECTING(orig-name)})
;exten => s,n,NoOp(REDIRECTING(orig-name-charset) is ${REDIRECTING(orig-name-charset)})
;exten => s,n,NoOp(REDIRECTING(orig-name-pres) is ${REDIRECTING(orig-name-pres)})
;exten => s,n,NoOp(REDIRECTING(orig-subaddr-valid) is ${REDIRECTING(orig-subaddr-valid)})
;exten => s,n,NoOp(REDIRECTING(orig-subaddr) is ${REDIRECTING(orig-subaddr)})
;exten => s,n,NoOp(REDIRECTING(orig-subaddr-type) is ${REDIRECTING(orig-subaddr-type)})
;exten => s,n,NoOp(REDIRECTING(orig-subaddr-odd) is ${REDIRECTING(orig-subaddr-odd)})
;exten => s,n,NoOp(REDIRECTING(orig-pres) is ${REDIRECTING(orig-pres)})
;exten => s,n,NoOp(REDIRECTING(orig-tag) is ${REDIRECTING(orig-tag)})
;exten => s,n,NoOp(REDIRECTING(from-all) is ${REDIRECTING(from-all)})
;exten => s,n,NoOp(REDIRECTING(from-num-valid) is ${REDIRECTING(from-num-valid)})
;exten => s,n,NoOp(REDIRECTING(from-num) is ${REDIRECTING(from-num)})
;exten => s,n,NoOp(REDIRECTING(from-ton) is ${REDIRECTING(from-ton)})
;exten => s,n,NoOp(REDIRECTING(from-num-plan) is ${REDIRECTING(from-num-plan)})
;exten => s,n,NoOp(REDIRECTING(from-num-pres) is ${REDIRECTING(from-num-pres)})
;exten => s,n,NoOp(REDIRECTING(from-name-valid) is ${REDIRECTING(from-name-valid)})
;exten => s,n,NoOp(REDIRECTING(from-name) is ${REDIRECTING(from-name)})
;exten => s,n,NoOp(REDIRECTING(from-name-charset) is ${REDIRECTING(from-name-charset)})
;exten => s,n,NoOp(REDIRECTING(from-name-pres) is ${REDIRECTING(from-name-pres)})
;exten => s,n,NoOp(REDIRECTING(from-subaddr-valid) is ${REDIRECTING(from-subaddr-valid)})
;exten => s,n,NoOp(REDIRECTING(from-subaddr) is ${REDIRECTING(from-subaddr)})
;exten => s,n,NoOp(REDIRECTING(from-subaddr-type) is ${REDIRECTING(from-subaddr-type)})
;exten => s,n,NoOp(REDIRECTING(from-subaddr-odd) is ${REDIRECTING(from-subaddr-odd)})
;exten => s,n,NoOp(REDIRECTING(from-pres) is ${REDIRECTING(from-pres)})
;exten => s,n,NoOp(REDIRECTING(from-tag) is ${REDIRECTING(from-tag)})
;exten => s,n,NoOp(REDIRECTING(to-all) is ${REDIRECTING(to-all)})
;exten => s,n,NoOp(REDIRECTING(to-num-valid) is ${REDIRECTING(to-num-valid)})
;exten => s,n,NoOp(REDIRECTING(to-num) is ${REDIRECTING(to-num)})
;exten => s,n,NoOp(REDIRECTING(to-ton) is ${REDIRECTING(to-ton)})
;exten => s,n,NoOp(REDIRECTING(to-num-plan) is ${REDIRECTING(to-num-plan)})
;exten => s,n,NoOp(REDIRECTING(to-num-pres) is ${REDIRECTING(to-num-pres)})
;exten => s,n,NoOp(REDIRECTING(to-name-valid) is ${REDIRECTING(to-name-valid)})
;exten => s,n,NoOp(REDIRECTING(to-name) is ${REDIRECTING(to-name)})
;exten => s,n,NoOp(REDIRECTING(to-name-charset) is ${REDIRECTING(to-name-charset)})
;exten => s,n,NoOp(REDIRECTING(to-name-pres) is ${REDIRECTING(to-name-pres)})
;exten => s,n,NoOp(REDIRECTING(to-subaddr-valid) is ${REDIRECTING(to-subaddr-valid)})
;exten => s,n,NoOp(REDIRECTING(to-subaddr) is ${REDIRECTING(to-subaddr)})
;exten => s,n,NoOp(REDIRECTING(to-subaddr-type) is ${REDIRECTING(to-subaddr-type)})
;exten => s,n,NoOp(REDIRECTING(to-subaddr-odd) is ${REDIRECTING(to-subaddr-odd)})
;exten => s,n,NoOp(REDIRECTING(to-pres) is ${REDIRECTING(to-pres)})
;exten => s,n,NoOp(REDIRECTING(to-tag) is ${REDIRECTING(to-tag)})
;exten => s,n,NoOp(REDIRECTING(pres) is ${REDIRECTING(pres)})
;BUGBUG test dumping --^

;exten => s,n,NoOp(REDIRECTING(orig-reason) is ${REDIRECTING(orig-reason)})
exten => s,n,NoOp(REDIRECTING(count) is ${REDIRECTING(count)})
exten => s,n,NoOp(REDIRECTING(reason) is ${REDIRECTING(reason)})

[macro-displaycolp]
exten => s,1,NoOp(CONNECTEDLINE(all) is ${CONNECTEDLINE(all)})
exten => s,n,NoOp(CONNECTEDLINE(ton) is ${CONNECTEDLINE(ton)})
;exten => s,n,NoOp(CONNECTEDLINE(name-charset) is ${CONNECTEDLINE(name-charset)})
;exten => s,n,NoOp(CONNECTEDLINE(name-pres) is ${CONNECTEDLINE(name-pres)})
;exten => s,n,NoOp(CONNECTEDLINE(num-pres) is ${CONNECTEDLINE(num-pres)})
exten => s,n,NoOp(CONNECTEDLINE(pres) is ${CONNECTEDLINE(pres)})
exten => s,n,NoOp(CONNECTEDLINE(subaddr-valid) is ${CONNECTEDLINE(subaddr-valid)})
exten => s,n,NoOp(CONNECTEDLINE(subaddr) is ${CONNECTEDLINE(subaddr)})
exten => s,n,NoOp(CONNECTEDLINE(tag) is ${CONNECTEDLINE(tag)})

;BUGBUG test dumping --v
;exten => s,n,NoOp(CONNECTEDLINE(all) is ${CONNECTEDLINE(all)})
;exten => s,n,NoOp(CONNECTEDLINE(num-valid) is ${CONNECTEDLINE(num-valid)})
;exten => s,n,NoOp(CONNECTEDLINE(num) is ${CONNECTEDLINE(num)})
;exten => s,n,NoOp(CONNECTEDLINE(ton) is ${CONNECTEDLINE(ton)})
;exten => s,n,NoOp(CONNECTEDLINE(num-plan) is ${CONNECTEDLINE(num-plan)})
;exten => s,n,NoOp(CONNECTEDLINE(num-pres) is ${CONNECTEDLINE(num-pres)})
;exten => s,n,NoOp(CONNECTEDLINE(name-valid) is ${CONNECTEDLINE(name-valid)})
;exten => s,n,NoOp(CONNECTEDLINE(name) is ${CONNECTEDLINE(name)})
;exten => s,n,NoOp(CONNECTEDLINE(name-charset) is ${CONNECTEDLINE(name-charset)})
;exten => s,n,NoOp(CONNECTEDLINE(name-pres) is ${CONNECTEDLINE(name-pres)})
;exten => s,n,NoOp(CONNECTEDLINE(subaddr-valid) is ${CONNECTEDLINE(subaddr-valid)})
;exten => s,n,NoOp(CONNECTEDLINE(subaddr) is ${CONNECTEDLINE(subaddr)})
;exten => s,n,NoOp(CONNECTEDLINE(subaddr-type) is ${CONNECTEDLINE(subaddr-type)})
;exten => s,n,NoOp(CONNECTEDLINE(subaddr-odd) is ${CONNECTEDLINE(subaddr-odd)})
;exten => s,n,NoOp(CONNECTEDLINE(pres) is ${CONNECTEDLINE(pres)})
;exten => s,n,NoOp(CONNECTEDLINE(tag) is ${CONNECTEDLINE(tag)})
;BUGBUG test dumping --^

[macro-displayother]
exten => s,1,NoOp(CHANNEL(reversecharge) is ${CHANNEL(reversecharge)})
exten => s,n,NoOp(CHANNEL(keypad_digits) is ${CHANNEL(keypad_digits)})
exten => s,n,NoOp(CHANNEL(no_media_path) is ${CHANNEL(no_media_path)})
exten => s,n,NoOp(CHANNEL(dahdi_type) is ${CHANNEL(dahdi_type)})
exten => s,n,NoOp(CHANNEL(dahdi_span) is ${CHANNEL(dahdi_span)})
exten => s,n,NoOp(CHANNEL(dahdi_channel) is ${CHANNEL(dahdi_channel)})

[macro-displayall]
;exten => s,1,DumpChan(1)
exten => s,1,Macro(displaycli)
exten => s,n,Macro(displayredir)
;exten => s,n,Macro(displayother)

[macro-connected_line_send]
exten => s,1,NoOp(Connected line send macro for ${ARG1})
;exten => s,n,DumpChan(1)
exten => s,n,Macro(displaycolp)
exten => s,n,Macro(displaycli)

[connected_line_send]
exten => s,1,NoOp(Connected line send subroutine for ${ARG1})
;exten => s,n,DumpChan(1)
exten => s,n,Macro(displaycolp)
exten => s,n,Macro(displaycli)
exten => s,n,Return

[macro-redirecting_send]
exten => s,1,NoOp(Redirecting send macro for ${ARG1})
;exten => s,n,DumpChan(1)
exten => s,n,Macro(displaycli)
exten => s,n,Macro(displayredir)

[redirecting_send]
exten => s,1,NoOp(Redirecting send subroutine for ${ARG1})
;exten => s,n,DumpChan(1)
exten => s,n,Macro(displaycli)
exten => s,n,Macro(displayredir)
exten => s,n,Return

[macro-set_interception]
exten => s,1,NoOp(Setting interception variables for context:${ARG1} exten:${ARG2})

;; Use macro interception method
;exten => s,n,Set(__CONNECTED_LINE_CALLER_SEND_MACRO=connected_line_send)
;exten => s,n,Set(__CONNECTED_LINE_CALLER_SEND_MACRO_ARGS=caller context:${ARG1} exten:${ARG2})
;exten => s,n,Set(__CONNECTED_LINE_CALLEE_SEND_MACRO=connected_line_send)
;exten => s,n,Set(__CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS=CALLEE context:${ARG1} exten:${ARG2})
;exten => s,n,Set(__REDIRECTING_CALLER_SEND_MACRO=redirecting_send)
;exten => s,n,Set(__REDIRECTING_CALLER_SEND_MACRO_ARGS=caller context:${ARG1} exten:${ARG2})
;exten => s,n,Set(__REDIRECTING_CALLEE_SEND_MACRO=redirecting_send)
;exten => s,n,Set(__REDIRECTING_CALLEE_SEND_MACRO_ARGS=CALLEE context:${ARG1} exten:${ARG2})

; Use subroutine interception method
exten => s,n,Set(__CONNECTED_LINE_SEND_SUB=connected_line_send,s,1)
exten => s,n,Set(__CONNECTED_LINE_SEND_SUB_ARGS=context:${ARG1} exten:${ARG2})
exten => s,n,Set(__REDIRECTING_SEND_SUB=redirecting_send,s,1)
exten => s,n,Set(__REDIRECTING_SEND_SUB_ARGS=context:${ARG1} exten:${ARG2})

[macro-callit]
exten => s,1,NoOp(Requested to call ${ARG1},${ARG2},${ARG3}  CC_INTERFACES is ${CC_INTERFACES})
exten => s,n,Set(DESTS=${IF(${EXISTS(${CC_INTERFACES})}?${CC_INTERFACES}:${ARG1})})
;exten => s,n,CELGenUserEvent(RPM_Event,Extra_RPM_Data)
exten => s,n,Dial(${DESTS},${ARG2},${ARG3})
exten => s,n,NoOp(DIALSTATUS is ${DIALSTATUS})

; BUGBUG for issue 18212 --v
;exten => h,1,NoOp(Extension ${EXTEN} (macro-callit))
;exten => h,n,NoOp(DIALSTATUS is ${DIALSTATUS})
;exten => h,n,Set(CDR(WhoHungUp,r)=CALLED)
;;exten => h,n,Hangup
; BUGBUG for issue 18212 --^

[macro-vmail]
exten => s,1,NoOp(Checking voicemail${ARG1})
;exten => s,n,Answer()
exten => s,n,GotoIf($["${DIALSTATUS}"="BUSY"]?busy:unavail)
exten => s,n(unavail),Voicemail(${MACRO_EXTEN}${ARG1},u)
exten => s,n,MacroExit()
exten => s,n(busy),Voicemail(${MACRO_EXTEN}${ARG1},b)
exten => s,n,MacroExit()

; AGI invoked gosub
[agi_gosub]
exten => s,1,NoOp(AGI called, ARGC=${ARGC}, ARG1=${ARG1}, ARG2=${ARG2})
exten => s,n,Return(AGI returned ${ARG1})

; Predial gosub
[predial]
exten => s,1,NoOp(Predial, ARGC=${ARGC}, ARG1=${ARG1}, ARG2=${ARG2})
exten => s,n,Return(Predial ${ARG1})

exten => s,10(alt_entry),NoOp(Predial alternate entry, ARGC=${ARGC}, ARG1=${ARG1}, ARG2=${ARG2})
exten => s,n,Return(Predial ${ARG1})

; Answer gosub
[postanswer]
exten => s,1,NoOp(Post answer, ARGC=${ARGC}, ARG1=${ARG1}, ARG2=${ARG2})
exten => s,n,Return

[gosub_virtual_context]
exten => s,2,NoOp(Sneaky, ARGC=${ARGC}, ARG1=${ARG1}, ARG2=${ARG2}, ARG3=${ARG3})


; ************************************************************************

[default]
exten => s,1,NoOp(Unrouted call handler)
exten => s,n,Macro(displayall)
;exten => s,n,Wait(5)
exten => s,n,Answer()
exten => s,n,Wait(1)
;exten => s,n,Wait(15)
exten => s,n,Playback(tt-weasels)
exten => s,n,Hangup()

; Dialplan exception handler
exten => e,1,NoOp(Dialplan exception caught: Reason='${EXCEPTION(reason)}' ${EXCEPTION(context)},${EXCEPTION(exten)},${EXCEPTION(priority)})
;exten => e,n,NoOp(EXCEPTION(reason)   is ${EXCEPTION(reason)})
;exten => e,n,NoOp(EXCEPTION(context)  is ${EXCEPTION(context)})
;exten => e,n,NoOp(EXCEPTION(exten)    is ${EXCEPTION(exten)})
;exten => e,n,NoOp(EXCEPTION(priority) is ${EXCEPTION(priority)})
exten => e,n,Goto(s,1)

; ************************************************************************

[stdexten_ctx]
;
; Standard extension subroutine:
;   ${EXTEN} - Extension
;   ${ARG1} - Device(s) to ring
;   ${ARG2} - Optional context in Voicemail
;
; Note that the current version will drop through to the next priority in the
; case of their pressing '#'.  This gives more flexibility in what do to next:
; you can prompt for a new extension, or drop the call, or send them to a
; general delivery mailbox, or...
;
; The use of the LOCAL() function is purely for convenience.  Any variable
; initially declared as LOCAL() will disappear when the innermost Gosub context
; in which it was declared returns.  Note also that you can declare a LOCAL()
; variable on top of an existing variable, and its value will revert to its
; previous value (before being declared as LOCAL()) upon Return.
;
exten => _X.,50000(stdexten),NoOp(Start stdexten)
exten => _X.,n,Set(LOCAL(ext)=${EXTEN})
exten => _X.,n,Set(LOCAL(dev)=${ARG1})
exten => _X.,n,Set(LOCAL(cntx)=${ARG2})
exten => _X.,n,Set(LOCAL(mbx)=${ext}${IF($[!${ISNULL(${cntx})}]?@${cntx})})
exten => _X.,n,Dial(${dev},20)				; Ring the interface, 20 seconds maximum
exten => _X.,n,Goto(stdexten-${DIALSTATUS},1)		; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)

exten => stdexten-NOANSWER,1,Voicemail(${mbx},u)	; If unavailable, send to voicemail w/ unavail announce
exten => stdexten-NOANSWER,n,Return()			; If they press #, return to start

exten => stdexten-BUSY,1,Voicemail(${mbx},b)		; If busy, send to voicemail w/ busy announce
exten => stdexten-BUSY,n,Return()			; If they press #, return to start

exten => _stde[x]te[n]-.,1,Goto(stdexten-NOANSWER,1)	; Treat anything else as no answer

exten => a,1,VoicemailMain(${mbx})			; If they press *, send the user into VoicemailMain
exten => a,n,Return()

; ************************************************************************

[sip_default]
include => default

; ************************************************************************

; Intented setup
;                  BRI    -- User-B (200)
;         SIP     ISDN   / SIP
; User-A ----- * ------ *
; (100)       / NET  CPE \ SIP
; Phone-1____/            -- User-C (201)
; (400)                   \_ Phone-2 (500)

; ************************************************************************

; User-A
[sip_site_a]
; Calling Nonexistent user that redirects to User-B
exten => 110,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 110,n,Macro(displayall)
exten => 110,n,Set(REDIRECTING(from-all,i)="Fakeout" <${EXTEN}>)
exten => 110,n,Set(REDIRECTING(to-all,i)="User-B" <${USER_B}>)
;exten => 110,n,Set(REDIRECTING(to-pres,i)=allowed)
exten => 110,n,Set(REDIRECTING(count,i)=2)
exten => 110,n,Set(REDIRECTING(reason)=cfu)
exten => 110,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/${USER_B},60,kKtT)
exten => 110,n,Hangup()

; Goto undefined extension
exten => 111,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 111,n,GoTo(1122,1)

; Timeout call extension
exten => 112,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 112,n,Set(TIMEOUT(absolute)=8)
exten => 112,n,NoOp(TIMEOUT(absolute) is ${TIMEOUT(absolute)})
exten => 112,n,Macro(displayall)
exten => 112,n,Macro(set_interception,sip_site_a,${EXTEN})
exten => 112,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/400,30,kKtT)
exten => 112,n,Hangup()

; Timeout wait extension
exten => 113,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 113,n,Set(TIMEOUT(absolute)=5)
exten => 113,n,NoOp(TIMEOUT(absolute) is ${TIMEOUT(absolute)})
exten => 113,n,Macro(displayall)
exten => 113,n,Answer()
exten => 113,n,WaitExten(10)
;exten => 113,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/400,30,kKtT)
;exten => 113,n,Hangup()

; Background wait extension
exten => 114,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 114,n,Set(TIMEOUT(absolute)=5)
exten => 114,n,NoOp(TIMEOUT(absolute) is ${TIMEOUT(absolute)})
exten => 114,n,Macro(displayall)
exten => 114,n,Answer()
exten => 114,n,Background(tt-monkeys)

; Manual exception extension
exten => 115,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 115,n,RaiseException(Manual)

; ParkAndAnnounce to redirected number
exten => 116,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 116,n,Macro(displayall)
exten => 116,n,ParkAndAnnounce(pbx-transfer:PARKED,30,DAHDI/${DAHDI_NET_GROUP}/230)
exten => 116,n,NoOp(Back from ParkAndAnnounce)
exten => 116,n,Hangup()


; Calling Queue
exten => 120,1,NoOp(Extension ${EXTEN} (sip_site_a)
exten => 120,n,Macro(displayall)
exten => 120,n,Set(CONNECTEDLINE(all)="SipAQueue" <3582>)
exten => 120,n,Answer()
exten => 120,n,Queue(ast185)

; Calling a recording
exten => 121,1,NoOp(Extension ${EXTEN} (sip_site_a)
exten => 121,n,Macro(displayall)
exten => 121,n,Set(CONNECTEDLINE(all)="FoobarA" <3582>)
; SIP will not send FoobarA out with the next line since there is no number set!
;exten => 121,n,Set(CONNECTEDLINE(all)=FoobarA)
exten => 121,n,Answer()
exten => 121,n,Playback(tt-weasels)
exten => 121,n,Hangup()

; Calling a series of numbers (Forever)
exten => 122,1,NoOp(Extension ${EXTEN} (sip_site_a)
exten => 122,n,Macro(displayall)
exten => 122,n,Set(CONNECTEDLINE(all)="SipARecordings" <3582>)
exten => 122,n,Answer()
exten => 122,n(restart),Set(COUNT=100)
exten => 122,n(loopit),Set(COUNT=$[${COUNT} - 1])
exten => 122,n,SayNumber(${COUNT})
exten => 122,n,GotoIf(${COUNT}?loopit:restart)
exten => 122,n,Hangup()

; Calling Queue with a member
exten => 123,1,NoOp(Extension ${EXTEN} (sip_site_a)
exten => 123,n,Macro(displayall)
exten => 123,n,Set(CONNECTEDLINE(all)="SipQueueMember" <3582>)
exten => 123,n,Answer()
exten => 123,n,Queue(ast200,tT)

;; BUGBUG --v
; Calling User-B directly
;exten => 200,1,NoOp(Extension ${EXTEN} (sip_site_a))
;exten => 200,n,Macro(displayall)
;exten => 200,n,Set(CONNECTEDLINE(all)="Willy${EXTEN}" <9259>)
;exten => 200,n,Macro(set_interception,pots,${EXTEN})
;;exten => 200,n,Set(FRAME_TRACE(white)=CONTROL)
;exten => 200,n,Macro(callit,SIP/${EXTEN},30,IkKtT)
;exten => 200,n,Hangup()
;; BUGBUG --^

; Test AsyncAGI
;
; agi exec <channel name> <app and arguments> [id]
; agi exec <channel name> "WAIT FOR DIGIT -1" [id]
; agi exec <channel name> "EXEC Background tt-monkeys" [id]
; agi exec <channel name> "EXEC Dial SIP/200,30" [id]
; agi exec <channel name> "ASYNCAGI BREAK" [id]
;
exten => 214,1,NoOp(Extension ${EXTEN} (sip_site_a)
exten => 214,n,Answer()
exten => 214,n,Macro(displayall)
exten => 214,n,AGI(agi:async)
exten => 214,n,NoOp(Back in dialplan)
exten => 214,n,NoOp(AGISTATUS is ${AGISTATUS})
exten => 214,n,Hangup()

; Test AGI hangup (Issue 17954, 18492, 18935)
exten => 219,1,NoOp(Extension ${EXTEN} (sip_site_a)
exten => 219,n,Answer()
exten => 219,n,Macro(displayall)
exten => 219,n,AGI(/home/rmudgett/projects/lvm/setups/bri_phone/dial_219.pl)
exten => 219,n,NoOp(Back in dialplan)
exten => 219,n,NoOp(AGISTATUS is ${AGISTATUS})
exten => 219,n,Hangup()

; Calling User B or C or Phone 2
exten => _[235]XX,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => _[235]XX,n,Macro(displayall)
exten => _[235]XX,n,Macro(set_interception,sip_site_a,${EXTEN})
exten => _[235]XX,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/${EXTEN},60,kKtT)
exten => _[235]XX,n,Hangup()

;Calling Phone 1
exten => _4XX,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => _4XX,n,Macro(displayall)
exten => _4XX,n,Macro(set_interception,sip_site_a,${EXTEN})
;exten => _4XX,n,SendText(SIP mesage test)
exten => _4XX,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/${EXTEN},30,kKtT)
exten => _4XX,n,Hangup()

; Calling Phone 1 through local channel
exten => 410,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 410,n,Macro(displayall)
exten => 410,n,Macro(set_interception,sip_site_a,${EXTEN})
;exten => 410,n,SendText(SIP mesage test)
exten => 410,n,Macro(callit,Local/400@sip_site_a/nm,30,kKtT)
exten => 410,n,Hangup()

; Calling with keypad facility in setup.
exten => 600,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 600,n,Macro(displayall)
exten => 600,n,Answer()
exten => 600,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}//K(${EXTEN}),60,kKtT)
exten => 600,n,Hangup()

; Calling with keypad facility in setup.
exten => 601,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 601,n,Macro(displayall)
exten => 601,n,Answer()
exten => 601,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/200/K(${EXTEN}),60,kKtT)
exten => 601,n,Hangup()

; Calling with subaddress in setup.
exten => 602,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 602,n,Macro(displayall)
exten => 602,n,Set(CALLERID(subaddr)=8765)
exten => 602,n,Set(CALLERID(subaddr-valid)=1)
exten => 602,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/200:1234,60,kKtT)
exten => 602,n,Hangup()

; Calling with reverse charging in setup.
exten => 603,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 603,n,Macro(displayall)
exten => 603,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/200/R,60,kKtT)
exten => 603,n,Hangup()

;Calling Phone 1 using channel name format.
exten => 604,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 604,n,Macro(displayall)
exten => 604,n,Macro(set_interception,sip_site_a,${EXTEN})
exten => 604,n,Macro(callit,DAHDI/i3/400,30,kKtT)
exten => 604,n,Hangup()

; MeetMe conference plain
exten => 605,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 605,n,Macro(displayall)
exten => 605,n,MeetMe(,sM)

; MeetMe conference normal member
exten => 606,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 606,n,Macro(displayall)
exten => 606,n,MeetMe(,swM)

; MeetMe conference admin member
exten => 607,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 607,n,Macro(displayall)
exten => 607,n,MeetMe(,aAs,123)

; Calling POTS phones
exten => _70X,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => _70X,n,Macro(displayall)
exten => _70X,n,Macro(set_interception,sip_site_a,${EXTEN})
;exten => _70X,n,Set(FRAME_TRACE(white)=CONTROL)
;exten => _70X,n,Set(FRAME_TRACE(white)=CONTROL,DTMF_BEGIN,DTMF_END)
;exten => _70X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,kKtT)
;BUGBUG ASTERISK-17541
exten => _70X,n,Answer()
exten => _70X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,r)
;exten => _70X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,m)
;BUGBUG ASTERISK-17541
exten => _70X,n,Hangup()

; Calling POTS phones through analog "trunk" on ports 4-5.
exten => _71X,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => _71X,n,Macro(displayall)
exten => _71X,n,Macro(set_interception,sip_site_a,${EXTEN})
exten => _71X,n,Macro(callit,DAHDI/5/70${EXTEN:-1:1},60,kKtT)
exten => _71X,n,Hangup()

; Calling Far end using overlap dialing
exten => _9!,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => _9!,n,Macro(displayall)
exten => _9!,n,Answer()
exten => _9!,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/${EXTEN:1},60,kKtT)
;exten => _9!,n,Hangup()

;Generic call completion request
exten => 800,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 800,n,CallCompletionRequest
exten => 800,n,NoOp(CC_REQUEST_RESULT is ${CC_REQUEST_RESULT})
exten => 800,n,NoOp(CC_REQUEST_REASON is ${CC_REQUEST_REASON})
exten => 800,n,Hangup

;Generic call completion cancel
exten => 801,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 801,n,CallCompletionCancel
exten => 801,n,NoOp(CC_CANCEL_RESULT is ${CC_CANCEL_RESULT})
exten => 801,n,NoOp(CC_CANCEL_REASON is ${CC_CANCEL_REASON})
exten => 801,n,Hangup

; BUGBUG ASTERISK-18222 Call pickup race
exten => 802,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => 802,n,Dial(Local/701@en-pickup&Local/702@en-pickup)
; BUGBUG ASTERISK-18222

; Calling out SIP trunk
exten => _1XXX,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => _1XXX,n,Macro(displayall)
exten => _1XXX,n,Macro(set_interception,sip_site_a,${EXTEN})
exten => _1XXX,n,Macro(callit,SIP/${EXTEN}@sip_trk,30,kKtT)
exten => _1XXX,n,Hangup()

; Calling out SIP trunk
exten => _2XXX,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => _2XXX,n,Macro(displayall)
exten => _2XXX,n,Macro(set_interception,sip_site_a,${EXTEN})
exten => _2XXX,n,Macro(callit,SIP/${EXTEN}@sip_trk,30,kKtT)
exten => _2XXX,n,Hangup()

; SIP to SIP call
exten => _320X,1,NoOp(Extension ${EXTEN} (sip_site_a))
exten => _320X,n,Macro(displayall)
exten => _320X,n,Macro(set_interception,sip_site_a,${EXTEN})
exten => _320X,n,Macro(callit,SIP/${EXTEN:1},30,kKtT)
exten => _320X,n,Hangup()

include => stdexten_ctx
include => parkedcalls
include => default

; ************************************************************************

; User-B and User-C
[sip_site_b]
;exten => h,1,NoOp(Extension ${EXTEN} (sip_site_b))
;exten => h,n,NoOp(Before AGI, AGISTATUS is ${AGISTATUS})
;exten => h,n,AGI(/home/rmudgett/projects/lvm/setups/bri_phone/deadagi.pl)
;exten => h,n,NoOp(After AGI, AGISTATUS is ${AGISTATUS})

; Calling User-A or Phone 1
exten => _[14]XX,1,NoOp(Extension ${EXTEN} (sip_site_b))
; BUGBUG testing Caller id restructuring ---v
;exten => _[14]XX,n,NoOp(CALLERID(all,"parse,it" <9273>) is ${CALLERID(all,"parse,it" <9273>)})
;exten => _[14]XX,n,NoOp(CALLERID(name,"parse,it" <9273>) is ${CALLERID(name,"parse,it" <9273>)})
;exten => _[14]XX,n,NoOp(CALLERID(num,"parse,it" <9273>) is ${CALLERID(num,"parse,it" <9273>)})
;exten => _[14]XX,n,NoOp(CALLERPRES() is ${CALLERPRES()})
; BUGBUG testing Caller id restructuring ---^
exten => _[14]XX,n,Macro(displayall)
exten => _[14]XX,n,Macro(set_interception,sip_site_b,${EXTEN})
exten => _[14]XX,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/${EXTEN},60,kKtT)
exten => _[14]XX,n,Hangup()

; AGI invoke a gosub call
exten => 123,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 123,n,AGI(/home/rmudgett/projects/lvm/setups/bri_phone/dial_123.pl)
exten => 123,n,NoOp(Done with AGI script)
exten => 123,n,Hangup()

; Send authorization pin
exten => 124,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 124,n,Macro(displayall)
exten => 124,n,Macro(set_interception,sip_site_b,${EXTEN})
exten => 124,n,Answer()
exten => 124,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/${EXTEN}/P(400),60,kKtT)
;exten => 124,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/${EXTEN}/P(400),60,D(246)kKtT)
exten => 124,n,Hangup()

; Dial directly to 100
exten => 125,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 125,n,Macro(displayall)
exten => 125,n,Macro(set_interception,sip_site_b,${EXTEN})
exten => 125,n,Macro(callit,SIP/100,60,kKtT)
;exten => 125,n,Dial(SIP/100,60)
exten => 125,n,Hangup()

; FollowMe testing
exten => 126,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 126,n,Macro(displayall)
exten => 126,n,Macro(set_interception,sip_site_b,${EXTEN})
exten => 126,n,Wait(2)
exten => 126,n,FollowMe(default)
;exten => 126,n,FollowMe(default,I)
exten => 126,n,Hangup()

; BUGBUG testing message_unauth sipp scenario
exten => 127,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 127,n,Set(MESSAGE(body)=Watson come here)
exten => 127,n,MessageSend(sip:user@127.0.0.1:5062)
exten => 127,n,MessageSend(sip:user@127.0.0.1:5062,fred)
exten => 127,n,MessageSend(sip:user@127.0.0.1:5062,aloha)
exten => 127,n,MessageSend(sip:user@127.0.0.1:5062,"Anonymous" <sip:anonymous@invalid>)
exten => 127,n,MessageSend(sip:user@127.0.0.1:5062,"The Goober" <sip:3829@127.0.0.1>)
exten => 127,n,MessageSend(sip:user@127.0.0.1:5062,<sip:6719@127.0.0.1>)
exten => 127,n,Hangup()

; ExtenSpy testing
exten => 128,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 128,n,Macro(displayall)
exten => 128,n,Answer()
exten => 128,n,Wait(2)
exten => 128,n,ExtenSpy(100@pots)
exten => 128,n,Hangup()

; ChanSpy testing
exten => 129,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 129,n,Macro(displayall)
exten => 129,n,Answer()
exten => 129,n,Wait(2)
exten => 129,n,ChanSpy(DAHDI)
exten => 129,n,Hangup()


; Fork call for CC
exten => 300,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 300,n,Macro(displayall)
exten => 300,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/100&DAHDI/${DAHDI_CPE_GROUP}/400,60,kKtT)
exten => 300,n,Hangup()

; Calling peer User B/C
exten => _20X,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => _20X,n,Macro(displayall)
exten => _20X,n,Macro(callit,SIP/${EXTEN},30,kKtT)
exten => _20X,n,Hangup()

; Calling Nonexistent user that redirects to User-A
exten => 210,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 210,n,Macro(displayall)
exten => 210,n,Set(REDIRECTING(from-all,i)="Fakeout" <${EXTEN}>)
exten => 210,n,Set(REDIRECTING(to-all,i)="User-A" <${USER_A}>)
;exten => 210,n,Set(REDIRECTING(to-pres,i)=allowed)
exten => 210,n,Set(REDIRECTING(count,i)=2)
exten => 210,n,Set(REDIRECTING(reason)=cfu)
exten => 210,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/${USER_A},60,kKtT)
exten => 210,n,Hangup()

; Calling Nonexistent user that redirects to Phone-1
exten => 211,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 211,n,Macro(displayall)
exten => 211,n,Set(REDIRECTING(from-all,i)="Fakeout" <${EXTEN}>)
exten => 211,n,Set(REDIRECTING(to-all,i)="User-A" <${USER_A}>)
;exten => 211,n,Set(REDIRECTING(to-pres,i)=allowed)
exten => 211,n,Set(REDIRECTING(count,i)=2)
exten => 211,n,Set(REDIRECTING(reason)=cfu)
exten => 211,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/${PH_1},60,kKtT)
exten => 211,n,Hangup()

; Calling Nonexistent user that redirects to 110
exten => 212,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 212,n,Macro(displayall)
;exten => 212,n,Set(REDIRECTING(orig-all,i)="Fakeorig" <1${EXTEN}>)
;exten => 212,n,Set(REDIRECTING(orig-reason,i)=cfb)
exten => 212,n,Set(REDIRECTING(from-all,i)="Fakeout" <${EXTEN}>)
exten => 212,n,Set(REDIRECTING(to-all,i)="User-A" <1${USER_A}>)
;exten => 212,n,Set(REDIRECTING(to-pres,i)=allowed)
exten => 212,n,Set(REDIRECTING(count,i)=2)
exten => 212,n,Set(REDIRECTING(reason)=cfu)
exten => 212,n,Macro(set_interception,sip_site_b,${EXTEN})
exten => 212,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/111,60,kKtT)
exten => 212,n,Hangup()

; Calling Nonexistent user that redirects to Fake user
exten => 214,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 214,n,Macro(displayall)
exten => 214,n,Set(REDIRECTING(from-all,i)="BB-Gun" <214>)
exten => 214,n,Set(REDIRECTING(to-all,i)="A Monkey" <215>)
;exten => 214,n,Set(REDIRECTING(to-pres,i)=allowed)
exten => 214,n,Set(REDIRECTING(count,i)=1)
exten => 214,n,Set(REDIRECTING(reason)=cfu)
exten => 214,n,Macro(set_interception,sip_site_b,${EXTEN})
exten => 214,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/215,60,kKtT)
exten => 214,n,Hangup()

; Calling Queue
exten => 220,1,NoOp(Extension ${EXTEN} (sip_site_b)
exten => 220,n,Macro(displayall)
exten => 220,n,Set(CONNECTEDLINE(all)="SipBQueue" <3527>)
exten => 220,n,Answer()
;exten => 220,n,SendText(SIP Qb)
exten => 220,n,Queue(ast185)

; Calling a recording
exten => 221,1,NoOp(Extension ${EXTEN} (sip_site_b)
exten => 221,n,Macro(displayall)
exten => 221,n,Set(CONNECTEDLINE(all)="FoobarB" <3527>)
; SIP will not send FoobarB out with the next line since there is no number set!
;exten => 221,n,Set(CONNECTEDLINE(all)=FoobarB)
exten => 221,n,NoOp(CONNECTEDLINE(all) is ${CONNECTEDLINE(all)})
exten => 221,n,Answer()
exten => 221,n,Playback(tt-weasels)
exten => 221,n,Hangup()

; Calling a series of numbers (Forever)
exten => 222,1,NoOp(Extension ${EXTEN} (sip_site_b)
exten => 222,n,Macro(displayall)
exten => 222,n,Set(CONNECTEDLINE(all)="FoobarB" <3527>)
exten => 222,n,Answer()
exten => 222,n(restart),Set(COUNT=100)
exten => 222,n(loopit),Set(COUNT=$[${COUNT} - 1])
exten => 222,n,SayNumber(${COUNT})
exten => 222,n,GotoIf(${COUNT}?loopit:restart)
exten => 222,n,Hangup()

;Calling Phone 2
exten => _5XX,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => _5XX,n,Macro(displayall)
exten => _5XX,n,Macro(callit,DAHDI/${DAHDI_PH_2_GROUP}/${EXTEN},30,kKtT)
exten => _5XX,n,Hangup()

; MeetMe conference plain
exten => 605,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 605,n,Macro(displayall)
exten => 605,n,MeetMe(,sM)

; MeetMe conference normal member
exten => 606,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 606,n,Macro(displayall)
exten => 606,n,MeetMe(,swM)

; MeetMe conference admin member
exten => 607,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 607,n,Macro(displayall)
exten => 607,n,MeetMe(,aAs,123)

;Calling Phone 1 with deferred DTMF digits
exten => 608,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 608,n,Macro(displayall)
exten => 608,n,Macro(set_interception,sip_site_b,${EXTEN})
exten => 608,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/400ww1234,60,IkKtT)
;exten => 608,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/400w1234,60,IkKtT)
;exten => 608,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/400w,60,IkKtT)
exten => 608,n,Hangup()


; Calling POTS phones
exten => _70X,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => _70X,n,Macro(displayall)
exten => _70X,n,Macro(set_interception,sip_site_b,${EXTEN})
;exten => _70X,n,Set(FRAME_TRACE(white)=CONTROL)
;exten => _70X,n,Set(FRAME_TRACE(white)=CONTROL,DTMF_BEGIN,DTMF_END)
exten => _70X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,kKtT)
exten => _70X,n,Hangup()

; Predial w/ forked call
exten => 711,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 711,n,Macro(displayall)
exten => 711,n,Macro(set_interception,sip_site_b,${EXTEN})
;exten => 711,n,Set(FRAME_TRACE(white)=CONTROL)
;exten => 711,n,Set(FRAME_TRACE(white)=CONTROL,DTMF_BEGIN,DTMF_END)
;exten => 711,n,Macro(callit,DAHDI/1&DAHDI/2,60,kKtTb(predial^s^1(CALLEE^${EXTEN}))B(predial^s^1(caller^${EXTEN}))U(postanswer^On_CALLEE^${EXTEN}))
exten => 711,n,Macro(callit,DAHDI/1&DAHDI/2,60,kKtTb(predial^s^1(CALLEE^${EXTEN}))B(predial^s^alt_entry(caller^${EXTEN}))U(postanswer^On_CALLEE^${EXTEN}))
;exten => 711,n,Dial(DAHDI/1&DAHDI/2,60,kKtTb(predial^s^1(CALLEE^${EXTEN}))B(predial^s^1(caller^${EXTEN}))U(postanswer^On_CALLEE^${EXTEN}))
;exten => 711,n,Dial(DAHDI/1&DAHDI/2,60,kKtTb(predial^s^1)B(predial^s^1)U(postanswer^On_CALLEE^${EXTEN}))
exten => 711,n,Hangup()

; Park call with Park not in first priority
exten => 780,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 780,n,NoOp(BLINDTRANSFER is ${BLINDTRANSFER})
exten => 780,n,Park()
exten => 780,n,NoOp(After park)

; ParkAndAnnounce test
exten => 781,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 781,n,NoOp(BLINDTRANSFER is ${BLINDTRANSFER})
exten => 781,n,ParkAndAnnounce(pbx-transfer:PARKED,30,SIP/100)
exten => 781,n,NoOp(After ParkAndAnnounce)


;Generic call completion request
exten => 800,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 800,n,CallCompletionRequest
exten => 800,n,NoOp(CC_REQUEST_RESULT is ${CC_REQUEST_RESULT})
exten => 800,n,NoOp(CC_REQUEST_REASON is ${CC_REQUEST_REASON})
exten => 800,n,Hangup

;Generic call completion cancel
exten => 801,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 801,n,CallCompletionCancel
exten => 801,n,NoOp(CC_CANCEL_RESULT is ${CC_CANCEL_RESULT})
exten => 801,n,NoOp(CC_CANCEL_REASON is ${CC_CANCEL_REASON})
exten => 801,n,Hangup

; BUGBUG ASTERISK-18222 Call pickup race
exten => 802,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => 802,n,Dial(Local/701@en-pickup&Local/702@en-pickup)
; BUGBUG ASTERISK-18222

; Calling Far end using overlap dialing
exten => _9!,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => _9!,n,Macro(displayall)
exten => _9!,n,Answer()
exten => _9!,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/${EXTEN:1},60,kKtT)
;exten => _9!,n,Hangup()

; Calling out SIP trunk
exten => _1XXX,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => _1XXX,n,Macro(displayall)
exten => _1XXX,n,Macro(set_interception,sip_site_b,${EXTEN})
exten => _1XXX,n,Macro(callit,SIP/${EXTEN}@sip_trk,30,kKtT)
exten => _1XXX,n,Hangup()

; Calling out SIP trunk
exten => _2XXX,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => _2XXX,n,Macro(displayall)
exten => _2XXX,n,Macro(set_interception,sip_site_b,${EXTEN})
exten => _2XXX,n,Macro(callit,SIP/${EXTEN}@sip_trk,30,kKtT)
exten => _2XXX,n,Hangup()

; SIP to SIP call
exten => _31XX,1,NoOp(Extension ${EXTEN} (sip_site_b))
exten => _31XX,n,Macro(displayall)
exten => _31XX,n,Macro(set_interception,sip_site_a,${EXTEN})
exten => _31XX,n,Macro(callit,SIP/${EXTEN:1},30,kKtT)
exten => _31XX,n,Hangup()

include => stdexten_ctx
include => parkedcalls
include => default

; ************************************************************************

[sip_trunk]
; Section for SIP trunk

; Calling User-A
exten => 1100,1,NoOp(Extension ${EXTEN} (sip_trunk))
exten => 1100,n,Macro(displayall)
exten => 1100,n,Set(CONNECTEDLINE(all)="PostedMarky" <4321>)
exten => 1100,n,Macro(set_interception,sip_trunk,${EXTEN})
;exten => 1100,n,Macro(callit,SIP/${EXTEN:1},30,IkKtT)
exten => 1100,n,Macro(callit,SIP/${EXTEN:1},30,kKtT)
exten => 1100,n,Hangup()

; Calling Queue
exten => 1120,1,NoOp(Extension ${EXTEN} (sip_trunk)
exten => 1120,n,Macro(displayall)
exten => 1120,n,Set(CONNECTEDLINE(all)="NetQueue" <5647>)
exten => 1120,n,Answer()
;exten => 1120,n,SendText(Student Q)
exten => 1120,n,Queue(ast185)

; Calling Phone on network side (Not necessarily connected.)
exten => _14XX,1,NoOp(Extension ${EXTEN} (sip_trunk))
exten => _14XX,n,Macro(displayall)
exten => _14XX,n,Set(CONNECTEDLINE(all)="Phone-${EXTEN}" <3${EXTEN}>)
;exten => _14XX,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/${EXTEN:1},30,IkKtT)
exten => _14XX,n,Macro(set_interception,sip_trunk,${EXTEN})
exten => _14XX,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/${EXTEN:1},30,IkKtT)
exten => _14XX,n,Hangup()

; Calling POTS phones
exten => _170X,1,NoOp(Extension ${EXTEN} (sip_trunk))
exten => _170X,n,Macro(displayall)
exten => _170X,n,Macro(set_interception,sip_trunk,${EXTEN})
exten => _170X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,kKtT)
exten => _170X,n,Hangup()

; Calling User B or C
exten => _220X,1,NoOp(Extension ${EXTEN} (sip_trunk))
exten => _220X,n,Macro(displayall)
exten => _220X,n,Macro(set_interception,sip_trunk,${EXTEN})
;exten => _220X,n,Set(CONNECTEDLINE(all)="Willy${EXTEN}" <9259>)
;exten => _220X,n,Macro(callit,SIP/${EXTEN:1},30,IkKtT)
exten => _220X,n,Macro(callit,SIP/${EXTEN:1},30,kKtT)
exten => _220X,n,Hangup()

; Calling Queue
exten => 2220,1,NoOp(Extension ${EXTEN} (sip_trunk)
exten => 2220,n,Macro(displayall)
exten => 2220,n,Set(CONNECTEDLINE(all)="CpeQueue" <9547>)
exten => 2220,n,Answer()
exten => 2220,n,Queue(ast185)

; Calling Phone 2
exten => 2500,1,NoOp(Extension ${EXTEN} (sip_trunk))
exten => 2500,n,Macro(displayall)
exten => 2500,n,Set(CONNECTEDLINE(all)="Phone-2" <8492>)
exten => 2500,n,Macro(callit,DAHDI/${DAHDI_PH_2_GROUP}/${EXTEN:1},30,IkKtT)
exten => 2500,n,Hangup()

; Calling POTS phones
exten => _270X,1,NoOp(Extension ${EXTEN} (sip_trunk))
exten => _270X,n,Macro(displayall)
exten => _270X,n,Macro(set_interception,sip_trunk,${EXTEN})
exten => _270X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,kKtT)
exten => _270X,n,Hangup()

include => default

; ************************************************************************

[bri_default]
include => default

; ************************************************************************

[bri_net]
; Section for port pretending to be the CO(Network)

; Calling User-A
;exten => 100,hint,SIP/${EXTEN}
exten => 100,hint,SIP/100
exten => 100,1,NoOp(Extension ${EXTEN} (bri_net))
exten => 100,n,Proceeding()
; Wait for Q.SIG name
;exten => 100,n,Wait(1)
exten => 100,n,Macro(displayall)
exten => 100,n,Set(CONNECTEDLINE(all)="PostedMarky" <4321>)
exten => 100,n,Macro(set_interception,bri_net,${EXTEN})
;BUGBUG
exten => 100,n,Set(CONNECTED_LINE_SEND_BLOCK=1)
;BUGBUG
;exten => 100,n,Macro(callit,SIP/${EXTEN},30,IkKtT)
exten => 100,n,Macro(callit,SIP/${EXTEN},30,kKtT)
exten => 100,n,Hangup()

; Calling User-A with subaddress
exten => 101,1,NoOp(Extension ${EXTEN} (bri_net))
exten => 101,n,Proceeding()
exten => 101,n,Macro(displayall)
exten => 101,n,Set(CONNECTEDLINE(all,i)="PostedMarky" <4321>)
exten => 101,n,Set(CONNECTEDLINE(subaddr,i)=5847)
exten => 101,n,Set(CONNECTEDLINE(subaddr-valid)=1)
exten => 101,n,Macro(set_interception,bri_net,${EXTEN})
exten => 101,n,Macro(callit,SIP/100,30,IkKtT)
exten => 101,n,Hangup()

; Special overlap dialing extension test
exten => 1000,1,NoOp(Extension ${EXTEN} (bri_net))
exten => 1000,n,Proceeding()
exten => 1000,n,Macro(displayall)
exten => 1000,n,Set(CONNECTEDLINE(all)="SpecialMark" <4221>)
exten => 1000,n,Macro(callit,SIP/100,30,IkKtT)
exten => 1000,n,Hangup()

; Fork call for CC
exten => 110,1,NoOp(Extension ${EXTEN} (bri_net))
exten => 110,n,Proceeding()
exten => 110,n,Macro(displayall)
exten => 110,n,Macro(callit,SIP/100&DAHDI/${DAHDI_PH_1_GROUP}/400,30,kKtT)
exten => 110,n,Hangup()

; Calling Nonexistent user that redirects to User-A
exten => 111,1,NoOp(Extension ${EXTEN} (bri_net))
exten => 111,n,Proceeding()
exten => 111,n,Macro(displayall)
exten => 111,n,Set(REDIRECTING(from-all,i)="Bouncer" <${EXTEN}>)
exten => 111,n,Set(REDIRECTING(to-all,i)="User-A" <${USER_A}>)
exten => 111,n,Set(REDIRECTING(to-pres,i)=allowed)
exten => 111,n,Set(REDIRECTING(count,i)=1)
exten => 111,n,Set(REDIRECTING(reason)=cfu)
exten => 111,n,Set(CONNECTEDLINE(all)="PostedMarky" <4321>)
exten => 111,n,Macro(callit,SIP/${USER_A},30,IkKtT)
exten => 111,n,Hangup()

; Calling Queue
exten => 120,1,NoOp(Extension ${EXTEN} (bri_net)
exten => 120,n,Proceeding()
exten => 120,n,Macro(displayall)
exten => 120,n,Set(CONNECTEDLINE(all)="NetQueue" <5647>)
exten => 120,n,Answer()
;exten => 120,n,SendText(Student Q)
exten => 120,n,Queue(ast185)

; Calling Queue with a member
exten => 123,1,NoOp(Extension ${EXTEN} (bri_net)
exten => 123,n,Macro(displayall)
exten => 123,n,Set(CONNECTEDLINE(all)="SipQueueMember" <3582>)
exten => 123,n,Answer()
exten => 123,n,Queue(ast200,tT)

; Wait for authorization pin
exten => 124,1,NoOp(Extension ${EXTEN} (bri_net))
exten => 124,n,Macro(displayall)
exten => 124,n,Proceeding()
exten => 124,n,WaitExten(3)
exten => 124,n,Hangup()

; Bouncing user back over link
exten => 215,1,NoOp(Extension ${EXTEN} (bri_net))
exten => 215,n,Proceeding()
exten => 215,n,Macro(displayall)
;exten => 215,n,Wait(1)
;exten => 215,n,Macro(displayall)
;exten => 215,n,Macro(set_interception,bri_net,${EXTEN})
exten => 215,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/${EXTEN},60,kKtT)
exten => 215,n,Hangup()

; Calling User B or C
exten => _2XX,1,NoOp(Extension ${EXTEN} (bri_net) (From call deflection?))
exten => _2XX,n,Proceeding()
exten => _2XX,n,Macro(displayall)
exten => _2XX,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/${EXTEN},60,kKtT)
exten => _2XX,n,Hangup()

; Calling Phone 1
; The following commented out line gave a warning message (see mantis 16166)
;exten => 400,hint,DAHDI/i2/${GLOBAL(PH_1)}
;exten => 400,hint,DAHDI/i2/${EXTEN}
exten => 400,hint,DAHDI/i2/400(bri_net hint 400)
exten => 400,1,NoOp(Extension ${EXTEN} (bri_net))
;exten => 400,n,SendText(Exchange student)
exten => 400,n,Proceeding()
exten => 400,n,Macro(displayall)
;exten => 400,n,SendText(Foreign exchange)
exten => 400,n,Set(CONNECTEDLINE(all)="Phone-1" <3832>)
;exten => 400,n,Set(FRAME_TRACE(white)=CONTROL)
exten => 400,n,Macro(set_interception,bri_net,${EXTEN})
exten => 400,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/${EXTEN},30,IkKtT)
exten => 400,n,Macro(vmail)
exten => 400,n,Hangup()

; Calling Phone 1 (Forced caller NSAP subaddress)
exten => 410,hint,DAHDI/i2/410
exten => 410,1,NoOp(Extension ${EXTEN} (bri_net))
exten => 410,n,Proceeding()
exten => 410,n,Macro(displayall)
exten => 410,n,Set(CALLERID(subaddr-valid)=1)
exten => 410,n,Set(CALLERID(subaddr)=5432)
exten => 410,n,Set(CALLERID(subaddr-type)=0)
exten => 410,n,Set(CALLERID(subaddr-odd)=0)
exten => 410,n,Set(CONNECTEDLINE(all)="Phone-1" <3833>)
exten => 410,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/400,30,IkKtT)
exten => 410,n,Macro(vmail,@other)
exten => 410,n,Hangup()

; Calling Phone 1 (Forced caller user_specified BCD odd subaddress)
exten => 411,hint,DAHDI/i2/411
exten => 411,1,NoOp(Extension ${EXTEN} (bri_net))
exten => 411,n,Proceeding()
exten => 411,n,Macro(displayall)
exten => 411,n,Set(CALLERID(subaddr-valid)=1)
exten => 411,n,Set(CALLERID(subaddr)=54321)
exten => 411,n,Set(CALLERID(subaddr-type)=2)
exten => 411,n,Set(CALLERID(subaddr-odd)=1)
exten => 411,n,Set(CONNECTEDLINE(all)="Phone-1" <3834>)
exten => 411,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/400,30,IkKtT)
exten => 411,n,Macro(vmail,@spaz)
exten => 411,n,Hangup()

; BUGBUG Mantis issue 18509 Fall off dialplan
exten => 412,1,NoOp(Extension ${EXTEN} (bri_net))
exten => 412,n,Proceeding()
exten => 412,n,Congestion(5)

;Calling Phone 1 with deferred DTMF digits
exten => 413,1,NoOp(Extension ${EXTEN} (bri_net))
exten => 413,n,Macro(displayall)
exten => 413,n,Macro(set_interception,bri_net,${EXTEN})
exten => 413,n,Set(CONNECTEDLINE(all)="Phone-${EXTEN}" <3${EXTEN}>)
exten => 413,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/400ww1234,30,IkKtT)
exten => 413,n,Hangup()

; Calling Phone on network side (Not necessarily connected.)
exten => _4XX,1,NoOp(Extension ${EXTEN} (bri_net))
exten => _4XX,n,Proceeding()
exten => _4XX,n,Macro(displayall)
exten => _4XX,n,Set(CONNECTEDLINE(all)="Phone-${EXTEN}" <3${EXTEN}>)
exten => _4XX,n,Macro(set_interception,bri_net,${EXTEN})
exten => _4XX,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/${EXTEN},30,IkKtT)
;exten => _4XX,n,Macro(vmail)
exten => _4XX,n,Hangup()

include => default


; ************************************************************************

[bri_cpe]
; Section for port connected to the CO

; Calling User B or C
exten => _20X,hint,SIP/200
exten => _20X,1,NoOp(Extension ${EXTEN} (bri_cpe))
exten => _20X,n,Proceeding()
exten => _20X,n,Macro(displayall)
exten => _20X,n,Macro(displayother)
exten => _20X,n,Macro(set_interception,bri_cpe,${EXTEN})
exten => _20X,n,Set(CONNECTEDLINE(subaddr,i)=4321)
exten => _20X,n,Set(CONNECTEDLINE(subaddr-valid,i)=1)
exten => _20X,n,Set(CONNECTEDLINE(all)="Willy${EXTEN}" <9259>)
;exten => _20X,n,Macro(callit,SIP/${EXTEN},30,IkKtT)
exten => _20X,n,Macro(callit,SIP/${EXTEN},30,kKtT)
exten => _20X,n,Hangup()

; Calling Nonexistent user that redirects to User-B
exten => 211,1,NoOp(Extension ${EXTEN} (bri_cpe))
exten => 211,n,Proceeding()
exten => 211,n,Macro(displayall)
exten => 211,n,Set(REDIRECTING(from-all,i)="Bouncer" <${EXTEN}>)
exten => 211,n,Set(REDIRECTING(to-all,i)="User-B" <${USER_B}>)
exten => 211,n,Set(REDIRECTING(to-pres,i)=allowed)
exten => 211,n,Set(REDIRECTING(count,i)=1)
exten => 211,n,Set(REDIRECTING(reason)=cfu)
exten => 211,n,Set(CONNECTEDLINE(all)="Wonka" <8765>)
exten => 211,n,Macro(callit,SIP/${USER_B},30,IkKtT)
exten => 211,n,Hangup()

;; Calling Nonexistent user that deflects the call to User-B
;exten => 212,1,NoOp(Extension ${EXTEN} (bri_cpe))
;exten => 212,n,Proceeding()
;exten => 212,n,Macro(displayall)
;exten => 212,n,Ringing()
; Note DAHDISendCallreroutingFacility will always hangup the call because it returns non-zero.
;exten => 212,n,DAHDISendCallreroutingFacility(200,${EXTEN},cfu)
;exten => 212,n,Wait(10)
;exten => 212,n,misdn_facility(calldeflect,200)
;exten => 212,n,misdn_facility(callrerouting,200)
;exten => 212,n,Hangup()

; Calling Nonexistent user that "transfers" to User-B
exten => 213,1,NoOp(Extension ${EXTEN} (bri_cpe))
exten => 213,n,Proceeding()
exten => 213,n,Macro(displayall)
exten => 213,n,Set(CONNECTEDLINE(all)="Wilber" <7786>)
exten => 213,n,Answer()
exten => 213,n,Wait(4)
exten => 213,n,Set(CONNECTEDLINE(all)="Transfer" <3465>)
exten => 213,n,Wait(1)
exten => 213,n,Macro(callit,SIP/${USER_B},30,IkKtT)
exten => 213,n,Hangup()

; Terminate redirect bounce
exten => 215,1,NoOp(Extension ${EXTEN} (bri_cpe))
exten => 215,n,Proceeding()
exten => 215,n,Macro(displayall)
;exten => 215,n,Wait(1)
;exten => 215,n,Macro(displayall)
exten => 215,n,Set(CONNECTEDLINE(all)="Gilbert" <7392>)
exten => 215,n,Answer()
exten => 215,n,Playback(tt-weasels)
exten => 215,n,Wait(4)
exten => 215,n,Hangup()

; Media before answer
exten => 216,1,NoOp(Extension ${EXTEN} (bri_cpe)
exten => 216,n,Proceeding()
exten => 216,n,Macro(displayall)
exten => 216,n,NoOp(CHANNEL(no_media_path) is ${CHANNEL(no_media_path)})
exten => 216,n,Wait(1)
exten => 216,n,Progress()
exten => 216,n,Playback(tt-somethingwrong,noanswer)
exten => 216,n,Wait(1)
exten => 216,n,Answer()
exten => 216,n,Playback(tt-weasels)
exten => 216,n,Hangup()

exten => 217,1,NoOp(Extension ${EXTEN} (bri_cpe)
exten => 217,n,Proceeding()
exten => 217,n,Macro(displayall)
exten => 217,n,Macro(callit,SIP/${USER_B},30,gkKtT)
exten => 217,n,NoOp(DIALSTATUS is ${DIALSTATUS})
exten => 217,n,NoOp(HANGUPCAUSE is ${HANGUPCAUSE})
exten => 217,n,Macro(callit,SIP/${USER_B},30,gFkKtT)
exten => 217,n,NoOp(DIALSTATUS is ${DIALSTATUS})
exten => 217,n,NoOp(HANGUPCAUSE is ${HANGUPCAUSE})
exten => 217,n,Hangup()

; Test AGI double dial
exten => 218,1,NoOp(Extension ${EXTEN} (bri_cpe)
exten => 218,n,Proceeding()
exten => 218,n,Macro(displayall)
exten => 218,n,AGI(/home/rmudgett/projects/lvm/setups/bri_phone/dial_218.pl)
exten => 218,n,NoOp(Back in dialplan)
exten => 218,n,NoOp(AGISTATUS is ${AGISTATUS})
exten => 218,n,Hangup()


; Calling Queue
exten => 220,1,NoOp(Extension ${EXTEN} (bri_cpe)
exten => 220,n,Proceeding()
exten => 220,n,Macro(displayall)
exten => 220,n,Set(CONNECTEDLINE(all)="CpeQueue" <9547>)
exten => 220,n,Answer()
exten => 220,n,Queue(ast185)

; Calling busy number
exten => 221,1,NoOp(Extension ${EXTEN} (bri_cpe)
exten => 221,n,Proceeding()
exten => 221,n,Macro(displayall)
exten => 221,n,Busy()
exten => 221,n,NoOp(Busy complete)
exten => 221,n,Hangup()

; Calling congested number
exten => 222,1,NoOp(Extension ${EXTEN} (bri_cpe)
exten => 222,n,Proceeding()
exten => 222,n,Macro(displayall)
exten => 222,n,Congestion()
exten => 222,n,NoOp(Congestion complete)
exten => 222,n,Hangup()


; Calling Nonexistent user that deflects the call to User-B
exten => 230,1,NoOp(Extension ${EXTEN} (bri_cpe))
exten => 230,n,Proceeding()
exten => 230,n,Macro(displayall)
exten => 230,n,Ringing()
;exten => 230,n,Wait(1)
exten => 230,n,Wait(10)
; Note DAHDISendCallreroutingFacility will always hangup the call because it returns non-zero.
exten => 230,n,DAHDISendCallreroutingFacility(200,${EXTEN},cfu)
;exten => 230,n,DAHDISendCallreroutingFacility(202,${EXTEN},cfu)
;exten => 230,n,DAHDISendCallreroutingFacility(9000,${EXTEN},cfu)
exten => 230,n,Wait(10)
exten => 230,n,Hangup()

; Calling Nonexistent user that deflects the call repeatedly until the extension gets down to 230
exten => _23X,1,NoOp(Extension ${EXTEN} (bri_cpe))
exten => _23X,n,Proceeding()
exten => _23X,n,Macro(displayall)
exten => _23X,n,Ringing()
exten => _23X,n,Wait(1)
; Note DAHDISendCallreroutingFacility will always hangup the call because it returns non-zero.
exten => _23X,n,DAHDISendCallreroutingFacility($[${EXTEN} - 1],${EXTEN},cfu)
;exten => _23X,n,Wait(10)
exten => _23X,n,Hangup()

; Calling nonexistent user that just answers for 10 seconds.
exten => 240,1,NoOp(Extension ${EXTEN} (bri_cpe))
exten => 240,n,Proceeding()
exten => 240,n,Macro(displayall)
exten => 240,n,Answer()
exten => 240,n,Wait(1)
exten => 240,n,Playback(tt-weasels)
exten => 240,n,Wait(1)
exten => 240,n,Hangup()

; Calling Nonexistent user that deflects the call to Phone_1
exten => 241,1,NoOp(Extension ${EXTEN} (bri_cpe))
exten => 241,n,Proceeding()
exten => 241,n,Macro(displayall)
exten => 241,n,Ringing()
exten => 241,n,Wait(1)
; Note DAHDISendCallreroutingFacility will always hangup the call because it returns non-zero.
exten => 241,n,DAHDISendCallreroutingFacility(${PH_1},${EXTEN},cfu)
exten => 241,n,Wait(10)
exten => 241,n,Hangup()

; Calling POTS phones 1-4
exten => _25X,1,NoOp(Extension ${EXTEN} (bri_cpe))
exten => _25X,n,Proceeding()
exten => _25X,n,Macro(displayall)
exten => _25X,n,Set(CONNECTEDLINE(all)="POTS-${EXTEN}" <${EXTEN}>)
exten => _25X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,IkKtT)
exten => _25X,n,Hangup()


; Calling Phone 2
;exten => 500,hint,DAHDI/i2/${EXTEN}
exten => 500,hint,DAHDI/i2/500
exten => 500,1,NoOp(Extension ${EXTEN} (bri_cpe))
exten => 500,n,Proceeding()
exten => 500,n,Macro(displayall)
;exten => 500,n,NoOp(TRANSFERCAPABILITY is ${TRANSFERCAPABILITY})
exten => 500,n,Set(CONNECTEDLINE(all)="Phone-2" <8492>)
exten => 500,n,Macro(callit,DAHDI/${DAHDI_PH_2_GROUP}/${EXTEN},30,IkKtT)
exten => 500,n,Hangup()

include => default


; ************************************************************************

[bri_phone_1]
; Section for port connected to phone 1 on port 2
; Calling User-A
;exten => 100,hint,SIP/${EXTEN}
exten => 100,hint,SIP/100(bri-ph-1 hint 100)
exten => 100,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 100,n,Proceeding()
exten => 100,n,Macro(displayall)
exten => 100,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => 100,n,Set(CONNECTEDLINE(all)="PostedMarky" <4321>)
exten => 100,n,Set(CALLCOMPLETION(cc_agent_dialstring)=DAHDI/${DAHDI_PH_1_GROUP}/${CALLERID(num)})
exten => 100,n,Macro(set_interception,bri_phone_1,${EXTEN})
;exten => 100,n,Macro(callit,SIP/${EXTEN},30,IkKtT)
exten => 100,n,Macro(callit,SIP/${EXTEN},30,kKtT)
exten => 100,n,Hangup()

; Calling User-A with subaddress
exten => 101,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 101,n,Proceeding()
exten => 101,n,Macro(displayall)
exten => 101,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => 101,n,Set(CONNECTEDLINE(all,i)="PostedMarky" <4321>)
exten => 101,n,Set(CONNECTEDLINE(subaddr,i)=5847)
exten => 101,n,Set(CONNECTEDLINE(subaddr-valid)=1)
exten => 101,n,Macro(set_interception,bri_phone_1,${EXTEN})
exten => 101,n,Macro(callit,SIP/100,30,IkKtT)
exten => 101,n,Hangup()

; Calling Queue
exten => 120,1,NoOp(Extension ${EXTEN} (bri_phone_1)
exten => 120,n,Proceeding()
exten => 120,n,Macro(displayall)
exten => 120,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => 120,n,Set(CONNECTEDLINE(all)="Phone1Queue" <1543>)
exten => 120,n,Macro(set_interception,bri_phone_1,${EXTEN})
exten => 120,n,Answer()
exten => 120,n,Queue(ast185)

; Calling a recording
exten => 121,1,NoOp(Extension ${EXTEN} (bri_phone_1)
exten => 121,n,Proceeding()
exten => 121,n,Macro(displayall)
exten => 121,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => 121,n,Set(CONNECTEDLINE(all)="FoobarP1" <1543>)
exten => 121,n,Macro(set_interception,bri_phone_1,${EXTEN})
exten => 121,n,Answer()
exten => 121,n,Playback(tt-weasels)
exten => 121,n,Hangup()

; Calling a series of numbers (Forever)
exten => 122,1,NoOp(Extension ${EXTEN} (bri_phone_1)
exten => 122,n,Proceeding()
exten => 122,n,Macro(displayall)
exten => 122,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => 122,n,Set(CONNECTEDLINE(all)="FoobarP1" <1543>)
exten => 122,n,Macro(set_interception,bri_phone_1,${EXTEN})
exten => 122,n,Answer()
exten => 122,n(restart),Set(COUNT=100)
exten => 122,n(loopit),Set(COUNT=$[${COUNT} - 1])
exten => 122,n,SayNumber(${COUNT})
exten => 122,n,GotoIf(${COUNT}?loopit:restart)
exten => 122,n,Hangup()

; Calling Queue with a member
exten => 123,1,NoOp(Extension ${EXTEN} (bri_phone_1)
exten => 123,n,Proceeding()
exten => 123,n,Macro(displayall)
exten => 123,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => 123,n,Set(CONNECTEDLINE(all)="Phone1QueueMember" <1543>)
exten => 123,n,Macro(set_interception,bri_phone_1,${EXTEN})
exten => 123,n,Answer()
exten => 123,n,Queue(ast200,tT)

; Forking a call to User-A and User-B
exten => 124,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 124,n,Proceeding()
exten => 124,n,Macro(displayall)
exten => 124,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => 124,n,Set(CALLCOMPLETION(cc_agent_dialstring)=DAHDI/${DAHDI_PH_1_GROUP}/${CALLERID(num)})
exten => 124,n,Macro(set_interception,bri_phone_1,${EXTEN})
exten => 124,n,Macro(callit,Local/100@bri_phone_1&DAHDI/${DAHDI_NET_GROUP}/200,30,kKtT)
exten => 124,n,Hangup()

; AGI park a call
exten => 125,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 125,n,AGI(/home/rmudgett/projects/lvm/setups/bri_phone/dial_125.pl)
exten => 125,n,Hangup()

; Calling User B or C or Phone 2
exten => _[235]XX,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => _[235]XX,n,Proceeding()
exten => _[235]XX,n,Macro(displayall)
exten => _[235]XX,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => _[235]XX,n,Set(CALLERID(subaddr)=8765)
exten => _[235]XX,n,Set(CALLERID(subaddr-valid)=1)
exten => _[235]XX,n,Set(CALLCOMPLETION(cc_agent_dialstring)=DAHDI/${DAHDI_PH_1_GROUP}/${CALLERID(num)})
exten => _[235]XX,n,Macro(set_interception,bri_phone_1,${EXTEN})
exten => _[235]XX,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/${EXTEN},60,kKtT)
; Test f and o options
;exten => _[235]XX,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/${EXTEN},60,fokKtT)
;exten => _[235]XX,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/${EXTEN},60,f("force" <497>)o("orig" <930>)kKtT)
exten => _[235]XX,n,Hangup()

;; Calling Phone 2 JIRA ABE-2752
;;exten => 500,hint,DAHDI/i2/${EXTEN}
;;exten => 500,hint,DAHDI/i2/500
;exten => 500,1,NoOp(Extension ${EXTEN} (bri_phone_1))
;exten => 500,n,Proceeding()
;;exten => 500,n,Macro(displayall)
;;exten => 500,n,NoOp(TRANSFERCAPABILITY is ${TRANSFERCAPABILITY})
;exten => 500,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
;exten => 500,n,Set(CONNECTEDLINE(all)="Phone-2" <8492>)
;exten => 500,n,Macro(callit,DAHDI/${DAHDI_PH_2_GROUP}/${EXTEN},30,IkKtT)
;exten => 500,n,Hangup()

; BUGBUG for issue 18212 --v
;exten => h,1,NoOp(Extension ${EXTEN} (bri_phone_1))
;exten => h,n,NoOp(DIALSTATUS is ${DIALSTATUS})
;exten => h,n,Set(CDR(WhoHungUp,r)=CALLED)
;;exten => h,n,Hangup
; BUGBUG for issue 18212 --^

; Calling Phone on network side (Not necessarily connected.)
exten => _4XX,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => _4XX,n,Proceeding()
exten => _4XX,n,Macro(displayall)
exten => _4XX,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => _4XX,n,Set(CONNECTEDLINE(all)="Phone-${EXTEN}" <2${EXTEN}>)
exten => _4XX,n,Macro(set_interception,bri_phone_1,${EXTEN})
; BUGBUG for issue 18212 --v
;exten => _4XX,n,Set(CDR(WhoHungUp,r)=caller)
; BUGBUG for issue 18212 --^
exten => _4XX,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/${EXTEN},30,IkKtT)
;exten => _4XX,n,Macro(vmail)
exten => _4XX,n,Hangup()

; Calling with subaddress in setup.
exten => 602,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 602,n,Proceeding()
exten => 602,n,Macro(displayall)
exten => 602,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => 602,n,Set(CALLERID(subaddr)=8765)
exten => 602,n,Set(CALLERID(subaddr-valid)=1)
exten => 602,n,Set(CALLCOMPLETION(cc_agent_dialstring)=DAHDI/${DAHDI_PH_1_GROUP}/${CALLERID(num)})
exten => 602,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/200:1234,60,kKtT)
exten => 602,n,Hangup()

; MeetMe conference plain
exten => 605,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 605,n,Macro(displayall)
exten => 605,n,MeetMe(,sM)

; MeetMe conference normal member
exten => 606,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 606,n,Macro(displayall)
exten => 606,n,MeetMe(,swM)

; MeetMe conference admin member
exten => 607,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 607,n,Macro(displayall)
exten => 607,n,MeetMe(,aAs,123)

; Calling POTS phones
exten => 701,hint,DAHDI/1(bri-ph-1 hint 701)
exten => 702,hint,DAHDI/2(bri-ph-1 hint 702)
exten => 703,hint,DAHDI/3(bri-ph-1 hint 703)
exten => 704,hint,DAHDI/4(bri-ph-1 hint 704)
exten => 705,hint,DAHDI/5(bri-ph-1 hint 705)
exten => 706,hint,DAHDI/6(bri-ph-1 hint 706)
exten => 707,hint,DAHDI/7(bri-ph-1 hint 707)
exten => 708,hint,DAHDI/8(bri-ph-1 hint 708)
exten => _70X,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => _70X,n,Proceeding()
exten => _70X,n,Macro(displayall)
exten => _70X,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => _70X,n,Set(CONNECTEDLINE(all)="POTS-${EXTEN}" <4${EXTEN}>)
exten => _70X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,kKtT)
;exten => _70X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,IkKtT)
exten => _70X,n,Hangup()

;Generic call completion request
exten => 800,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 800,n,Proceeding()
exten => 800,n,CallCompletionRequest
exten => 800,n,NoOp(CC_REQUEST_RESULT is ${CC_REQUEST_RESULT})
exten => 800,n,NoOp(CC_REQUEST_REASON is ${CC_REQUEST_REASON})
exten => 800,n,Hangup()

;Generic call completion cancel
exten => 801,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 801,n,Proceeding()
exten => 801,n,CallCompletionCancel
exten => 801,n,NoOp(CC_CANCEL_RESULT is ${CC_CANCEL_RESULT})
exten => 801,n,NoOp(CC_CANCEL_REASON is ${CC_CANCEL_REASON})
exten => 801,n,Hangup()

; Voicemail retrieval extension
exten => 810,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 810,n,Proceeding()
exten => 810,n,VoiceMailMain(,s)
exten => 810,n,Hangup()

; Voicemail retrieval extension
exten => 811,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 811,n,Proceeding()
exten => 811,n,VoiceMailMain(@other,s)
exten => 811,n,Hangup()

; Voicemail retrieval extension
exten => 812,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => 812,n,Proceeding()
exten => 812,n,VoiceMailMain(@spaz,s)
exten => 812,n,Hangup()

; Calling Far end using overlap dialing
exten => _9!,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => _9!,n,Macro(displayall)
exten => _9!,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
;exten => _9!,n,Answer()
exten => _9!,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/${EXTEN:1},60,kKtT)
exten => _9!,n,Hangup()

; Directed pickup for ISDN phones
exten => *8,1,NoOp(Extension ${EXTEN} (bri_phone_1))
;exten => *8,n,Pickup()
exten => *8,n,Pickup(401)
exten => *8,n,Hangup()

; Calling out SIP trunk
exten => _1XXX,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => _1XXX,n,Macro(displayall)
exten => _1XXX,n,Macro(set_interception,bri_phone_1,${EXTEN})
exten => _1XXX,n,Macro(callit,SIP/${EXTEN}@sip_trk,30,kKtT)
exten => _1XXX,n,Hangup()

; Calling out SIP trunk
exten => _2XXX,1,NoOp(Extension ${EXTEN} (bri_phone_1))
exten => _2XXX,n,Macro(displayall)
exten => _2XXX,n,Macro(set_interception,bri_phone_1,${EXTEN})
exten => _2XXX,n,Macro(callit,SIP/${EXTEN}@sip_trk,30,kKtT)
exten => _2XXX,n,Hangup()

include => parkedcalls
include => default


; ************************************************************************

[bri_phone_2]

; Section for port connected to phone 2 on port 3
; Calling User-A or Phone 1
exten => _[14]XX,1,NoOp(Extension ${EXTEN} (bri_phone_2))
exten => _[14]XX,n,Proceeding()
exten => _[14]XX,n,Macro(displayall)
exten => _[14]XX,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => _[14]XX,n,Set(CALLCOMPLETION(cc_agent_dialstring)=DAHDI/${DAHDI_PH_2_GROUP}/${CALLERID(num)})
exten => _[14]XX,n,Macro(set_interception,bri_phone_2,${EXTEN})
exten => _[14]XX,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/${EXTEN},60,kKtT)
exten => _[14]XX,n,Hangup()

; Calling User B or C
exten => _20X,hint,SIP/200
exten => _20X,1,NoOp(Extension ${EXTEN} (+))
exten => _20X,n,Proceeding()
exten => _20X,n,Macro(displayall)
exten => _20X,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => _20X,n,Set(CONNECTEDLINE(all)="Willy${EXTEN}" <9259>)
exten => _20X,n,Set(CALLCOMPLETION(cc_agent_dialstring)=DAHDI/${DAHDI_PH_2_GROUP}/${CALLERID(num)})
exten => _20X,n,Macro(set_interception,bri_phone_2,${EXTEN})
;exten => _20X,n,Macro(callit,SIP/${EXTEN},30,IkKtT)
exten => _20X,n,Macro(callit,SIP/${EXTEN},30,kKtT)
exten => _20X,n,Hangup()

; Calling Queue
exten => 220,1,NoOp(Extension ${EXTEN} (bri_phone_2))
exten => 220,n,Proceeding()
exten => 220,n,Macro(displayall)
exten => 220,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => 220,n,Set(CONNECTEDLINE(all)="Phone2Queue" <7543>)
exten => 220,n,Answer()
exten => 220,n,Queue(ast185)

; MeetMe conference plain
exten => 605,1,NoOp(Extension ${EXTEN} (bri_phone_2))
exten => 605,n,Macro(displayall)
exten => 605,n,MeetMe(,sM)

; MeetMe conference normal member
exten => 606,1,NoOp(Extension ${EXTEN} (bri_phone_2))
exten => 606,n,Macro(displayall)
exten => 606,n,MeetMe(,swM)

; MeetMe conference admin member
exten => 607,1,NoOp(Extension ${EXTEN} (bri_phone_2))
exten => 607,n,Macro(displayall)
exten => 607,n,MeetMe(,aAs,123)

; Calling POTS phones
exten => 701,hint,DAHDI/1(bri-ph-2 hint 701)
exten => 702,hint,DAHDI/2(bri-ph-2 hint 702)
exten => 703,hint,DAHDI/3(bri-ph-2 hint 703)
exten => 704,hint,DAHDI/4(bri-ph-2 hint 704)
exten => 705,hint,DAHDI/5(bri-ph-2 hint 705)
exten => 706,hint,DAHDI/6(bri-ph-2 hint 706)
exten => 707,hint,DAHDI/7(bri-ph-2 hint 707)
exten => 708,hint,DAHDI/8(bri-ph-2 hint 708)
exten => _70X,1,NoOp(Extension ${EXTEN} (bri_phone_2))
exten => _70X,n,Proceeding()
exten => _70X,n,Macro(displayall)
exten => _70X,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => _70X,n,Set(CONNECTEDLINE(all)="POTS-${EXTEN}" <4${EXTEN}>)
exten => _70X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,kKtT)
exten => _70X,n,Hangup()

;Generic call completion request
exten => 800,1,NoOp(Extension ${EXTEN} (bri_phone_2))
exten => 800,n,Proceeding()
exten => 800,n,CallCompletionRequest
exten => 800,n,NoOp(CC_REQUEST_RESULT is ${CC_REQUEST_RESULT})
exten => 800,n,NoOp(CC_REQUEST_REASON is ${CC_REQUEST_REASON})
exten => 800,n,Hangup

;Generic call completion cancel
exten => 801,1,NoOp(Extension ${EXTEN} (bri_phone_2))
exten => 801,n,Proceeding()
exten => 801,n,CallCompletionCancel
exten => 801,n,NoOp(CC_CANCEL_RESULT is ${CC_CANCEL_RESULT})
exten => 801,n,NoOp(CC_CANCEL_REASON is ${CC_CANCEL_REASON})
exten => 801,n,Hangup

; Calling Far end using overlap dialing (Mantis issue 18509)
exten => _9!,1,NoOp(Extension ${EXTEN} (bri_phone_2))
exten => _9!,n,Macro(displayall)
exten => _9!,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
exten => _9!,n,SendText(Burp-up outside line)
;exten => _9!,n,Answer()
;exten => _9!,n,SendText(Answered outside line)
exten => _9!,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/${EXTEN:1},60,kKtT)
;exten => _9!,n,Hangup()

;; Calling Far end using overlap dialing (Mantis issue 18509)
;exten => _99!,1,NoOp(Extension ${EXTEN} (bri_phone_2))
;exten => _99!,n,Macro(displayall)
;exten => _99!,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
;;exten => _99!,n,Answer()
;exten => _99!,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/${EXTEN:2},60,kKtT)
;;exten => _99!,n,Hangup()

;; Calling Far end using overlap dialing (Mantis issue 18509)
;;ignorepat => 9
;exten => _9.,1,NoOp(Extension ${EXTEN} (bri_phone_2))
;exten => _9.,n,Macro(displayall)
;exten => _9.,n,Set(CALLERID(name)=ETSI-${CALLERID(num)})
;;exten => _9.,n,Answer()
;exten => _9.,n,Macro(callit,DAHDI/${DAHDI_CPE_GROUP}/${EXTEN:1},60,kKtT)
;exten => _9.,n,Hangup()

; Calling out SIP trunk
exten => _1XXX,1,NoOp(Extension ${EXTEN} (bri_phone_2))
exten => _1XXX,n,Macro(displayall)
exten => _1XXX,n,Macro(set_interception,bri_phone_2,${EXTEN})
exten => _1XXX,n,Macro(callit,SIP/${EXTEN}@sip_trk,30,kKtT)
exten => _1XXX,n,Hangup()

; Calling out SIP trunk
exten => _2XXX,1,NoOp(Extension ${EXTEN} (bri_phone_2))
exten => _2XXX,n,Macro(displayall)
exten => _2XXX,n,Macro(set_interception,bri_phone_2,${EXTEN})
exten => _2XXX,n,Macro(callit,SIP/${EXTEN}@sip_trk,30,kKtT)
exten => _2XXX,n,Hangup()

include => parkedcalls
include => default


; ************************************************************************

[pots]

; Calling User-A
exten => 100,1,NoOp(Extension ${EXTEN} (pots))
exten => 100,n,Macro(displayall)
exten => 100,n,Macro(set_interception,pots,${EXTEN})
exten => 100,n,Set(CONNECTEDLINE(all)="PostedMarky" <4321>)
;exten => 100,n,Set(FRAME_TRACE(white)=CONTROL)
exten => 100,n,Macro(callit,SIP/${EXTEN},30,IkKtT)
exten => 100,n,Hangup()

; Calling Queue
exten => 120,1,NoOp(Extension ${EXTEN} (pots)
exten => 120,n,Macro(displayall)
exten => 120,n,Macro(set_interception,pots,${EXTEN})
exten => 120,n,Answer()
exten => 120,n,Queue(ast185)

; Calling a recording
exten => 121,1,NoOp(Extension ${EXTEN} (pots)
exten => 121,n,Macro(displayall)
exten => 121,n,Macro(set_interception,pots,${EXTEN})
exten => 121,n,Answer()
exten => 121,n,Playback(tt-weasels)
exten => 121,n,Hangup()

; Calling a series of numbers (Forever)
exten => 122,1,NoOp(Extension ${EXTEN} (pots)
exten => 122,n,Macro(displayall)
exten => 122,n,Macro(set_interception,pots,${EXTEN})
exten => 122,n,Answer()
exten => 122,n(restart),Set(COUNT=100)
exten => 122,n(loopit),Set(COUNT=$[${COUNT} - 1])
exten => 122,n,SayNumber(${COUNT})
exten => 122,n,GotoIf(${COUNT}?loopit:restart)
exten => 122,n,Hangup()

; Calling Queue with a member
exten => 123,1,NoOp(Extension ${EXTEN} (pots)
exten => 123,n,Macro(displayall)
exten => 123,n,Macro(set_interception,pots,${EXTEN})
exten => 123,n,Set(CONNECTEDLINE(all)="Q-tip Company" <54321>)
exten => 123,n,Answer()
exten => 123,n,Queue(ast200,tT)

; JIRA ASTERISK-17658
exten => h,1,NoOp(Extension ${EXTEN} (pots))
;exten => h,1,Goto(9999,1)
;exten => h,n,Goto(9999,1)
exten => h,n,Goto(local_ctx,9999,1)
exten => h,n,Hangup

exten => 9999,1,NoOp(Goto target (pots))
exten => 9999,n,Hangup
; JIRA ASTERISK-17658

; Calling User-B directly
exten => 200,1,NoOp(Extension ${EXTEN} (pots))
exten => 200,n,Macro(displayall)
exten => 200,n,Macro(set_interception,pots,${EXTEN})
exten => 200,n,Set(CONNECTEDLINE(all)="Willy${EXTEN}" <9259>)
;exten => 200,n,Set(FRAME_TRACE(white)=CONTROL)
exten => 200,n,Macro(callit,SIP/${EXTEN},30,IkKtT)
exten => 200,n,Hangup()

; Calling a series of numbers (Forever)
exten => 222,1,NoOp(Extension ${EXTEN} (pots)
exten => 222,n,Macro(displayall)
exten => 222,n,Set(CONNECTEDLINE(all)="FoobarB" <3527>)
exten => 222,n,Answer()
exten => 222,n(restart),Set(COUNT=100)
exten => 222,n(loopit),Set(COUNT=$[${COUNT} - 1])
exten => 222,n,SayNumber(${COUNT})
exten => 222,n,GotoIf(${COUNT}?loopit:restart)
exten => 222,n,Hangup()

; Calling User B or C over ISDN link
exten => _[23]XX,1,NoOp(Extension ${EXTEN} (pots))
exten => _[23]XX,n,Macro(displayall)
exten => _[23]XX,n,Macro(set_interception,pots,${EXTEN})
;exten => _[23]XX,n,Set(CALLCOMPLETION(cc_agent_dialstring)=DAHDI/${CALLERID(num):-1:1})
exten => _[23]XX,n,Macro(callit,DAHDI/${DAHDI_NET_GROUP}/${EXTEN},60,kKtT)
exten => _[23]XX,n,Hangup()

;Calling Phone 1
exten => _4XX,1,NoOp(Extension ${EXTEN} (pots))
exten => _4XX,n,Macro(displayall)
exten => _4XX,n,Macro(set_interception,pots,${EXTEN})
exten => _4XX,n,Set(CONNECTEDLINE(all)="Phone-${EXTEN}" <4${EXTEN}>)
exten => _4XX,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/${EXTEN},30,IkKtT)
exten => _4XX,n,Hangup()

;Calling Phone 2
exten => _5XX,1,NoOp(Extension ${EXTEN} (pots))
exten => _5XX,n,Macro(displayall)
exten => _5XX,n,Macro(set_interception,pots,${EXTEN})
exten => _5XX,n,Set(CONNECTEDLINE(all)="Phone-${EXTEN}" <4${EXTEN}>)
exten => _5XX,n,Macro(callit,DAHDI/${DAHDI_PH_2_GROUP}/${EXTEN},30,IkKtT)
exten => _5XX,n,Hangup()

; MeetMe conference plain
exten => 605,1,NoOp(Extension ${EXTEN} (pots))
exten => 605,n,Macro(displayall)
exten => 605,n,MeetMe(,sM)

; MeetMe conference normal member
exten => 606,1,NoOp(Extension ${EXTEN} (pots))
exten => 606,n,Macro(displayall)
exten => 606,n,MeetMe(,swM)

; MeetMe conference admin member
exten => 607,1,NoOp(Extension ${EXTEN} (pots))
exten => 607,n,Macro(displayall)
exten => 607,n,MeetMe(,aAs,123)

;Calling Phone 1 with deferred DTMF digits
exten => 608,1,NoOp(Extension ${EXTEN} (pots))
exten => 608,n,Macro(displayall)
exten => 608,n,Macro(set_interception,pots,${EXTEN})
exten => 608,n,Set(CONNECTEDLINE(all)="Phone-${EXTEN}" <4${EXTEN}>)
exten => 608,n,Macro(callit,DAHDI/${DAHDI_PH_1_GROUP}/400ww1234,30,IkKtT)
exten => 608,n,Hangup()

; Calling POTS phones
exten => 701,hint,DAHDI/1(pots hint 701)
exten => 702,hint,DAHDI/2(pots hint 702)
exten => 703,hint,DAHDI/3(pots hint 703)
exten => 704,hint,DAHDI/4(pots hint 704)
exten => 705,hint,DAHDI/5(pots hint 705)
exten => 706,hint,DAHDI/6(pots hint 706)
exten => 707,hint,DAHDI/7(pots hint 707)
exten => 708,hint,DAHDI/8(pots hint 708)
exten => _70X,1,NoOp(Extension ${EXTEN} (pots))
exten => _70X,n,Macro(displayall)
exten => _70X,n,Macro(set_interception,pots,${EXTEN})
exten => _70X,n,Set(CONNECTEDLINE(all)="POTS-${EXTEN}" <4${EXTEN}>)
;exten => _70X,n,Set(CALLCOMPLETION(cc_agent_dialstring)=DAHDI/${CALLERID(num):-1:1})
;exten => _70X,n,Set(FRAME_TRACE(white)=CONTROL,DTMF_BEGIN,DTMF_END)
;exten => _70X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,kKtT)
;BUGBUG ASTERISK-15792 test of transfer to parking continuing in dialplan
;exten => _70X,n,Set(_GOTO_ON_BLINDXFR=pots^777^1)
exten => _70X,n,Dial(DAHDI/${EXTEN:-1:1},60,kKtT)
exten => _70X,n,Playback(tt-weasels)
;BUGBUG ASTERISK-15792 test of transfer to parking continuing in dialplan
exten => _70X,n,Hangup()

;BUGBUG ASTERISK-19342 Parking hint initial state
;exten => 751,hint,park:751@parkedcalls
;exten => 751,hint,park:751@parkinglot
;exten => 751,hint,park:751@pots
;exten => 751,1,NoOp
;BUGBUG ASTERISK-19342 Parking hint initial state

;BUGBUG ASTERISK-15792 test of transfer to parking continuing in dialplan
exten => 777,1,Playback(tt-somethingwrong)
;BUGBUG ASTERISK-15792 test of transfer to parking continuing in dialplan

;BUGBUG ASTERISK-18557 test of automatically generated parking hints
exten => 778,1,NoOp(Determine extension states of hints)
exten => 778,n,NoOp(DEVICE_STATE(park:751@pots)=${DEVICE_STATE(park:751@pots)})
exten => 778,n,NoOp(DEVICE_STATE(park:751@parkedcalls)=${DEVICE_STATE(park:751@parkedcalls)})
exten => 778,n,NoOp(EXTENSION_STATE(park:751@pots)=${EXTENSION_STATE(park:751@pots)})
exten => 778,n,NoOp(EXTENSION_STATE(park:751@parkedcalls)=${EXTENSION_STATE(park:751@parkedcalls)})
exten => 778,n,NoOp(EXTENSION_STATE(751@pots)=${EXTENSION_STATE(751@pots)})
exten => 778,n,NoOp(EXTENSION_STATE(751@parkedcalls)=${EXTENSION_STATE(751@parkedcalls)})
;BUGBUG ASTERISK-18557 test of automatically generated parking hints

; Calling POTS phones via local (one level)
exten => _71X,1,NoOp(Extension ${EXTEN} (pots))
exten => _71X,n,Macro(displayall)
exten => _71X,n,Macro(set_interception,pots,${EXTEN})
exten => _71X,n,Set(CONNECTEDLINE(all)="POTS-${EXTEN}" <4${EXTEN}>)
;exten => _71X,n,Set(CALLCOMPLETION(cc_agent_dialstring)=DAHDI/${CALLERID(num):-1:1})
;exten => _71X,n,Set(FRAME_TRACE(white)=CONTROL,DTMF_BEGIN,DTMF_END)
exten => _71X,n,Macro(callit,Local/${EXTEN}@local_ctx,60,kKtT)
exten => _71X,n,Hangup()

; Calling POTS phones via local (two levels)
exten => _72X,1,NoOp(Extension ${EXTEN} (pots))
exten => _72X,n,Macro(displayall)
exten => _72X,n,Macro(set_interception,pots,${EXTEN})
exten => _72X,n,Set(CONNECTEDLINE(all)="POTS-${EXTEN}" <4${EXTEN}>)
;exten => _72X,n,Set(CALLCOMPLETION(cc_agent_dialstring)=DAHDI/${CALLERID(num):-1:1})
;exten => _72X,n,Set(FRAME_TRACE(white)=CONTROL,DTMF_BEGIN,DTMF_END)
exten => _72X,n,Macro(callit,Local/${EXTEN}@local_ctx,60,kKtT)
exten => _72X,n,Hangup()

; Calling POTS phones via local (split two levels)
exten => 731,1,NoOp(Extension ${EXTEN} (pots))
exten => 731,n,Macro(displayall)
exten => 731,n,Macro(set_interception,pots,${EXTEN})
exten => 731,n,Set(CONNECTEDLINE(all)="POTS-${EXTEN}" <4${EXTEN}>)
;exten => 731,n,Set(CALLCOMPLETION(cc_agent_dialstring)=DAHDI/${CALLERID(num):-1:1})
;exten => 731,n,Set(FRAME_TRACE(white)=CONTROL,DTMF_BEGIN,DTMF_END)
exten => 731,n,Macro(callit,Local/721@local_ctx&Local/722@local_ctx,60,kKtT)
exten => 731,n,Hangup()

; Calling POTS phones via local (split two levels)
exten => 732,1,NoOp(Extension ${EXTEN} (pots))
exten => 732,n,Macro(displayall)
exten => 732,n,Macro(set_interception,pots,${EXTEN})
exten => 732,n,Set(CONNECTEDLINE(all)="POTS-${EXTEN}" <4${EXTEN}>)
;exten => 732,n,Set(CALLCOMPLETION(cc_agent_dialstring)=DAHDI/${CALLERID(num):-1:1})
;exten => 732,n,Set(FRAME_TRACE(white)=CONTROL,DTMF_BEGIN,DTMF_END)
; NOTE CCSS builds the CC_INTERFACES listing local channels first before real channels.
exten => 732,n,Macro(callit,DAHDI/2&Local/721@local_ctx,60,kKtT)
exten => 732,n,Hangup()

;Generic call completion request
exten => 800,1,NoOp(Extension ${EXTEN} (pots))
exten => 800,n,CallCompletionRequest
exten => 800,n,NoOp(CC_REQUEST_RESULT is ${CC_REQUEST_RESULT})
exten => 800,n,NoOp(CC_REQUEST_REASON is ${CC_REQUEST_REASON})
exten => 800,n,Hangup

;Generic call completion cancel
exten => 801,1,NoOp(Extension ${EXTEN} (pots))
exten => 801,n,CallCompletionCancel
exten => 801,n,NoOp(CC_CANCEL_RESULT is ${CC_CANCEL_RESULT})
exten => 801,n,NoOp(CC_CANCEL_REASON is ${CC_CANCEL_REASON})
exten => 801,n,Hangup

; BUGBUG ASTERISK-18222 Call pickup race
exten => 802,1,NoOp(Extension ${EXTEN} (pots))
exten => 802,n,Dial(Local/701@en-phone&Local/702@en-phone)
; BUGBUG ASTERISK-18222

; Directed pickup for analog phones
exten => *8,1,NoOp(Extension ${EXTEN} (pots))
exten => *8,n,Pickup()
exten => *8,n,Hangup()

include => parkedcalls
include => default

; Brazil DTMF issue part of dialplan
;exten => A351239985253C,1,NoOp(Brazil DTMF issue brazil-combined)
;exten => A351239985253C,n,Playback(tt-weasels)
;exten => A351239985253C,n,Hangup()
;
;exten => A00351239985253C,1,NoOp(Brazil DTMF issue brazil-combined-round2)
;exten => A00351239985253C,n,Playback(tt-weasels)
;exten => A00351239985253C,n,Hangup()
;
;exten => 997,1,NoOp(Brazil call file operation)
;exten => 997,n,Playback(/home/rmudgett/projects/open/brazil/recordings/brasil-combined-round2-cid-only)
;;exten => 997,n,Playback(/home/rmudgett/projects/open/brazil/recordings/brasil-combined-round2)
;;exten => 997,n,Playback(/home/rmudgett/projects/open/brazil/recordings/brasil-combined)
;exten => 997,n,SendDTMF(#)
;exten => 997,n,Wait(4)
;exten => 997,n,Hangup()
;
;exten => 998,1,NoOp(Brazil call file operation)
;;exten => 998,n,Playback(/home/rmudgett/projects/open/brazil/recordings/brasil-combined-round2-cid-only)
;exten => 998,n,Playback(/home/rmudgett/projects/open/brazil/recordings/brasil-combined-round2)
;;exten => 998,n,Playback(/home/rmudgett/projects/open/brazil/recordings/brasil-combined)
;exten => 998,n,SendDTMF(#)
;exten => 998,n,Wait(1)
;exten => 998,n,Hangup()
;
;exten => 999,1,NoOp(Brazil call file operation)
;;exten => 999,n,Playback(/home/rmudgett/projects/open/brazil/recordings/brasil-combined-round2-cid-only)
;;exten => 999,n,Playback(/home/rmudgett/projects/open/brazil/recordings/brasil-combined-round2)
;exten => 999,n,Playback(/home/rmudgett/projects/open/brazil/recordings/brasil-combined)
;exten => 999,n,SendDTMF(#)
;exten => 999,n,Wait(1)
;exten => 999,n,Hangup()
;
;exten => s,1,NoOp(Special unrouted call handler)
;exten => s,n,Macro(displayall)
;exten => s,n,Answer()
;;exten => s,n,Set(CALLERID(all)="" <>)
;;exten => s,n,PrivacyManager()
;exten => s,n,Read(CID,,,,,120)
;exten => s,n,NoOp(READSTATUS is ${READSTATUS})
;exten => s,n,NoOp(CID is ${CID})
;;exten => s,n,Wait(120)
;;exten => s,n,Playback(tt-weasels)
;exten => s,n,Hangup()


; ************************************************************************

[queue_digit_escape]

exten => _[1234567890],1,NoOp(Single digit ast200 queue escape)
exten => _[1234567890],n,SayNumber(${EXTEN})
exten => _[1234567890],n,Wait(1)
exten => _[1234567890],n,Hangup()

include => default



; ************************************************************************

[local_ctx]

; Calling User-A
exten => 100,1,NoOp(Extension ${EXTEN} (local_ctx))
exten => 100,n,Macro(displayall)
exten => 100,n,Macro(set_interception,local_ctx,${EXTEN})
exten => 100,n,Set(CONNECTEDLINE(all)="PostedMarky" <4321>)
;exten => 100,n,Set(FRAME_TRACE(white)=CONTROL)
exten => 100,n,Macro(callit,SIP/${EXTEN},30,IkKtT)
exten => 100,n,Hangup()

; Calling POTS phones
exten => _71X,1,NoOp(Extension ${EXTEN} (local_ctx))
exten => _71X,n,Macro(displayall)
exten => _71X,n,Macro(set_interception,local_ctx,${EXTEN})
exten => _71X,n,Set(CONNECTEDLINE(all)="Local-${EXTEN}" <4${EXTEN}>)
;exten => _71X,n,Set(FRAME_TRACE(white)=CONTROL,DTMF_BEGIN,DTMF_END)
exten => _71X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,kKtT)
exten => _71X,n,Hangup()

; Calling POTS phones
exten => _72X,1,NoOp(Extension ${EXTEN} (local_ctx))
exten => _72X,n,Macro(displayall)
exten => _72X,n,Macro(set_interception,local_ctx,${EXTEN})
exten => _72X,n,Set(CONNECTEDLINE(all)="Local-${EXTEN}" <4${EXTEN}>)
;exten => _72X,n,Set(FRAME_TRACE(white)=CONTROL,DTMF_BEGIN,DTMF_END)
exten => _72X,n,Macro(callit,Local/71${EXTEN:-1:1}@local_ctx,60,kKtT)
exten => _72X,n,Hangup()

; Instant message to Polycom phone SIP/200
exten => IM,1,NoOp(Extension ${EXTEN} (local_ctx))
exten => IM,n,Set(MESSAGE(body)=Local-${EXTEN})
;exten => IM,n,MessageSend(sip:200@10.24.20.236)
exten => IM,n,MessageSend(sip:200)
exten => IM,n,NoOp(MESSAGE_SEND_STATUS is ${MESSAGE_SEND_STATUS})
exten => IM,n,Hangup()

; JIRA ASTERISK-17658
exten => h,1,NoOp(Extension ${EXTEN} (local_ctx))
;exten => h,1,Goto(9999,1)
;exten => h,n,Goto(9999,1)
exten => h,n,Goto(pots,9999,1)
exten => h,n,Hangup

exten => 9999,1,NoOp(Goto target (local_ctx))
exten => 9999,n,Hangup
; JIRA ASTERISK-17658

include => default

; BUGBUG ASTERISK-18222 Call pickup race
[en-pickup]
exten => _70X,1,NoOp(Extension ${EXTEN} (en-pickup))
exten => _70X,n,PickupChan(Local/${EXTEN}@en-phone)

[en-phone]
exten => _70X,1,NoOp(Extension ${EXTEN} (en-phone))
exten => _70X,n,Macro(callit,DAHDI/${EXTEN:-1:1},60,kKtT)
; BUGBUG ASTERISK-18222
