Changeset 1603

Show
Ignore:
Timestamp:
04/15/06 11:03:04 (7 years ago)
Author:
mheydon1973
Message:

ENum macro is now multi-network. Also general tidy up of logic in said macro

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/amp_conf/astetc/extensions.conf

    r1561 r1603  
    274274exten => s,n,Set(DIAL_TRUNK=${ARG1}) 
    275275exten => s,n,AGI(fixlocalprefix)  ; this sets DIAL_NUMBER to the proper dial string for this trunk 
    276 exten => s,n,GotoIf($["${DIAL_NUMBER:0:1}" = "+"]?hasplus) ; Skip next line if it already is prefixed by a plus 
     276exten => s,n,Set(E164NETWORKS=e164.arpa-e164.info-e164.org) ; enum networks to check 
     277exten => s,n,GotoIf($["${DIAL_NUMBER:0:1}" = "+"]?begin) ; Skip next line if it already is prefixed by a plus 
    277278exten => s,n,Set(DIAL_NUMBER=+${DIAL_NUMBER}) ; Add a plus to the start, becasue ENUMLOOKUP needs it. 
    278 ; OK, this is now quite complex. To remain compliant, we have to iterate 
    279 ; through, in order, the returned records. Since we want to make this  
    280 ; call over the network, we can ignore tel: lines. Even if it's first 
    281 ; priority.  
    282 exten => s,n(hasplus),Set(ENUMCOUNT=${ENUMLOOKUP(${DIAL_NUMBER},ALL,c,e164.org)})  ;  Should e164.org be a var? I think so. 
    283 ; Now the count may be zero, so if it is, just go to failed 
    284 exten => s,n,GotoIf($[ $[ ${ENUMCOUNT} = 0 ] | $[x${ENUMCOUNT} = x ] ]?failed) 
     279 
     280; start of main network loop 
     281exten => s,n(begin),NoOp(E164NETWORKS is ${E164NETWORKS}) 
     282exten => s,n,GotoIf($["${E164NETWORKS:1:2}"=""]?failedtotally) 
     283exten => s,n,Set(ENUMNET=${CUT(E164NETWORKS,-,1)}) 
     284exten => s,n,Set(E164NETWORKS=${CUT(E164NETWORKS,-,2-)}) 
     285 
     286exten => s,n,NoOp(E164NETWORKS is now ${E164NETWORKS}) 
     287exten => s,n,NoOp(ENUMNET is ${ENUMNET}) 
     288 
     289exten => s,n,Set(ENUMCOUNT=${ENUMLOOKUP(${DIAL_NUMBER},all,c,${ENUMNET})}) 
     290exten => s,n,Set(ENUMPTR=0) 
     291 
     292; start of main lookup loop 
     293exten => s,n(startloop),GotoIf($["${ENUMPTR}"<"${ENUMCOUNT}"]?continue:failed) 
     294 
    285295; Now, let's start through them. 
    286 exten => s,n,Set(ENUMPTR=1
    287 exten => s,n(startloop),Set(ENUM=${ENUMLOOKUP(${DIAL_NUMBER},ALL,${ENUMPTR},e164.org)}) 
    288 ; Sanity check the return, make sure there's something in there. 
    289 exten => s,n,GotoIf($[${LEN(${ENUM})} = 0 ]?continue) 
     296exten => s,n(continue),Set(ENUMPTR=$[${ENUMPTR}+1]
     297exten => s,n,Set(ENUM=${ENUMLOOKUP(${DIAL_NUMBER},all,${ENUMPTR},${ENUMNET})}) 
     298 
     299; Deal with reponse 
    290300exten => s,n,GotoIf($["${ENUM:0:3}" = "sip" ]?sipuri) 
    291301exten => s,n,GotoIf($["${ENUM:0:3}" = "iax" ]?iaxuri) 
     
    293303; about dialstatus and retries if there are any enum results left. 
    294304exten => s,n,GotoIf($["${ENUM:0:3}" = "h32" ]?h323uri) 
    295 ; If we're here, it's not a protocol we know about. Let's increment the pointer 
    296 ; and if it's more than ENUMCOUNT, we know we've run out of options. We also can 
    297 ; come here if the enum string we've received is empty, or if the Dial command 
    298 ; returned CONGESTION or CHANUNAVAIL. 
    299 exten => s,n(continue),Set(ENUMPTR=$[${ENUMPTR}+1]) 
    300 exten => s,n,GotoIf($[${ENUMPTR} > ${ENUMCOUNT}]?failed) 
     305 
    301306; OK. If we're here, we've still got some enum entries to go through. Back to  
    302307; the start with you! 
    303308exten => s,n,Goto(startloop) 
     309 
    304310; If the prefix is 'sip:'... 
    305311exten => s,n(sipuri),Set(DIALSTR=SIP/${ENUM:4}) 
    306312exten => s,n,Goto(dodial) 
     313 
    307314; If it's IAX2... 
    308315exten => s,n(iaxuri),Set(DIALSTR=IAX2/${ENUM:5}) 
    309316exten => s,n,Goto(dodial) 
     317 
    310318; Or even if it's H323. 
    311319exten => s,n(h323uri),Set(DIALSTR=H323/${ENUM:5}) 
     
    313321exten => s,n(dodial),Dial(${DIALSTR}) 
    314322exten => s,n,NoOp(Dial exited in macro-enum-dialout with ${DIALSTATUS}) 
     323 
    315324; Now, if we're still here, that means the Dial failed for some reason.  
    316325; If it's CONGESTION or CHANUNAVAIL we probably want to try again on a 
     
    318327; left, and I didn't keep any previous dialstatuses, so hopefully  
    319328; someone looking throught the logs would have seen the NoOp's 
    320 exten => s,n,GotoIf($["${ENUMPTR}" = "${ENUMCOUNT}"]?noneleft) 
    321 exten => s,n,GotoIf($[ $[ "${DIALSTATUS}" = "CHANUNAVAIL" ] | $[ "${DIALSTATUS}" = "CONGESTION" ] ]?continue) 
     329exten => s,n,GotoIf($["${ENUMPTR}"<"${ENUMCOUNT}"]?maybemore:dialfailed) 
     330exten => s,n(maybemore),GotoIf($[ $[ "${DIALSTATUS}" = "CHANUNAVAIL" ] | $[ "${DIALSTATUS}" = "CONGESTION" ] ]?continue) 
     331 
    322332; If we're here, then it's BUSY or NOANSWER or something and well, deal with it. 
    323 exten => s,n(noneleft),Goto(s-${DIALSTATUS},1) 
     333exten => s,n(dialfailed),Goto(s-${DIALSTATUS},1) 
     334 
    324335; Here are the exit points for the macro. 
    325 exten => s,n(failed),NoOp(EnumLookup failed) 
     336exten => s,n(failed),NoOp(EnumLookup failed on network ${ENUMNET}) 
     337exten => s,n,Goto(begin) 
     338 
     339exten => s,n(failedtotally),NoOp(EnumLookup failed -- no more networks to try) 
    326340exten => s,n,Goto(end) 
     341 
    327342exten => s,n(nochans),NoOp(max channels used up) 
     343 
    328344exten => s,n(end),NoOp(Exiting macro-dialout-enum) 
    329345