[asterisk-dev] extensions.conf included contexts priorities

Steve Murphy murf at digium.com
Wed Apr 25 17:29:17 MST 2007

On Wed, 2007-04-25 at 12:50 -0400, Andrew Kohlsmith wrote:
> On Wednesday 25 April 2007 11:47 am, Steve Murphy wrote:
> > I do propose that we make the following change to the
> > extensions.conf.sample file to minimize user
> > misunderstanding/frustration over include directives.... the reason this
> > thread began...
> >
> > Do you think this might help? Is the English proper?
> I'd mention that wildcards are also searched depth-first, and that if a 
> wildcard in the current context matches, a more specific extension in an 
> included (or switched) context will NOT get executed.
> This is the most confusing part for me.  I was under the impression (and it 
> always seemed to work) that wildcards were searched DEAD LAST, since an 
> included context with an extension with fewer (incl. 0) wildcards was a 
> better match than an extension with more wildcards.
> What's scary (to me) is that my dialplans have been working just fine until 
> very, very recently.
> -A.

OK; is this better?

Jared, Leif, could any of this help flesh out a chapter in the Asterisk


Index: configs/extensions.conf.sample
--- configs/extensions.conf.sample      (revision 61639)
+++ configs/extensions.conf.sample      (working copy)
@@ -140,15 +140,48 @@
 ; Contexts contain several lines, one for each step of each
 ; extension, which can take one of two forms as listed below,
-; with the first form being preferred.  One may include another
-; context in the current one as well, optionally with a
-; date and time.  Included contexts are included in the order
-; they are listed.
+; with the first form being preferred. 
 ;exten => someexten,{priority|
 ;exten => someexten,{priority|
+; Included Contexts
+; One may include another context in the current one as well,
optionally with a
+; date and time.  Included contexts are included in the order
+; they are listed.
+; The reason a context would include other contexts is for their 
+; extensions.
+; The algorithm to find an extension is recursive, and works in this
+; fashion: 
+;       first, given a stack on which to store context references, 
+;           push the context to find the extension onto the stack...
+;    a) Try to find a matching extension in the context at the top of 
+;       the stack, 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, push that context onto 
+;       the top of the context stack, and recurse to a).
+;    d) If still not found, pop the entry from the top of the stack; 
+;       if the stack is empty, the search has failed. If it's not, 
+;       continue with the next context in c).
+; This is a depth-first traversal, and stops with the first context 
+; that provides a matching extension. As usual, if more than one
+; pattern in a context will match, the 'best' match will win.
+; Please note that that extensions found in an included context are
+; treated as if they were in the context from which the search began.
+; The PBX's notion of the "current context" is not changed.
+; Please note that in a context, it does not matter where an include
+; directive occurs. Whether at the top, or near the bottom, the effect 
+; will be the same. The only thing that matters is that if there is 
+; more than one include directive, they will be searched for
+; in order, first to last.
+; Also please note that pattern matches (like _9XX) are not treated
+; any differently than exact matches (like 987). Also note that the
+; order of extensions in a context have no affect on the outcome.
 ; Timing list for includes is 
 ;   <time range>|<days of week>|<days of month>|<months>

Steve Murphy
Software Developer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3227 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20070425/7789df81/smime.bin

More information about the asterisk-dev mailing list