[subDialTrunk] ;============================================================================== ; subRoutine that dial out a call through a Trunk. ; * Query the AstDB for this trunk. ; * Check if this trunk is enabled. ; * Check if the trunk is full. ; * Dial it! ; ; $ARG1: Number to dial out. ; $ARG2: Trunk selected. ; $RESULT: enabled:maxchans:dialstring ;============================================================================== exten => _X.,1,Set(RESULT=${DB(trunk/${ARG1})}) same => n,Set(ENABLED=${CUT(RESULT,:,1)}) same => n,GotoIf( $[!${ENABLED}]?disabled) same => n,Set(MAXCHAN=${CUT(RESULT,:,2)}) same => n,Set(GROUP(out)=${ARG1}) same => n,Set(GCOUNT=${GROUP_MATCH_COUNT(${ARG1})}) same => n,Set(CDR(groupcount)=${GCOUNT}) same => n,GotoIf( $[${GCOUNT}>${MAXCHAN}]?full) same => n,Set(DIALSTR=${CUT(RESULT,:,3)}) same => n,Set(__TRANSFER_CONTEXT=ext-attxfer) same => n,Dial(${DIALSTR}/${EXTEN},300,Tb(hTrunkHangup^set_handler^1)) same => n,Return(${DIALSTATUS}) same => n(disabled),Verbose(1,Trunk ${ARG1} is disabled.) same => n,Return(DISABLED) same => n(full),Verbose(1,Trunk ${ARG1} is full.) same => n,Return(FULL) exten => h,1,GotoIf($["${RTPAUDIOQOSBRIDGED}"=""]?finish) same => n,Set(CDR(rtpqos)=${RTPAUDIOQOSBRIDGED}) same => n(finish),NoOp(finish)