; command ENUMLOOKUP sudah tidak ada di asterisk 1.4, gantinya sbb: ; ada 2 langkah yang perlu dipelajari, yaitu mendefinikan macro dan menggunakan macro nya ; keseluruhan kode ditulis di extensions.conf ; oh ya, ini sudah digunakan di server voiprakyat, dan berjalan baik2 saja, tapi saya lom coba di asterisk default ; takutnya ada salah2 ketik variable dan typos lainnya ; 1. Mendefinisikan macro-enumexten ; urutan lookup bisa dilihat dari sini: E164NETWORKS ; yaitu dari enum.voiprakyat.or.id -> e164.arpa -> e164.org -> e164.info -> enum.org ; urutan lookup protocol dari: SIP -> IAX -> H323 ; ---------------------------------------------------------- [macro-enumexten] ; ; ${ARG1} - Extension to dial ; exten => s,1,Set(DIAL_NUMBER=${ARG1}) exten => s,n,Set(E164NETWORKS=enum.voiprakyat.or.id e164.arpa e164.org e164.info enum.org) ; Checking here to see if there are any e164 networks left to check. exten => s,n(begin),GotoIf($["${LEN(${E164NETWORKS})}" < "1"]?failed) ; There are, so we take the first one exten => s,n,Set(ENUMNET=${CUT(E164NETWORKS, ,1)}) ; And trim it from the front of E164NETWORKS exten => s,n,Set(E164NETWORKS=${CUT(E164NETWORKS, ,2-)}) ; OK, this is now quite complex. To remain compliant, we have to iterate ; through, in order, the returned records. Since we want to make this ; call over the network, we can ignore tel: lines. Even if it's first ; priority. exten => s,n,NoOp(EnumLookup ${DIAL_NUMBER} ALL c ${ENUMNET}) exten => s,n,Set(ENUMCOUNT=${ENUMLOOKUP(${DIAL_NUMBER}|ALL|c||${ENUMNET})}) ; Documentation is wrong. It can return nothing if the enum lookup fails. Grr. ; Now the count may be zero, so if it is, check the next network exten => s,n,GotoIf($["${ENUMCOUNT}" = "0"]?begin) exten => s,n,GotoIf($["x${ENUMCOUNT}" = "x"]?begin) ; Now, let's start through them. exten => s,n,Set(ENUMPTR=1) exten => s,n,NoOp(EnumLookup 1by1 ${DIAL_NUMBER} ${ENUMPTR} ${ENUMNET}) exten => s,n(startloop),Set(ENUM=${ENUMLOOKUP(${DIAL_NUMBER}|ALL||${ENUMPTR}|${ENUMNET})}) ; Sanity check the return, make sure there's something in there. exten => s,n,GotoIf($["${LEN(${ENUM})}" = "0"]?continue) exten => s,n,GotoIf($["${ENUM:0:3}" = "iax"]?iaxuri) exten => s,n,GotoIf($["${ENUM:0:3}" = "sip"]?sipuri) ; It doesn't matter if you don't have h323 enabled, as when it tries to dial, it cares ; about dialstatus and retries if there are any enum results left. ;exten => s,n,GotoIf($["${ENUM:0:3}" = "h32"]?h323uri) ; If we're here, it's not a protocol we know about. Let's increment the pointer ; and if it's more than ENUMCOUNT, we know we've run out of options. Try the ; next e164 network. exten => s,n(continue),Set(ENUMPTR=$[${ENUMPTR} + 1]) exten => s,n,GotoIf($[${ENUMPTR} > ${ENUMCOUNT}]?begin) ; OK. If we're here, we've still got some enum entries to go through. Back to ; the start with you! exten => s,n,Goto(startloop) ; If the prefix is 'sip:'... exten => s,n(sipuri),Set(DIALSTR=SIP/${ENUM:4}) exten => s,n,Goto(dodial) ; If it's IAX2... exten => s,n(iaxuri),Set(DIALSTR=IAX2/${ENUM:5}) exten => s,n,Goto(dodial) ; Or even if it's H323. ;exten => s,n(h323uri),Set(DIALSTR=H323/${ENUM:5}) exten => s,n(dodial),Dial(${DIALSTR}) exten => s,n,NoOp(Dial exited in macro-enumexten with ${DIALSTATUS}) ; Now, if we're still here, that means the Dial failed for some reason. ; If it's CONGESTION or CHANUNAVAIL we probably want to try again on a ; different channel. However, if it's the last one, we don't have any ; left, and I didn't keep any previous dialstatuses, so hopefully ; someone looking throught the logs would have seen the NoOp's exten => s,n,GotoIf($[${ENUMPTR} = ${ENUMCOUNT}]?noneleft) exten => s,n,GotoIf($[$[${DIALSTATUS} = "CHANUNAVAIL"] | $[${DIALSTATUS} = "CONGESTION"] ]?continue) ; If we're here, then it's BUSY or NOANSWER or something and well, deal with it. exten => s,n(noneleft),Goto(s-${DIALSTATUS},1) ; Here are the exit points for the macro. exten => s,n(failed),NoOp(EnumLookups failed) exten => s,n,Goto(end) exten => s,n(nochans),NoOp(max channels used up) exten => s,n(end),NoOp(Exiting macro-enumexten) exten => s,n,Hangup exten => s-BUSY,1,NoOp(Trunk is reporting BUSY) exten => s-BUSY,n,Busy() exten => s-BUSY,n,Wait(60) exten => s-BUSY,n,NoOp() exten => s-BUSY,n,Hangup exten => _s-.,1,NoOp(Dial failed due to ${DIALSTATUS}) exten => _s-.,n,Hangup exten => h,1,Hangup ; 2. Cara menggunakan macro-enumexten ; ---------------------------------------------------------- ; Prefix 62188 for ENUM VoIP Rakyat exten => _62188ZX.,1,Macro(enumexten,+${EXTEN}) ; Prefix + or 00 for ENUM extensions exten => _+ZX.,1,Macro(enumexten,${EXTEN}) exten => _00ZX.,1,Macro(enumexten,+${EXTEN:2}) -- VoIP Rakyat anton raharja http://www.antonraharja.web.id