Page 149 - Asterisk™: The Future of Telephony
P. 149
Context names have a maximum length of 79 characters (80 characters
–1 terminating null)
All of the instructions placed after a context definition are part of that context, until
the next context is defined. At the beginning of the dialplan, there are two special
contexts named [general] and [globals]. The [general] section contains a list of gen-
eral dialplan settings (which you’ll probably never have to worry about), and we will
discuss the [globals] context the “Global variables” section; for now it’s just important
to know that these two contexts are special. As long as you avoid the names [gen
eral] and [globals], you may name your contexts anything you like.
When you define a channel (which is how you connect things to the system), one of
the parameters that is defined in the channel definition is the context. In other words,
the context is the point in the dialplan where connections from that channel will begin.
Another important use of contexts (perhaps the most important) is to provide security.
By using contexts correctly, you can give certain callers access to features (such as long-
distance calling) that aren’t made available to others. If you don’t design your dialplan
carefully, you may inadvertently allow others to fraudulently use your system. Please
keep this in mind as you build your Asterisk system.
The doc/ subdirectory of the Asterisk source code contains a very im-
portant file named security.txt, which outlines several steps you should
take to keep your Asterisk system secure. It is vitally important that you
read and understand this file. If you ignore the security precautions
outlined there, you may end up allowing anyone and everyone to make
long-distance or toll calls at your expense!
If you don’t take the security of your Asterisk system seriously, you may
end up paying—literally! Please take the time and effort to secure your
system from toll fraud.
Extensions
In the world of telecommunications, the word extension usually refers to a numeric
identifier given to a line that rings a particular phone. In Asterisk, however, an extension
is far more powerful, as it defines a unique series of steps (each step containing an
application) that Asterisk will take that call through. Within each context, we can define
as many (or few) extensions as required. When a particular extension is triggered (by
an incoming call or by digits being dialed on a channel), Asterisk will follow the steps
defined for that extension. It is the extensions, therefore, that specify what happens to
calls as they make their way through the dialplan. Although extensions can certainly
be used to specify phone extensions in the traditional sense (i.e., extension 153 will
Dialplan Syntax | 121