Keywords: asterisk

## Some more Examples

All examples below except where noted use "e164.arpa" as the referenced domain, which is the default domain name for ENUMLOOKUP. All numbers are assumed to not have a leading "+" as dialed by the inbound channel, so that character is added where necessary during ENUMLOOKUP function calls.

-     ; example 1
      ;
      ; Assumes North American international dialing (011) prefix.
      ; Look up the first SIP result and send the call there, otherwise
      ;  send the call out a PRI.  This is the most simple possible
      ;  ENUM example, but only uses the first SIP reply in the list of
      ;  NAPTR(s).
      ;
      exten => _011.,1,Set(enumresult=${ENUMLOOKUP(+${EXTEN:3})})
      exten => _011.,n,Dial(SIP/${enumresult})
      exten => _011.,n,Dial(DAHDI/g1/${EXTEN})
      ;
      ; end example 1

      ; example 2
      ;
      ; Assumes North American international dialing (011) prefix.
      ; Check to see if there are multiple SIP NAPTRs returned by
      ;  the lookup, and dial each in order.  If none work (or none
      ;  exist) then send the call out a PRI, group 1.
      ;
      exten => _011.,1,Set(sipcount=${ENUMLOOKUP(${EXTEN:3},sip,c)}|counter=0)
      exten => _011.,n,While($["${counter}"<"${sipcount}"])
      exten => _011.,n,Set(counter=$[${counter}+1])
      exten => _011.,n,Dial(SIP/${ENUMLOOKUP(+${EXTEN:3},sip,,${counter})})
      exten => _011.,n,EndWhile
      exten => _011.,n,Dial(DAHDI/g1/${EXTEN})
      ;
      ; end example 2

      ; example 3
      ;
      ; This example expects an ${EXTEN} that is an e.164 number (like
      ;  14102241145 or 437203001721)
      ; Search through e164.arpa and then also search through e164.org
      ;  to see if there are any valid SIP or IAX termination capabilities.
      ;  If none, send call out via DAHDI channel 1.
      ;
      ; Start first with e164.arpa zone...
      ;
      exten => _X.,1,Set(sipcount=${ENUMLOOKUP(+${EXTEN},sip,c)}|counter=0)
      exten => _X.,2,GotoIf($["${counter}"<"${sipcount}"]?3:6)
      exten => _X.,3,Set(counter=$[${counter}+1])
      exten => _X.,4,Dial(SIP/${ENUMLOOKUP(+${EXTEN},sip,,${counter})})
      exten => _X.,5,GotoIf($["${counter}"<"${sipcount}"]?3:6)
      ;
      exten => _X.,6,Set(iaxcount=${ENUMLOOKUP(+${EXTEN},iax2,c)}|counter=0)
      exten => _X.,7,GotoIf($["${counter}"<"${iaxcount}"]?8:11)
      exten => _X.,8,Set(counter=$[${counter}+1])
      exten => _X.,9,Dial(IAX2/${ENUMLOOKUP(+${EXTEN},iax2,,${counter})})
      exten => _X.,10,GotoIf($["${counter}"<"${iaxcount}"]?8:11)
      ;
      exten => _X.,11,NoOp("No valid entries in e164.arpa for ${EXTEN} - checking in e164.org")
      ;
      ; ...then also try e164.org, and look for SIP and IAX NAPTRs...
      ;
      exten => _X.,12,Set(sipcount=${ENUMLOOKUP(+${EXTEN},sip,c,,e164.org)}|counter=0)
      exten => _X.,13,GotoIf($["${counter}"<"${sipcount}"]?14:17)
      exten => _X.,14,Set(counter=$[${counter}+1])
      exten => _X.,15,Dial(SIP/${ENUMLOOKUP(+${EXTEN},sip,,${counter},e164.org)})
      exten => _X.,16,GotoIf($["${counter}"<"${sipcount}"]?14:17)
      ;
      exten => _X.,17,Set(iaxcount=${ENUMLOOKUP(+${EXTEN},iax2,c,,e164.org)}|counter=0)
      exten => _X.,18,GotoIf($["${counter}"<"${iaxcount}"]?19:22)
      exten => _X.,19,Set(counter=$[${counter}+1])
      exten => _X.,20,Dial(IAX2/${ENUMLOOKUP(+${EXTEN},iax2,,${counter},e164.org)})
      exten => _X.,21,GotoIf($["${counter}"<"${iaxcount}"]?19:22)
      ;
      ; ...then send out PRI.
      ;
      exten => _X.,22,NoOp("No valid entries in e164.org for ${EXTEN} - sending out via DAHDI")
      exten => _X.,23,Dial(DAHDI/g1/${EXTEN})
      ;
      ; end example 3