[asterisk-dev] Re: extensions.conf included contexts priorities

Tony Mountifield tony at softins.clara.co.uk
Wed Apr 25 10:17:58 MST 2007

In article <1177516020.4769.57.camel at digium2>,
Steve Murphy <murf at parsetree.com> wrote:
> +; The algorithm to find an extension is recursive, and works in this
> +; fashion: 
> +;    a) Try to find a matching extension in the current context
> +;       and, if found, begin executing the priorities there in sequence.
> +;    b) If not found, Search the switches, if any declared, in sequence.
> +;    c) If still not found, for each include, make that context the current
> +;       context, and recurse to a).

This is not an accurate description. The search for an extension in the
current context and then any included contexts is performed afresh at
every priority, and any extension found within an include is executed
in the original context. The included "context" isn't really a context,
even though it looks like one!

Here's an example:

exten => 22,1,NoOp(CONTEXT1=${CONTEXT})

include => bar
include => baz

exten => 22,2,NoOp(CONTEXT2=${CONTEXT})
exten => 22,4,Hangup

exten => 22,3,NoOp(CONTEXT3=${CONTEXT})

If the caller enters context "foo" at extension 22, the following dialplan
applications will be invoked:

NoOp(CONTEXT2=foo) *** not bar ***
NoOp(CONTEXT3=foo) *** not baz ***

Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org

More information about the asterisk-dev mailing list