[asterisk-bugs] [Asterisk-GUI 0014156]: Cannot sort dialplan outgoing calling rules

Asterisk Bug Tracker noreply at bugs.digium.com
Fri Jan 9 13:45:24 CST 2009


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=14156 
====================================================================== 
Reported By:                dkerr
Assigned To:                bkruse
====================================================================== 
Project:                    Asterisk-GUI
Issue ID:                   14156
Category:                   Service Providers/Trunks
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     assigned
Asterisk Version:           1.4.21.2 
SVN Branch (only for SVN checkouts, not tarball releases):  trunk 
SVN Revision (number only!): 4389 
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             2008-12-31 15:21 CST
Last Modified:              2009-01-09 13:45 CST
====================================================================== 
Summary:                    Cannot sort dialplan outgoing calling rules
Description: 
The implementation of dialplans and outbound calling rules in the GUI
introduces a nasty problem due to sorting (or lack thereof). Take a simple
example where you want to route tollfree calls over a different voip
carrier.

If you create the dialplan by directly editing extensions.conf you might
create something like this...

[DLPN_DefaultDialPlan]
exten =
_1NXXNXXXXXX,1,Macro(trunkdial-failover-0.3,${voip1}/${EXTEN:0},,voip1,)
exten =
_1800NXXXXXX,1,Macro(trunkdial-failover-0.3,${voip2}/${EXTEN:0},,voip2,)
exten =
_1888NXXXXXX,1,Macro(trunkdial-failover-0.3,${voip2}/${EXTEN:0},,voip2,)
exten =
_1877NXXXXXX,1,Macro(trunkdial-failover-0.3,${voip2}/${EXTEN:0},,voip2,)
exten =
_1866NXXXXXX,1,Macro(trunkdial-failover-0.3,${voip2}/${EXTEN:0},,voip2,)

This would work nicely because asterisk would sort the extension patterns
and it would match against the 1800/1888/1877/1866 before matching against
1NXX.

But the GUI does not let me create such a dialplan. I cannot add more than
one dial pattern to a calling rule. So I am forced to create something like
this...

[CallingRule_DomesticLD]
exten =
_1NXXNXXXXXX,1,Macro(trunkdial-failover-0.3,${voip1}/${EXTEN:0},,voip1,)
[CallingRule_DomesticTollfree800]
exten =
_1800NXXXXXX,1,Macro(trunkdial-failover-0.3,${voip2}/${EXTEN:0},,voip2,)
[CallingRule_DomesticTollfree888]
exten =
_1888NXXXXXX,1,Macro(trunkdial-failover-0.3,${voip2}/${EXTEN:0},,voip2,)
[CallingRule_DomesticTollfree877]
exten =
_1877NXXXXXX,1,Macro(trunkdial-failover-0.3,${voip2}/${EXTEN:0},,voip2,)
[CallingRule_DomesticTollfree866]
exten =
_1866NXXXXXX,1,Macro(trunkdial-failover-0.3,${voip2}/${EXTEN:0},,voip2,)

Then in the dialplan GUI page I get to select the calling rules I want,
which creates...

[DLPN_DefaultDialPlan]
include = CallingRule_DomesticLD
include = CallingRule_DomesticTollfree800
include = CallingRule_DomesticTollfree888
include = CallingRule_DomesticTollfree877
include = CallingRule_DomesticTollfree866

So, what's the problem?  Well apart from being very cumbersome to create
so many calling rules, the real problem is that asterisk does not sort
extension patterns across "includes".  Patterns inside each include are
sorted, but then the DLPN_DefaultDialPlan is parsed in the order each
include is listed in the context. In the above example DomesticLD is first
and so it's pattern of _1NXX matches both tollfree and toll calls... the
tollfree patterns are never matched.

Manually editing the extension.conf file provides a workaround of sorts.
You can manually add multiple patterns to a calling rule. So you can make
[CallingRule_DomesticLD] look exactly like my first example above. And,
while the GUI calling rules page can't create such a thing, if you create
one manually the GUI page recognizes it and lets you edit it (even change
the order of each pattern... which is unnecessary and a NoOp as asterisk
sorts anyway). But that doesn't fix the core problem of sorting the include
statements in the dialplan which is needed.


Proposed fix...
1) the Dialplan GUI needs redesigned to allow sorting the order that
Calling Rules are included.
2) the Calling Rules GUI needs design change to allow adding patterns to
an existing rule.

I don't have time to tackle a patch of this size right now, but wanted to
open this bug to track the issue and open discussion on it.

David

====================================================================== 

---------------------------------------------------------------------- 
 (0097352) awk (manager) - 2009-01-09 13:45
 http://bugs.digium.com/view.php?id=14156#c97352 
---------------------------------------------------------------------- 
Hey David,
This does appear to be an issue. A temporary solution would be to create
the 'DomesticLD' or the abstract catch-all condition last, thus the
includes (example below) would have the LD calling rule last preventing
your undesired situation. I haven't tested this suggestion, but I'm
assuming, based on my knowledge of the GUI mechanics, that it is possible.

[DLPN_DefaultDialPlan]
include = CallingRule_DomesticTollfree800
include = CallingRule_DomesticTollfree888
include = CallingRule_DomesticTollfree877
include = CallingRule_DomesticTollfree866
include = CallingRule_DomesticLD

A redesign of this feature would probably be the better long term
solution. I'm changing this from a bug to a feature request as the GUI is
working as intended, but missing the requested ability (read: feature). 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-01-09 13:45 awk            Note Added: 0097352                          
======================================================================




More information about the asterisk-bugs mailing list