text
stringlengths
0
152
channel.
Most parameters have defaults, which you will find documented in the sample files.
Start with reading the pjsip.conf.sample file found in your ~/src/asterisk.<TAB>/
configs/samples/ folder. It will provide plenty of information about defaults, as well as
information about other resources worth reading. We will not use the file for the
actual configuration (we are using the database instead); however, the file is an excel‐
lent reference, and you should keep it near at hand, as it will have the answers to
many questions you may have about parameters.
We are going to focus on getting a basic device going for you as simply as possible.
We have found that setting up channels is one of the more frustrating things new
Asterisk users experience, and we want to demonstrate that at its most basic level, it
does not need to be painful at all. Once you have succeeded here, you’ll always have a
known-good configuration to fall back on, as you move forward into more complex
scenarios.
5 Put simply, you would need to find the pjsip.conf.sample file, and use it as a template to create a pjsip.conf file
in your /etc/asterisk folder, and then edit that file in a manner similar to how we’re going to do things in the
database.
6 Or in the .conf file, if you choose to go that route.
Configuring Asterisk
|
65
How Channel Configuration Works with the Dialplan
Channels are how Asterisk connects calls to everything outside of it, but it is the
dialplan that defines what happens to calls as they pass through the system. There‐
fore, channels and dialplan are inextricably linked. The dialplan is the heart of an
Asterisk system: it controls how call logic is applied to any connection, from any
channel, such as what happens when a device dials extension 101, or an incoming call
from an external provider is routed to a DID. The PJSIP channel configuration tables
in the database, plus the /etc/asterisk/extensions.conf file, will play a critical role in
most—if not all—calls routed through the system. Once you have your channels con‐
figured, you will find that most of your work will be in the dialplan. We will dive
deeply into this in upcoming chapters.
When a call comes into Asterisk, the identity of the incoming call is matched in the
channel configuration for the protocol in use (SIP connections are handled by the
PJSIP channel driver). The channel driver will handle authenticating the incoming
connection. The channel configuration also defines where that channel will enter the
dialplan.
Once Asterisk has determined how it will handle the channel (i.e., it’s authenticated
and the various parameters for the call have been established), it can pass call control
to the correct context in the dialplan. It is the context parameter in the ps_end
points table that tells the channel where the call will enter the dialplan (which con‐
tains all the information about how to handle and route the call).
In Figure 5-2, we see that the call flow through the configuration, for an internal call
(set-to-set), will look something like this:
1. User of set 0000f30A0A0101 dials 102.
2. Asterisk matches the incoming SIP request against an endpoint (and authenti‐
cates it).
3. The number dialed is matched to the [sets] context in the dialplan.
4. The Dial() application is used to send a call out a PJSIP channel, to the contact
associated with 0000f30B0B02.
5. The contact address is determined (typically based on registration if it’s a set, but
could be hardcoded as well if it is a trunk).
6. A SIP INVITE message is sent to the destination.
A key point to remember is that the channel configuration files control not only how
calls enter the system, but also how they leave the system. So, for example, if one set
calls another set, the channel configuration file is used not only to pass the call into
the dialplan, but also to direct the call out from the dialplan to the destination.
66
|
Chapter 5: User Device Configuration
Figure 5-2. Relationship of pjsip.conf to extensions.conf
chan_pjsip
The PJSIP channel module is one of the newer modules in Asterisk. It replaced the
original chan_sip module.
The old SIP module, chan_sip, has been deprecated, so we will not
be documenting it in this book. If you are new to Asterisk, you
should stick to PJSIP, but it may be helpful to understand that
chan_sip was around for many years, and is still widely used on
old systems.
The PJSIP framework, as implemented in Asterisk, is composed of many compo‐
nents. If you check your database, you will find that there are over a dozen tables
relating to PJSIP (prefixed with ps_). Not all of them relate to set configuration,
though.