[macro-realstexten]
exten = s,1,Set(CHECKCALLERNUM=${IF(${LEN(${CHECKCALLERNUM})>0}?${CHECKCALLERNUM}:${CALLERID(num)})})
exten = s,2,Set(CHECKREALCALLERNUM=${IF(${LEN(${REALCALLERNUM})>0}?${REALCALLERNUM}:${CALLERID(num)})})
exten = s,3,Set(TIMEOUT(absolute)=${ABSOLUTE_TIMEOUT})
exten = s,4,Gotoif(${LEN(${IsSystemFunc})}>0?6:5)
exten = s,5,YsWalkContext(whitelist-internal,${PBXDIALNUM},1,${CHECKREALCALLERNUM},internal)
exten = s,6,Set(CALLERID(num)=${CHECKCALLERNUM})
exten = s,n,Gotoif($["${CALLERID(num)}" = "Conference"]?conf,1)
exten = s,n,Gotoif(${DB(CFA/${ARG1})}>0?follow-me-always,1)
exten = s,n,Gotoif(${DB(DND/${ARG1})}>0?dnd,1)
exten = s,n,NoOp(NO CLIP)
exten = s,n,set(CDR(extfield4)=${PJSIPGETIP()})
exten = s,n,ExecIf($[${CALLERID(num)} = 3009]?Set(_CUSHEADER=b(custom-header^add_internal_info^1))) 
exten = s,n,Gotoif($["${EXTENSION_STATE(${ARG1})}" = "INUSE"]?send-notify:judge-fork)
exten = s,n(send-notify),SEND_STATUS_NOTIFY() 
exten = s,n(judge-fork),Gotoif(${SIPFORKING}?forking:dial)
exten = s,n(forking),Set(GROUP()=${ARG1})
exten = s,n,Set(GROUP(caller)=${SRCEXTENSION})
exten = s,n,Gotoif($[${GROUP_COUNT()}>1]?s-BUSY,1)
exten = s,n(dial),Dial(${ARG2},${RINGTIME_${PBXDIALNUM}},${ARG3}b(local_add_diversion,add_diversion,1(${SRCTRUNKNAME},${PBXDIALNUM},${CALLERID(num)}))${CUSHEADER}${RINGTONE}${MEETMEING},,${RINGINGPRIORITY_${PBXDIALNUM}})
exten = s,n,Gotoif(${LEN(${CONFER_INVITER})}>1?1-out,1)
exten = s,n,Goto(s-${DIALSTATUS},1)
exten = s-CHANUNAVAIL,1,Goto(s-NOANSWER,1)
exten = s-ANSWER,1,Hangup()
exten = s-NOANSWER,1,Gotoif(${DB(CFN/${PBXDIALNUM})}>0?follow-me-noanswer,1:2-out,1)
exten = s-BUSY,1,Gotoif($[${APIDIALSTATUS}==BUSY]?h,1)
exten = s-BUSY,2,Gotoif(${DB(CFB/${PBXDIALNUM})}>0?follow-me-busy,1:1-out,1)
exten = dnd,1,UserEvent(CallFailed,Cause: DND)
exten = dnd,2,Goto(vm-u,1)
exten = follow-me-always,1,Gotoif(${SIPFORKING}?2:3)
exten = follow-me-always,2,Set(GROUP()="")
exten = follow-me-always,3,Gotoif(${DB(ACFD/${PBXDIALNUM})}>0?vm-u,1)
exten = follow-me-always,4,Set(CFNUM=${DB(CFANUM/${PBXDIALNUM})})
exten = follow-me-always,5,Gotoif($[${LEN(${CFNUM})}<1]?vm-u,1))
exten = follow-me-always,6,Gotoif($["${CFNUM}" = "${PBXDIALNUM}"]?vm-u,1)
exten = follow-me-always,7,Set(IsFollowme=${IF($[${IsFromOutside} = 1]?1:0)})
exten = follow-me-always,8,Set(_NOCHANGEDOD=${IF($[${IsFromOutside} = 1]?${NOPBXDIALNUM}:0)})
exten = follow-me-always,n,Set(_DIVNUM=${PBXDIALNUM})
exten = follow-me-always,n,Followme(${PBXDIALNUM}-a,n)
exten = follow-me-always,n,Hangup()
exten = follow-me-noanswer,1,Gotoif(${SIPFORKING}?2:3)
exten = follow-me-noanswer,2,Set(GROUP()="")
exten = follow-me-noanswer,3,Gotoif(${DB(NCFD/${PBXDIALNUM})}>0?vm-u,1)
exten = follow-me-noanswer,4,Set(CFNUM=${DB(CFNNUM/${PBXDIALNUM})})
exten = follow-me-noanswer,5,Gotoif($[${LEN(${CFNUM})}<1]?vm-u,1))
exten = follow-me-noanswer,6,Gotoif($["${CFNUM}" = "${PBXDIALNUM}"]?vm-u,1)
exten = follow-me-noanswer,7,Set(IsFollowme=${IF($[${IsFromOutside} = 1]?1:0)})
exten = follow-me-noanswer,8,Set(_NOCHANGEDOD=${IF($[${IsFromOutside} = 1]?${NOPBXDIALNUM}:0)})
exten = follow-me-noanswer,n,Set(_DIVNUM=${PBXDIALNUM})
exten = follow-me-noanswer,n,Followme(${PBXDIALNUM}-n,n)
exten = follow-me-noanswer,n,Hangup()
exten = follow-me-busy,1,Gotoif(${SIPFORKING}?2:3)
exten = follow-me-busy,2,Set(GROUP()="")
exten = follow-me-busy,3,Gotoif(${DB(BCFD/${PBXDIALNUM})}>0?vm-b,1)
exten = follow-me-busy,4,Set(CFNUM=${DB(CFBNUM/${PBXDIALNUM})})
exten = follow-me-busy,5,Gotoif($[${LEN(${CFNUM})}<1]?vm-b,1)
exten = follow-me-busy,6,Gotoif($["${CFNUM}" = "${PBXDIALNUM}"]?vm-b,1)
exten = follow-me-busy,7,Set(IsFollowme=${IF($[${IsFromOutside} = 1]?1:0)})
exten = follow-me-busy,8,Set(_NOCHANGEDOD=${IF($[${IsFromOutside} = 1]?${NOPBXDIALNUM}:0)})
exten = follow-me-busy,n,Set(_DIVNUM=${PBXDIALNUM})
exten = follow-me-busy,n,Followme(${PBXDIALNUM}-b,n)
exten = follow-me-busy,n,Hangup()
exten = vm-u,1,Gotoif(${LEN(${MEETMEING})}>1?vm-u,2:vm-u,3)
exten = vm-u,2,ChannelRedirect(${CHANNEL(name)},conferences_invite,${CONFERENCENO},1)
exten = vm-u,3,Gotoif($[${PRESS5TOLEVMSG_ENABLE} = 1]?vm-u,4:vm-unavail,1)
exten = vm-u,n,Read(digito,,1,,,7)
exten = vm-u,n,Gotoif($[${digito}=5]?vm-s,1)
exten = vm-u,n,Hangup()
exten = vm-b,1,Gotoif($[${PRESS5TOLEVMSG_ENABLE} = 1]?vm-b,2:vm-busy,1)
exten = vm-b,n,Read(digito,,1,,,7)
exten = vm-b,n,Gotoif($[${digito}=5]?vm-s,1)
exten = vm-b,n,Hangup()
exten = vm-unavail,1,Voicemail(${PBXDIALNUM},u)
exten = vm-unavail,n,Hangup()
exten = vm-busy,1,Voicemail(${PBXDIALNUM},b)
exten = vm-busy,n,Hangup()
exten = vm-s,1,Voicemail(${PBXDIALNUM},)
exten = vm-s,n,Hangup()
exten = 1-out,1,Gotoif(${LEN(${MEETMEING})}>1?1-out,2:1-out,3)
exten = 1-out,2,ChannelRedirect(${CHANNEL(name)},conferences_invite,${CONFERENCENO},1)
exten = 1-out,3,Hangup()
exten = 2-out,1,Hangup(NO_ANSWER)
exten = conf,1,Gotoif(${DB(CFA/${ARG1})}>0?7:2)
exten = conf,2,Gotoif($[${AutoAnswer}=1]?5:3)
exten = conf,3,Dial(${ARG2},${RINGTIME_${PBXDIALNUM}},${ARG3}${RINGTONE}b(conf-pjsip-addheader,add_header,1(${AutoAnswer},${CONFID},${MEMBERINFO},${CONFINFO})),,${RINGINGPRIORITY_${PBXDIALNUM}})
exten = conf,4,Hangup()
exten = conf,5,Set(ringstrategy=2)
exten = conf,6,Dial(${ARG2},${RINGTIME_${PBXDIALNUM}},${ARG3}${RINGTONE}b(conf-pjsip-addheader,add_header,1(${AutoAnswer},${CONFID},${MEMBERINFO},${CONFINFO})),,${ringstrategy})
exten = conf,7,Hangup()

[ringgroup_6200]
exten = 6200,1,NoOp(6200)
exten = 6200,n,Set(YSGROUPEXTEN=6200)
exten = 6200,n,Set(CDR(orgdst)=6200)
exten = 6200,n,Set(_RINGGROUPS=yes)
exten = 6200,n,Wait(1)
exten = 6200,n,Set(CDR(ringtype)=ringall)
exten = 6200,n,Set(_CUSHEADER=b(custom-header^add_ringgroup_info^1))
exten = 6200,n,Set(RINGTYPE=ringall)
exten = 6200,n,Dial(${DIALPARAM_OF_EXTEN3007}&${DIALPARAM_OF_EXTEN3008},60,TtKkXx${RINGTONE}${CUSHEADER})
exten = 6200,n,Goto(always-Hangup,h,1)
exten = fax,1,Goto(inrouter_${INROUTERNAME}_fax_detect,fax,1)
exten = _.,1,Goto(from-outside,${EXTEN},1)


[custom-header]
exten = add_internal_info, 1, Set(PJSIP_HEADER(add,Alert-Info)=<http://192.168.9.198>\;info=test)
exten = add_ringgroup_info, 1, Set(PJSIP_HEADER(add,Alert-Info)=<http://192.168.9.198>\;info=test)
