[asterisk-dev] CID match uses "shortest prefix match"

Klaus Darilion klaus.mailinglists at pernau.at
Wed Mar 18 06:08:15 CDT 2009


Hi Jared!

Thanks for helping in clarifying things.


So what about dialing 123456 and having:
exten => _12345.,NoOp(Option 1)
exten => _123.,1,NoOp(Option 2)

Which one will be used? I do not found this scenario in your description.

Or what will be used in this case (dialing 123456):
exten => _X2345.,NoOp(Option 1)
exten => _123.,1,NoOp(Option 2)


thanks
Klaus



Jared Smith schrieb:
> ----- "Klaus Darilion" <klaus.mailinglists at pernau.at> wrote:
>> Of course this is ambiguous, actualla how is Asterisk sorting such
>>  extensions?
>> 
>> With exten => _123.,1,NoOp(Matches 3 digits using 16 bytes of
>> pattern) exten => _XXXX.,1,NoOp(Matches 5+ digits using only 7
>> bytes of pattern)
> 
> 
> Here's my understanding of how the pattern matching works in
> Asterisk.  (And if I'm wrong, please correct me, as I've been working
> on this for a while now.)  There are four simple rules to follow:
> 
> 1) Go digit by digit from left to right
> 
> 2) See if the dialed digit matches the current digit in the pattern.
> If there's not a match, exclude this pattern.  If there is a match,
> only advanced the pattern(s) with the lowest number of possibilities
> in the match.  If two or more patterns have the same number of
> possibilities, order them in ASCII sorting order.
> 
> 3) Move on to the next digit.
> 
> 4) When you've evaluated every digit, take the pattern on the top and
> execute that extension.
> 
> 
> Now that we've enumerated the rules, let's look as a couple of
> examples...
> 
> exten => _NXX,1,NoOp(Option 1) exten => _[1-3]XX,1,NoOp(Option 2)
> 
> In this case, if the caller dialed 333, Option 2 would be matched, as
> the [1-3] is more constrained (has fewer possibilities) than the N.
> Let's look at on more example:
> 
> exten => _NXX,1,NoOp(Option 3) exten => _[1-8],1,NoOp(Option 4)
> 
> This one is a bit trickier, as the N has eight possibilities (2
> through 9), and so does the [1-8].  Because 1 comes before N in ASCII
> sorting order, it doing to get matched (again, assuming the caller
> dials 333).
> 
> Hopefully, that clarifies things for those who were confused about
> how Asterisk does its pattern matching.  (And yes, this really should
> be documented somewhere inside of Asterisk, such as the default
> extensions.conf file or a file in the doc/ subdirectory of the source
> code.)
> 
> --- Jared Smith Training Manager Digium, Inc.
> 
> _______________________________________________ --Bandwidth and
> Colocation Provided by http://www.api-digital.com--
> 
> asterisk-dev mailing list To UNSUBSCRIBE or update options visit: 
> http://lists.digium.com/mailman/listinfo/asterisk-dev



More information about the asterisk-dev mailing list