[asterisk-dev] extensions.conf included contexts priorities

Steve Murphy murf at digium.com
Tue Apr 24 13:38:48 MST 2007

On Tue, 2007-04-24 at 15:32 -0400, Andrew Kohlsmith wrote:
> On Tuesday 24 April 2007 12:36 pm, Jared Smith wrote:
> > Actually, I think this *is* intentend.  As I understand it, here's how
> > the extension matching works in Asterisk.  First, Asterisk tries to
> > find a match in the current context. If it finds no match, it then
> > looks for any switch statements to see if it can find a match there.
> > If there is no match there, it then looks at any include statements.
> > It should also be noted that for nested includes, Asterisk does a
> > depth-first search through the includes.
> [ ... example snipped ... ]
> > In short, we can sum it all up like this: Asterisk checks all
> > extensions before switches, and all switches before includes.  I hope
> > that clears things up for you.  (If I've made a mistake in my
> > explanation, please let me know.)
> No, your explanation is clear, but that leaves implementations hazy.  :-(
> How would one go about handling catchalls?  the 'i' extension seems like a 
> very poor way to do so, and having
> [foo-catchall]
> exten _XXX,1,NoOp(Do something with a ${EXTEN} from foo)
> [foo]
> exten => 123,1,...
> include => bar
> include => baz
> include => foo-catchall
> [bar-catchall]
> exten _XXX,1,NoOp(Do something with a ${EXTEN} from bar)
> [bar]
> exten => 456,1,...
> include => bar-catchall
> [baz-catchall]
> exten _XXX,1,NoOp(Do something with a ${EXTEN} from baz)
> [baz]
> exten => 456,1,...
> include => baz-catchall
> just seems plain old silly...
> Similarly, since that does indeed seem to be the case, there is then no way of 
> overriding a context's extensions by including another context above the 
> extension definitions you want to override.


You only need one such 'catchall' in the include hierarchy. They will
all be searched. The first matching exact-match or pattern match will
take the prize.

My guess is that winner in your dialplan would be foo/bar/bar-catchall.
foo/baz/baz-catchall and foo/foo-catchall are redundant in this case.
And, if you
removed bar-catchall, then foo/baz/baz-catchall would match. And if you
removed that, ...well, you see how it goes.

As far as overriding goes, I'd guess you put your most specific stuff in
the highest-level context, and include more general sorts of stuff. Sort
of inside-out, but still very workable...?


Steve Murphy
Software Developer

More information about the asterisk-dev mailing list