[asterisk-users] Re: Extension presedence.

Tony Mountifield tony at softins.clara.co.uk
Fri Aug 18 02:31:47 MST 2006


In article <44E578B3.5030301 at decisionworx.com>,
Jan du Toit <jan.du.toit at decisionworx.com> wrote:
> 
> I have the following two extensions:
> exten => _71405XXXXXXX,1,Dial(Zap/g1/${EXTEN:5}|20,tr)
> exten => _71.,1,Dial(Zap/g2/${EXTEN:2}|20,tr)
> 
> I have an external application that generates dialstrings, it generates 
> the 71 prefix so that the call can go through the T1 cards. As you can 
> see the 71 is cut of when passing it to the cards itself (EXTEN:2).
> On the T1 card we have 4 circuits. One for local (group one is 
> configured for that) and three long disctance (group 2,3 and 4).
> 
> When I dial a 405 number it goes to the second exetension, group 2. I 
> want it to go through the first group.
> I thought that since the first extension is more specific it will have 
> presedence over the second general one.
> Is this right? Am I doing something wrong?

I think the extensions are sorted into ASCII order, in which case . comes
before digits.

There are three ways you could do it. The first is to match the exceptions:

exten => _71405XXXXXXX,1,Dial(Zap/g1/${EXTEN:5}|20,tr)
exten => _7140[0-46-9].,1,Dial(Zap/g2/${EXTEN:2}|20,tr)
exten => _714[1-9].,1,Dial(Zap/g2/${EXTEN:2}|20,tr)
exten => _71[0-35-9].,1,Dial(Zap/g2/${EXTEN:2}|20,tr)

The second is to put them in separate contexts and include those contexts.
Included contexts get searched in order:

[area405]
exten => _71405XXXXXXX,1,Dial(Zap/g1/${EXTEN:5}|20,tr)

[non405]
exten => _71.,1,Dial(Zap/g2/${EXTEN:2}|20,tr)

[mycontext]
include => area405
include => non405

The third is to use Xs to match the correct number of digits. X comes after
digits in sorting order:

exten => _71405XXXXXXX,1,Dial(Zap/g1/${EXTEN:5}|20,tr)
exten => _71XXXXXXXXXX,1,Dial(Zap/g2/${EXTEN:2}|20,tr)

Even _71X. would work, but you probably want to accept only the correct
number of digits in all cases.

Hope this helps!

Cheers
Tony
-- 
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-users mailing list