[Asterisk-Dev] Dialplan syntax changes.. Option: work on a radically different design..

Steve Kann stevek at stevek.com
Wed May 18 07:40:29 MST 2005


Here's my opinion, as an observer (personally, most of this doesn't 
matter much to me at the moment, as my dialplans are stunningly simple, 
mostly because I handle most things via FastAGI).

Taking a step back, and re-examining the problem..

[I'll do a rumsfeld-style ask myself questions and answer them thing here]:

What is the dialplan?  It's really a procedural language, it seems.

Do we already have well defined syntax(es) that would fit?

Sure we do -- and most of them stem from the syntax of C in one way or 
another.

So, can it make sense to make the Dialplan look more like C?

I think it does.

Here's an example (based on some stuff in configs/extensions.conf.sample

==== snip ====

  static=yes
  writeprotect=no
  autofallthrough=yes

CONSOLE=Console/dsp                             ; Console interface for demo
;CONSOLE=Zap/1
;CONSOLE=Phone/phone0
IAXINFO=guest                                   ; IAXtel username/password
;IAXINFO=myuser:mypass
TRUNK=Zap/g2                                    ; Trunk interface


macro LocalDial (dialed) {
    Dial($dialed);
    switch($?) {
    }
    return something;
}

context mycontext {
    extension 2125551212 () {
          Dial(SIP/Grandstream1,DIAL_RINGBACK|DIAL_ARGUMENT)
          switch ($?) {
             case NOANSWER {
                2125551333 ();
             }
             case CONGESTION {
                Play(busy);
             }
             default {}
         }          
    }
    extension _212555XXXX () {
          Dial(Local/$EXTEN);
    }
}
============

I think that we could get together and define a grammar for this, parse 
it with yacc/lex, etc. 

There was lots of talk about the "pluggable PBX" concept earlier, on dev 
chats, etc.  I think if you're going to break everyone's dialplans 
anyway, you might as well really break them, and do it right.

It seems like what's happening here is that we're making the language 
look like spreadsheet expressions..

I'm surely oversimplifying the problem here, in at least two ways:

1) The dialplan is not only looked at as calls pass through it, but it 
is also consulted to determine the existence of extensions and pattern 
matching.

2) The dialplan was originally designed to be modifiable at run-time, 
where you could, e.g. change things in the CLI, and then have asterisk 
spit out the new dialplan.  But you can't do that now anyway.

-SteveK




More information about the asterisk-dev mailing list