System information

same => n,Set(thisResult=${DUNDIRESULT(${DUNDI_ID},${ResultCounter})})
; If the current value returned is not None, we have a resulting
; location to call and we can exit the loop
same => n,ExecIf($["${thisResult}" != "None"]?ExitWhile())
; If we made it this far, no value has been returned yet that we want to
; use, so increase the counter and try the next value.
same => n,Set(ResultCounter=${INC(ResultCounter)})
; End of our loop
same => n,EndWhile()
; We've made it here because we made it to the end of the loop or we found
; a value we want to return. Check to see which it is. If we just ran out of
; values, return 'None'.
;
same => n,GotoIf($["${thisResult}" = "None"]?NoResults,1)
; If we make it here, we have a value we want to return.
same => n,Return(${thisResult})
; If there were no acceptable results, return the value 'None'
exten => NoResults,1,Verbose(2,No results were found)
same => n,Return(None)
With the DUNDIQUERY() and DUNDIRESULT() functions, you have a lot of power to control
how to handle the results returned and perform routing logic with those values.
Conclusion
In this chapter we looked at how the DUNDi protocol helps you to perform lookups
against the other Asterisk systems in your cluster, to perform dynamic routing. With
the use of DUNDi, you can take multiple systems and control when and where calls
are placed within them, providing toll-bypass capabilities and even giving your em-
ployees the ability to move between physical locations, while also limiting the number
of out-of-system hops a call must take to find them.
While the original intention of DUNDi was to help us migrate away from centralized
directory services—an intention that has yet to come to fruition—DUNDi is an ex-
tremely effective and useful tool that can be put to work in organizations to advertise
and route calls dynamically between systems in a cloud environment. DUNDi is a tool
that gives great power to Asterisk administrators looking to create a distributed
network.
522 | Chapter 23:Distributed Universal Number Discovery (DUNDi)