[asterisk-users] Re: Match a Numer - then continue with dialplan

Douglas Garstang dgarstang at oneeighty.com
Wed Dec 20 12:06:10 MST 2006


> -----Original Message-----
> From: Tony Mountifield [mailto:tony at softins.clara.co.uk]
> Sent: Wednesday, December 20, 2006 11:47 AM
> To: asterisk-users at lists.digium.com
> Subject: [asterisk-users] Re: Match a Numer - then continue with
> dialplan
> 
> 
> In article 
> <645FEC31A18FE54A8721500CDD55A7B60350769C at mail.oneeighty.com>,
> Douglas Garstang <dgarstang at oneeighty.com> wrote:
> > 
> > Don't get offended Doug, but I get really frustrated when I 
> try to explain what I am trying
> > to do with Asterisk, and people don't seem to quite get it. 
> Your about the 4th person who's
> > replied to this post, and hasn't quite grasped my question. 
> :) <--- smiley.. see...we're all
> > cool.
> 
> Perhaps its the terminology you used that is confusing 
> people. See below:
> 
> > I don't want Asterisk to go on to ask for more digits. I 
> want to do a very simple thing. I
> > want to set a variable when call flow continues beyond a 
> certain point (without asking the
> > user for more digits), and then continue on, and use that 
> variable later. It's a very simple
> > thing, I can't work out why Asterisk doesn't let me do that.
> 
> To almost all people "call flow" would mean executing one 
> priority after
> another for a given extension.
> 
> After reading and re-reading your posts trying to work out 
> what you are
> trying to do, it seems to me that when *you* say "call flow", 
> you mean the
> act of trying to find an extension. And what your looking for 
> is a way to
> do things a different points in the *search*, while it is 
> still trying to
> decide on a statement to land on. Is that correct?
Yes to the first sentence. Not quite sure what you mean after that.

> 
> If so, I think you need to re-think the strategy a bit. The only way a
> command gets executed in a dialplan is when Asterisk has 
> matched an extension
> and a priority. Then once it has executed that command, it 
> increments the
> priority (unless it was a Goto or something) and starts 
> searching again.
That was my original question. I was asking if there was a way to set a variable and the continue, which doesn't seem like too strange a thing to have Asterisk support.

> 
> However, don't forget that it searches for matching 
> extensions every time
> the priority changes. You are not locked into a particular pattern or
> extension number from priority 1 onwards. You can mix and 
> match patterns
> with literal extensions, even across includes, e.g.
Don't follow you. When asterisk matches an extension, it starts interating through the priorities until there's none left, or you Goto() somewhere else.

> 
> [example]
> include => ctx31X
> include => ctx3XX
> 
> exten => _X.,1,NoOp(this gets executed first for everything)
> exten => _X.,2,NoOp(this gets executed second only if ctx31X 
> or ctx3XX didnt match)
> exten => _X.,3,NoOp(this gets executed third for everything)
You lost me here.

> 
> [ctx31X]
> exten => _31X,2,NoOp(this gets executed second for 310-319)
> 
> [ctx3XX]
> exten => _3XX,2,NoOp(this gets executed second for 300-309 
> and 320-399)


> 
> So you might be able to do something along these lines by 
> being creative
> with priorities and includes, and setting or testing 
> variables. Something
> along these lines:
> 
> 1. Each company starts off in its own context, and at 
Can't do that. The point at which a phone enters the dial plan needs to start with rather a long list of include=> statements, to grant/deny access to certain features.

> priority 1 in _X. it
> sets a variable like SRCCOMPANY to something specific to it.
> It includes all the destination contexts.
> 
> 2. Each destination context starts at priority 2 and sets a 
> variable like
> DESTCOMPANY to something specific to that destination.
> 
> 3. At priority 3 in each source context, SRCCOMPANY and 
> DESTCOMPANY are
> compared, in order to decide whether to override the CallerID with the
> source company's generic callerID. Let's say this uses priorities 3, 4
> and 5 (for the GotoIf doing the compare, then the SetCallerID, and the
> NoOp target for the GotoIf when the callerID doesn't need rewriting).
> The destination contexts do not have priorities 3, 4 and 5.
> 
> 4. The destination contexts continue at priority 6 to route the call.
> 
> I think by interleaving priorities between contxts like this 
> you should
> be able to achieve what you are looking for. Please let us 
> know on the list
> if you are successful - it encourages us to keep helping in 
> the future!

I tried your example, which I completely don't follow, and it didn't seem to execute as you expected.
Dialling 311 yields:

*CLI> 
    -- Executing NoOp("SIP/3254101-d10e", "this gets executed first for everything") in new stack
    -- Executing NoOp("SIP/3254101-d10e", "this gets executed second only if ctx31X or ctx3XX didnt match") in new stack
    -- Executing NoOp("SIP/3254101-d10e", "this gets executed third for everything") in new stack

I need to make extensive use of the include=> directive, and I just can't see how getting stuck in priorities within an extension is going to allow me to do that.

Doug.



More information about the asterisk-users mailing list