List Info

Thread: Re: new priority of pattern matching in 1.4. Does it makes sense?




Re: new priority of pattern matching in 1.4. Does it makes sense?
country flaguser name
Canada
2008-02-22 10:31:13
Kudos Jared for citing a good example. At least now I see
that there is
at least one practical application of this methodology.

IMHO, I wouldn't recommend building a dialplan that way
because it is
pretty ambiguous to someone that doesn't understand the
inner workings
of Asterisk pattern matching.

Indeed, I admit that had you given me that example and asked
me which
pattern would match I would not have been able to say with
certainty how
it would work.

As a practical example, I prefer to do dial plans this way:

[class1] ; lobby
include => local
include => toll-free
include => block-ld
include => block-int
include => no-sex

[class2] ; secretary
include => local
include => toll-free
include => long-distance
include => block-int
include => no-sex

[class3] ; CEO
include => local
include => toll-free
include => long-distance
include => international
include => sex

[local]
include => convert-to-local
exten => _NXXXXXX,1,Dial(IAX2/some_itsp/$) ;
seven-digit local
exten => _NXXNXXXXXX,1,Dial(IAX2/some_itsp/$) ;
ten-digit local

[toll-free]
exten => _1800NXXXXXX,1,Dial(IAX2/some_itsp/$) ;
800 toll free
exten => _1888NXXXXXX,1,Dial(IAX2/some_itsp/$) ;
888 toll free
exten => _1877NXXXXXX,1,Dial(IAX2/some_itsp/$) ;
877 toll free
exten => _1866NXXXXXX,1,Dial(IAX2/some_itsp/$) ;
866 toll free

[long-distance]
exten => _1NXXNXXXXXX,1,Dial(IAX2/some_itsp/$) ;
allow ld calls

[international]
exten => _011.,1,Dial(IAX2/some_itsp/$) ; allow
int. calls

[sex]
exten => _1900NXXXXXX,1,Dial(IAX2/some_itsp/$) ;
allow int. calls

[block-ld]
exten =>
_1NXXNXXXXXX,1,Playback(this-call-is-not-allowed,n) ; block
ld 
exten => _1NXXNXXXXXX,n,Congestion(5)
exten => _1NXXNXXXXXX,n,Hangup()

[block-int]
exten => _011.,1,Playback(this-call-is-not-allowed,n) ;
block int'l
exten => _011.,n,Congestion(5)
exten => _011.,n,Hangup()

[no-sex]
exten =>
_1900NXXXXXX,1,Playback(this-call-is-not-allowed,n) ; block
900
exten => _1900NXXXXXX,n,Congestion(5)
exten => _1900NXXXXXX,n,Hangup()

[convert-to-local]
exten => _1555222XXXX,1,Dial(IAX2/some_itsp/${EXTEN:4})
exten => _1555223XXXX,1,Dial(IAX2/some_itsp/${EXTEN:4})
exten => _1555224XXXX,1,Dial(IAX2/some_itsp/${EXTEN:4})
... etc...
----

With a quick look you can tell how the calls will route for
each of the
kinds of phones. I admit that it's a bit longer and
"readability" is
purely a subjective thing.

My point is simply that this example doesn't work with the
existing
system. "convert-to-local" never matches because
"long-distance" is
always a higher priority.

A while back there was a thread regarding implementing a
type of regexp
matching and as part of that work there might be some
optimization of
matching as well. If that work ever makes it in then it
would seem to
make sense to reevaluate the priority matching system as
well.

Thanks to all for the feedback on this topic.

John



_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.c
om--

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Re: new priority of pattern matching in 1.4. Does it makes sense?
country flaguser name
United States
2008-02-22 16:10:26
On Fri, 2008-02-22 at 10:31 -0600, John Lange wrote:
> 
> [...]
> 
> My point is simply that this example doesn't work with
the existing
> system. "convert-to-local" never matches
because "long-distance" is
> always a higher priority.
> 

I didn't test this, but my gut tells me [convert-to-local]
would match
before long-distance (asterisk would search in [local] then
in
[convert-to-local] before moving on).  Also you would need
to include
the [no-sex] context first for it to be effective, other
wise 900
numbers would match in [longdistance].

-- 
Matthew Nicholson
Digium


_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.c
om--

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Re: new priority of pattern matching in 1.4. Does it makes sense?
country flaguser name
United States
2008-02-23 12:36:33
On Fri, 2008-02-22 at 10:31 -0600, John Lange wrote:
> Kudos Jared for citing a good example. At least now I
see that there is
> at least one practical application of this
methodology.

I'm glad you liked my example.

> My point is simply that this example doesn't work with
the existing
> system. "convert-to-local" never matches
because "long-distance" is
> always a higher priority.

I'm not following you here.  I pasted your example into my
extensions.conf, reloaded the dialplan, and then examined
the dialplan:

localhost*CLI> dialplan show 15552221212class1
[ Included context 'convert-to-local' created by
'pbx_config' ]
  '_1555222XXXX' => 1. Dial(IAX2/some_itsp/${EXTEN:4})   
        [pbx_config]

[ Included context 'block-ld' created by 'pbx_config' ]
  '_1NXXNXXXXXX' => 1.
Playback(this-call-is-not-allowed|n)       [pbx_config]
                    2. Congestion(5)                        
     [pbx_config]
                    3. Hangup()                             
     [pbx_config]


This clearly shows that for the lobby phone (pointing at the
class1
context), the convert-to-local context is the first to
match.

Same thing for the class2 context:

localhost*CLI> dialplan show 15552221212class2
[ Included context 'convert-to-local' created by
'pbx_config' ]
  '_1555222XXXX' => 1. Dial(IAX2/some_itsp/${EXTEN:4})   
        [pbx_config]
 
[ Included context 'long-distance' created by 'pbx_config'
]
  '_1NXXNXXXXXX' => 1. Dial(IAX2/some_itsp/$)     
        [pbx_config]

And the same holds true for the class3 context as well:

localhost*CLI> dialplan show 15552221212class3
[ Included context 'convert-to-local' created by
'pbx_config' ]
  '_1555222XXXX' => 1. Dial(IAX2/some_itsp/${EXTEN:4})   
        [pbx_config]
 
[ Included context 'long-distance' created by 'pbx_config'
]
  '_1NXXNXXXXXX' => 1. Dial(IAX2/some_itsp/$)     
        [pbx_config]
  
[ Included context 'convert-to-local' created by
'pbx_config' ]
  '_1555222XXXX' => 1. Dial(IAX2/some_itsp/${EXTEN:4})   
        [pbx_config]

I'm really confused as to why this isn't working for you, as
it's
clearly working the way you intended here in my dialplan. 
I'd be
interested in seeing the output of the "dialplan
show" commands from
your system.

-- 
Jarenessto
Community Relations Manager
Digium, Inc.


_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.c
om--

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )