[asterisk-dev] Endpoints vs Extensions

Matthew Jordan mjordan at digium.com
Fri Aug 22 09:30:48 CDT 2014


On Fri, Aug 22, 2014 at 8:55 AM, Chris Bestall <chris.bestall at gmail.com> wrote:
> I'm sorry if this has been asked before, but I've googled and not found much
> in the way of help.

Just as an FYI, you may want to e-mail these kinds of questions to the
asterisk-app-dev mailing list.

We've also started doing a major documentation push for ARI on the
Asterisk wiki [1] - hopefully we'll get more of these kinds of
questions answered via those pages.

> I'm using Asterisk 12 and the new PJSIP driver.  I'm also trying to use ARI
> to originate a call.
>
> What I'm confused by is the difference between an endpoint and an extension.
> When I use the ARI to originate a call I am required to pass in an endpoint.
> Do extensions even matter on outgoing calls when using PJSIP?

There's a number of terminology definitions that are colliding here.
>From the perspective of ARI and the dialplan, the PJSIP channel driver
doesn't really have anything to do with this. So the following is more
of an answer to "What is an endpoint when creating a channel through
ARI".

An extension is a dialplan concept. It is generally a specific
location in a context, where its full addressable address is a tuple
of context, extension, priority.

When you are using ARI, you have channels that have been handed to you
from the dialplan. You exist as an application within the dialplan -
since the Stasis dialplan application handed you the channels - but
you aren't constrained by the dialplan. You can do whatever you want
with those channels, and don't have to do so within the constraints of
dialplan execution.

So, an endpoint - from the perspective of ARI - is some identifier
that a channel driver will understand as the thing that can have a
path of communication between itself and Asterisk. That could be a
chan_sip peer, it could be a chan_pjsip endpoint. It could even be a
location in the dialplan, i.e., extension, via a Local channel. So
when the POST /channels documentation [2] says:

"endpoint: string - (required) Endpoint to call."

that means it wants your dial string.

You could create a channel directly to a chan_sip peer:

POST /channels?endpoint=SIP/alice&app=my_awesome_app

Or to a chan_pjsip endpoint:

POST /channels?endpoint=PJSIP/alice&app=my_awesome_app

Or, like I said, you could create a path between your ARI app and
something else in the dialplan. In this case, the "endpoint" is the
location in the dialplan you're creating a channel to:

POST /channels?endpoint=Local/1000 at default&app=my_awesome_app

Or you could go really nutty and decide your app doesn't event want
the channel! Instead, you can just spawn channels out into the
dialplan and ignore them from there on:

POST /channels?endpoint=PJSIP/trunk/sip:alice at my_provider.net&context=default&extension=1000&priority=1

Note that in this case, my "endpoint" from ARI's perspective is
PJSIP/trunk/sip:alice at my_provider.net, which is dialling a SIP URI
through the PJSIP endpoint "trunk". What an endpoint is depends on the
frame of reference.

I answered a similar question a few days ago here:

http://lists.digium.com/pipermail/asterisk-dev/2014-August/069880.html

> I have a follow up question as well.
>
> I'm trying to use flowroute to perform outgoing calls.  I need to include a
> prefix when calling.  Can this done be done with endpoints via config or do
> I have to include the prefix each time I enter the endpoint?

What do you mean by prefix? An example of what flowroute is looking
for would help here.

[1] https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=29395573
[2] https://wiki.asterisk.org/wiki/display/AST/Asterisk+12+Channels+REST+API#Asterisk12ChannelsRESTAPI-originate

Matt

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org



More information about the asterisk-dev mailing list