ENUMLOOKUP pada Asterisk 1.4

Begini kita melakukannya pada Asterisk 1.2: (pada 1.4 dijelaskan dibawah)

1. Mendefinisikan ENUM server yang akan di-lookup

edit /etc/asterisk/enum.conf dan isikan:

; ENUM server
search => enum.voiprakyat.or.id
search => e164.arpa
search => e164.org
search => e164.info
search => enum.org

2. Melakukan proses ENUM lookup

edit /etc/asterisk/extensions.conf dan isikan (biasanya pada baris paling bawah):

; 0 => 62
exten => _0X.,1,Dial(Local/62${EXTEN:1})
exten => _0X.,2,Hangup

; ENUM with +
exten => _+X.,1,Dial(Local/${EXTEN:1})
exten => _+X.,2,Hangup

exten => _X.,1,Ringing
exten => _X.,2,Wait,2
exten => _X.,3,ENUMLOOKUP(+${EXTEN})
exten => _X.,4,Dial(${ENUM}|30|tTwW)
exten => _X.,5,Hangup
exten => _X.,104,Playback(no-route-exists-to-dest)

Pada Asterisk 1.4 kita tidak bisa lagi menggunakan command ENUMLOOKUP(), diganti menjadi function ${ENUMLOOKUP(…)}. Sebagai alternatif saya menggunakan macro sehingga penggunaannya sama dengan ENUMLOOKUP pada Asterisk 1.2.

Begini kita melakukannya pada Asterisk 1.4:

1. Mendefinisikan macro ENUM lookup dengan nama macro-enumexten

edit /etc/asterisk/extensions.conf dan isikan sebelum block [default]:

; ${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})

; 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. Melakukan proses ENUM lookup

edit /etc/asterisk/extensions.conf dan isikan (biasanya pada baris paling bawah):

; 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})

Struktur file /etc/asterisk/extensions.conf kurang-lebih akan seperti berikut:


langkah 1 disini


disini extension2 anda, termasuk langkah 2

Masih perlu tempat bertanya ? Kunjungi http://developer.voiprakyat.or.id/forum/viewtopic.php?t=643 dan posting pertanyaan (mungkin juga pengalaman anda mencoba) disana.


One thought on “ENUMLOOKUP pada Asterisk 1.4

Comments are closed.