Match-as-you-go


#1

Hello

I have the following setup:
[ul]
[li]PC running Linux(Debian/Sarge) and Asterisk (1.0.7)[/li]
[li]a HFC-based ISDN-card in the PC in NT-mode (E-Tech PCTA128 PCI ISDN board)[/li]
[li]one softphone client (sjphone)[/li]
[li]one ISDN-to-analog converter/pabx connected to the ISDN-card via a crossed ISDN-cable (duovox)[/li][/ul]

Most things work fine. For example: I can call the analog phones behing the duovox from the sjphone-softphone via asterisk, I can even call the analog phones from PSTN phones via a gateway (like the free world dialup access number provider by xs4all in the Netherlands). Very nice!
I can dial out with the SJphone-softphone, no problems there.

Dialing out from the analog phones however is a problem. I think it has to do with the dialplan in extensions.conf, probably I misunderstand how asterisk handles “match-as-you-go” dialing (http://www.voip-info.org/wiki-Asterisk+Extension+Matching).

I planned my dialplan to result in the following behaviour of Asterisk:
[ul]
[li]numbers starting with “0” are “real” phonenumbers and are handled by my sip-provider (e.g: 0612345678 --> sip:0612345678@provider.nl)[/li]
[li]numbers not starting with a “0” are local or special numbers (e.g: 31 --> misdn/1/31 is a analog phone)[/li][/ul]

My dialplan (see end of this message) works for the SJphone client. But for the analog phones I get the following behaviour when I try to dial 0623456789:
After the first 3 digits (062):

-- Executing Dial("mISDN/1", "SIP/06@provider") in new stack
-- Called 06@provider
-- Got SIP response 404 "User not found" back from 12.34.56.78
-- SIP/provider-e19c is circuit-busy
== Everyone is busy/congested at this time
 WARNING[30263]: pbx.c:1938 ast_pbx_run: Invalid extension '2', but no rule 'i' in context 'intern'

Asterisk immediately dials sip:06@provider without waiting for the number to be complete… This is what I tried to avoid with the “include=>longnumbers” before the “include=>normalnumbers”. But is does not work…
The problem is that I can not say beforehand how long the phonenumber is going to be. It depends on the destination (national/international/toll-free/etc). I can make it work for most national numbers in Holland, since they are all 10 digits. If I change the line
exten => 0.,1,Dial…
into
exten =>0XXXXXXXXX,1,Dial…
I get what I want for most national Dutch numbers.

How can I make this also work for any number (short (few digits) toll free numbers, long (many digits) internation numbers)?


Here is my asterisk configuration:
misdn.conf
[general]
context=intern
language=en
immediate=no
debug=0
msns=*

[NTports]
context=intern
ports=1

relevant part of extensions.conf:
[intern]
exten => 31,1,Dial(misdn/1/31)
include => longnumbers
include => normalnumbers

[longnumbers]
exten => _0XXXXXXXXXXXXXX,1,Congestion

[normalnumbers]
exten => _0.,1,Dial(SIP/${EXTEN:0}@provider)


#2

Change

exten => _0.,1,Dial(SIP/${EXTEN:0}@provider)

to

exten => _0XXXXXXXX,1,Dial(SIP/${EXTEN:0}@provider)


#3

Thanks for the reply.

exten => _0XXXXXXXXX,1,Dial…
only matches 10-digit numbers starting with a zero. So this works for most national Dutch numbers, but this does not match Belgian national numbers (e.g. 003223456789) or Australian (006123456789)

If I add a
exten => _00XXXXXXXXXX,1,Dial…
the dialplan still works for the 10-digit Dutch numbers, but if I dial 006123456789 Asterisk dials sip:0061234567@provider before I completed typing the number.

So the problem is that not all phone numbers are equal length! How can I work around this?


#4

More than a year ago people were also having similar problems:
http://lists.digium.com/pipermail/asterisk-users/2004-April/043447.html
However they were using chan_zap and I am using chan_misdn.

Is match-as-you-go dialing handled in the Asterisk code or in the channel code? If it is handled ‘per channel’:
Does match-as-you-go dialing work in chan_zap now?
Maybe some source code from chan_zap should be copied to chan_misdn?


#5

[quote=“zmanea”]Change

exten => _0.,1,Dial(SIP/${EXTEN:0}@provider)

to

exten => _0XXXXXXXX,1,Dial(SIP/${EXTEN:0}@provider)[/quote]

Out of curiousity, what is the difference between using {EXTEN:0} and just {EXTEN}. I have used {EXTEN} since I began using * about a year ago, but i notice that alot of people use {EXTEN:0}.


#6

I don’t think that there is a difference between {EXTEN} and {EXTEN:0}. I ended up using {EXTEN:0} because I started from examples that were using {EXTEN:2} to strip off leading digits.
But maybe I am wrong: I am very new to asterisk.


#7

I found a way around this problem:
extensions.conf

;context for the sip-clients (sjphone)
[intern-sip]
include => intern

;context for the misdn clients (analog phones behind duovox)
[intern-misdn]
exten => _.,1,SetVar(digits=${digits}${EXTEN})
exten => _.,2,GotoIf($["${repeat}" = "1"]?intern,${digits},1)
exten => _.,3,DigitTimeout,2                            ;small timeout so fast typing people get a connection quickly (but slow typing people get "invalid number" response)
exten => _.,4,SetVar(repeat=1)

[intern]
exten => _0.,1,Dial(SIP/${EXTEN:0}@provider)

exten => 31,1,Dial(misdn/1/31)
exten => 33,1,Dial(SIP/33)

When I now dial 0612345678 from the analog phone:

    -- Executing SetVar("mISDN/1", "digits=0") in new stack
    -- Executing GotoIf("mISDN/1", "0?intern|0|1") in new stack
    -- Executing DigitTimeout("mISDN/1", "2") in new stack
    -- Set Digit Timeout to 2
    -- Executing SetVar("mISDN/1", "repeat=1") in new stack
  == CDR updated on mISDN/1
    -- Executing SetVar("mISDN/1", "digits=0612345678") in new stack
    -- Executing GotoIf("mISDN/1", "1?intern|0612345678|1") in new stack
    -- Goto (intern,0612345678,1)
    -- Executing Dial("mISDN/1", "SIP/0612345678@provider") in new stack
    -- Called 0612345678@provider
    -- SIP/provider-7d48 is ringing
    -- SIP/provider-7d48 answered mISDN/1
  == Spawn extension (intern, 0612345678, 1) exited non-zero on 'mISDN/1'

Or if I dial 33:

    -- Executing SetVar("mISDN/1", "digits=3") in new stack
    -- Executing GotoIf("mISDN/1", "0?intern|3|1") in new stack
    -- Executing DigitTimeout("mISDN/1", "2") in new stack
    -- Set Digit Timeout to 2
    -- Executing SetVar("mISDN/1", "repeat=1") in new stack
  == CDR updated on mISDN/1
    -- Executing SetVar("mISDN/1", "digits=33") in new stack
    -- Executing GotoIf("mISDN/1", "1?intern|33|1") in new stack
    -- Goto (intern,33,1)
    -- Executing Dial("mISDN/1", "SIP/33") in new stack
    -- Called 33
    -- SIP/33-fba5 is ringing
  == Spawn extension (intern, 33, 1) exited non-zero on 'mISDN/1'

The solution is not very elegant, but it works.

Anyone suggestions how to do this in a more elegant way?


#8

Perhaps i’m missunderstanding what you want to achieve here, but why not just define the call contexts all individually?

I have the following contexts:

[statewide]
[auswide]
[ausmobile]
[auslocal]
[ausfree]
[internal]

They are all explicitly defined, then I just include the contexts to the user context depending on what permissions I want them to have. So someone can be given rights to local calls, but not mobile etc.


#9

I think that defining seperate context does not solve my problem.

The problem is that Asterisk starts to dial “06@provider” after I have typed these two digits (06) on my phone. But I was not finished typing yet: I wanted to dial 0623456789@provider…

This is called “Match-as-you-go” in the voip-wiki (http://www.voip-info.org/wiki-Asterisk+Extension+Matching). But the solution as described in the wiki does not seem to work here, which is strange of course. That is why I created this solution.