4 years agocodecs: Add Codec 2 mode 2400.
Alexander Traud [Tue, 19 Jul 2016 18:14:21 +0000 (20:14 +0200)]
codecs: Add Codec 2 mode 2400.

ASTERISK-26217 #close

Change-Id: I1e45d8084683fab5f2b272bf35f4a149cea8b8d6

4 years agoMerge "pbx: Create pbx_include.c for management of 'struct ast_include'."
Joshua Colp [Mon, 18 Jul 2016 12:07:36 +0000 (07:07 -0500)]
Merge "pbx: Create pbx_include.c for management of 'struct ast_include'."

4 years agoMerge "app_queue: Only remove queue member from pending when state changes."
zuul [Fri, 15 Jul 2016 16:57:52 +0000 (11:57 -0500)]
Merge "app_queue: Only remove queue member from pending when state changes."

4 years agopbx: Create pbx_include.c for management of 'struct ast_include'.
Corey Farrell [Thu, 14 Jul 2016 18:51:42 +0000 (14:51 -0400)]
pbx: Create pbx_include.c for management of 'struct ast_include'.

This changes context includes from a linked list to a vector, makes
'struct ast_include' opaque to pbx.c.

Although ast_walk_context_includes is maintained the procedure is no
longer efficient except for the first call (inc==NULL).  This
functionality is replaced by two new functions implemented by vector
* ast_context_includes_count (AST_VECTOR_SIZE)
* ast_context_includes_get (AST_VECTOR_GET)

As with ast_walk_context_includes callers of these functions are
expected to have locked contexts.  Only a few places in Asterisk walked
the includes, they have been converted to use the new functions.

const have been applied where possible to parameters for ast_include

Change-Id: Ib5c882e27cf96fb2aec67a39c18b4c71c9c83b60

4 years agofeatures.c: Remove unneeded adsi.h include.
Corey Farrell [Thu, 14 Jul 2016 08:25:43 +0000 (04:25 -0400)]
features.c: Remove unneeded adsi.h include.

adsi.h is no longer used by features.c since parking was moved to a

Change-Id: I2248b8a455225a17cb6ddaafd6c20c511a1eaf59

4 years agoUpdate support for SILK format.
Mark Michelson [Thu, 30 Jun 2016 20:58:53 +0000 (15:58 -0500)]
Update support for SILK format.

This commit adds scaffolding in order to support the SILK audio format
on calls. Roughly, this is what is added:

* Cached silk formats. One for each possible sample rate.
* ast_codec structures for each possible sample rate.
* RTP payload mappings for "SILK".

In addition, this change overhauls the res_format_attr_silk file in the
following ways:

* The "samplerate" attribute is scrapped. That's native to the format.
* There are far more checks to ensure that attributes have been
  allocated before attempting to reference them.
* We do not SDP fmtp lines for attributes set to 0.

These changes make way to be able to install a codec_silk module and
have it actually work. It also should allow for passthrough silk calls
in Asterisk.

Change-Id: Ieeb39c95a9fecc9246bcfd3c45a6c9b51c59380e

4 years agoMerge "translate: explicit format destination not properly set"
zuul [Thu, 14 Jul 2016 18:40:43 +0000 (13:40 -0500)]
Merge "translate: explicit format destination not properly set"

4 years agoMerge "threadpool: Fix leak in ast_threadpool_serializer_group error path."
zuul [Thu, 14 Jul 2016 18:33:52 +0000 (13:33 -0500)]
Merge "threadpool: Fix leak in ast_threadpool_serializer_group error path."

4 years agoMerge "pbx: Fix leak of timezone for time based includes."
zuul [Thu, 14 Jul 2016 17:14:44 +0000 (12:14 -0500)]
Merge "pbx: Fix leak of timezone for time based includes."

4 years agoMerge "BuildSystem: Avoid obsolete warning with pthread.m4 on autoconf."
zuul [Thu, 14 Jul 2016 17:05:19 +0000 (12:05 -0500)]
Merge "BuildSystem: Avoid obsolete warning with pthread.m4 on autoconf."

4 years agoMerge "res_rtp_asterisk: Enable Forward Secrecy (PFS) for DTLS."
Joshua Colp [Thu, 14 Jul 2016 15:32:54 +0000 (10:32 -0500)]
Merge "res_rtp_asterisk: Enable Forward Secrecy (PFS) for DTLS."

4 years agoMerge "stasis_endpoint.c: Fix contactstatus_to_json()."
zuul [Thu, 14 Jul 2016 14:37:00 +0000 (09:37 -0500)]
Merge "stasis_endpoint.c: Fix contactstatus_to_json()."

4 years agoMerge "pjsip_options.c: Fix container operation."
zuul [Thu, 14 Jul 2016 13:37:06 +0000 (08:37 -0500)]
Merge "pjsip_options.c: Fix container operation."

4 years agoMerge "pjsip_configuration.c: Misc cleanups."
zuul [Thu, 14 Jul 2016 13:37:05 +0000 (08:37 -0500)]
Merge "pjsip_configuration.c: Misc cleanups."

4 years agoapp_queue: Only remove queue member from pending when state changes.
Joshua Colp [Thu, 14 Jul 2016 12:45:10 +0000 (09:45 -0300)]
app_queue: Only remove queue member from pending when state changes.

It is possible for a not in use state change to occur multiple
times causing a queue member to be removed from the pending call
container prematurely.

The first not in use state change will remove the queue member
from the container. At this moment the member may be called and
placed in the pending container. After this another not in use
state change can be received which will remove it from the
container. Despite being called at this point the code will
incorrectly see that there are no pending calls to it.

This change only removes it from the pending container if the
state has actually changed.

ASTERISK-26133 #close
  app_queue.diff submitted by Richard Miller (license 5685)

Change-Id: Ie5a7f17a44f98e9159e9b85009ce3f8393aa78c0

4 years agoMerge "chan_sip: Fix reference leak in mwi_event_cb"
Joshua Colp [Thu, 14 Jul 2016 09:54:48 +0000 (04:54 -0500)]
Merge "chan_sip: Fix reference leak in mwi_event_cb"

4 years agopbx: Fix leak of timezone for time based includes.
Corey Farrell [Thu, 14 Jul 2016 07:40:26 +0000 (03:40 -0400)]
pbx: Fix leak of timezone for time based includes.

Create include_free to run ast_destroy_timing and ast_free, use that in
all places that freed an ast_include structure.  This fixes a couple of
paths that previously did not run ast_destroy_timing.

ASTERISK-26196 #close

Change-Id: I1671bd111bef0dc113e8bf8f77f89fcfc395d838

4 years agoMerge "res/res_corosync: Raise a Stasis message on node join/leave events"
zuul [Thu, 14 Jul 2016 03:11:40 +0000 (22:11 -0500)]
Merge "res/res_corosync: Raise a Stasis message on node join/leave events"

4 years agoMerge "res/res_pjsip_session: Check for presence of an active negotiator"
zuul [Wed, 13 Jul 2016 23:48:39 +0000 (18:48 -0500)]
Merge "res/res_pjsip_session: Check for presence of an active negotiator"

4 years agotranslate: explicit format destination not properly set
Kevin Harwell [Wed, 13 Jul 2016 22:45:27 +0000 (17:45 -0500)]
translate: explicit format destination not properly set

If the destination format's name differed from the codec name then the
translator's explict_dst field would be improperly set. In some circumstances
it would end up setting it to a newly created format that has the same name
as the codec when it actually needed to be the given destination codec.

This could cause the translation path to use the wrong format. For instance,
if an endpoint had specified 'myulaw' as a format the translator could end up
using a 'ulaw' format (with whatever/default settings) instead. If the format
attribute settings differed between the two then there may unexpected results
during processing.

This patch removes the name check when building the translation path. This
should make it always set the translator's explicit_dst to the given destination
format as long as the sample rate and types match.

Change-Id: Iaf8a03831d68e657d89569d54b505074efbefab5

4 years agostasis_endpoint.c: Fix contactstatus_to_json().
Richard Mudgett [Fri, 8 Jul 2016 16:46:04 +0000 (11:46 -0500)]
stasis_endpoint.c: Fix contactstatus_to_json().

The roundtrip_usec json member is optional.  If it isn't present then
don't put it into the converted json structure where ast_json_pack()
will choke on it.

Change-Id: I39bb2f86154ef54591270c58bfda8635070f9ea0

4 years agopjsip_options.c: Fix container operation.
Richard Mudgett [Mon, 11 Jul 2016 15:22:35 +0000 (10:22 -0500)]
pjsip_options.c: Fix container operation.

aor_observer_deleted() needs to operate on all contacts found for the
deleted AOR instead of only the first one found.  This is really only a
problem if there is more than one contact for the AOR.

Change-Id: Id24ac0d5e8c931330231fb45dd2a331a84339dc1

4 years agopjsip_configuration.c: Misc cleanups.
Richard Mudgett [Mon, 11 Jul 2016 15:21:35 +0000 (10:21 -0500)]
pjsip_configuration.c: Misc cleanups.

* Fix some whitespace in various routines.

* Rename i to iter in persistent_endpoint_update_state().

* Fix off-nominal copy/paste message wording in

Change-Id: Id8e34f5d09e7eebac3af22501c44c1110a3e29d8

4 years agochan_sip: Fix reference leak in mwi_event_cb
Corey Farrell [Wed, 13 Jul 2016 18:45:07 +0000 (14:45 -0400)]
chan_sip: Fix reference leak in mwi_event_cb

Cleanup the peer reference when stasis_subscription_final_message is
true.  Also free peer_name even if peer exists, after reload a new
peer_name will be allocated.

ASTERISK-26193 #close

Change-Id: If7ecd52facdc5c227f701c760841e3f6ca53cc69

4 years agothreadpool: Fix leak in ast_threadpool_serializer_group error path.
Corey Farrell [Wed, 13 Jul 2016 16:30:58 +0000 (12:30 -0400)]
threadpool: Fix leak in ast_threadpool_serializer_group error path.

ast_threadpool_serializer_group leaks a reference to ser when listener
is allocated but tps is not.  Although listener takes the reference to
ser cleanup functions are not run without tps.

ASTERISK-26191 #close

Change-Id: Ie3ccf69a3f1e676c2ef62a77067c0cb57dc9a585

4 years agores_rtp_asterisk: Enable Forward Secrecy (PFS) for DTLS.
Alexander Traud [Wed, 22 Jun 2016 12:13:39 +0000 (14:13 +0200)]
res_rtp_asterisk: Enable Forward Secrecy (PFS) for DTLS.

Since July 2014, TLS based protocols (SIP over TLS, Secure WebSockets, HTTPS)
support PFS thanks to ASTERISK-23905. In July 2015, the same feature was added
for DTLS. The source code from main/tcptls.c should have been re-used to ease
security audits. Therefore, this change rolls back the change from July 2015 and
re-uses the code from July 2014. This has the additional benefits to work under
CentOS 7 and enabling not just ECDHE but DHE based cipher suites as well.

ASTERISK-25659 #close
Reported by: StefanEng86, urbaniak, pay123
Tested by: sarumjanuch, traud
res_rtp_asterisk.patch submitted by sarumjanuch
dtls_centos_step_1.patch submitted by traud
dtls_centos_step_2.patch submitted by traud

Change-Id: I537cadf4421f092a613146b230f2c0ee1be28d5c

4 years agores/res_pjsip_session: Check for presence of an active negotiator
Matt Jordan [Sat, 25 Jun 2016 00:55:09 +0000 (19:55 -0500)]
res/res_pjsip_session: Check for presence of an active negotiator

It is possible in a hypothetical situation for a session refresh to be
invoked on a PJSIP when the negotiatior on the INVITE session has not
yet been established. While this shouldn't occur with existing uses of
ast_sip_session_refresh, the crashes that occur due to improperly
calling PJSIP functions that expect a non-NULL negotiatior are
avoidable. PJSIP will create the negotiator in pjsip_inv_reinvite; this
means that simply checking for the presence of the negotiator before
passing it to other PJSIP functions that use it is allowable. As such,
this patch adds checks for the presence of the negotiator before calling
PJSIP functions that assume it is non-NULL.

Change-Id: I1028323e7e01b0a531865e5412a71b6f6ec4276d

4 years agores/res_pjsip_pubsub: Add additional debug statements
Matt Jordan [Mon, 19 Oct 2015 23:55:58 +0000 (18:55 -0500)]
res/res_pjsip_pubsub: Add additional debug statements

When something very sad and wrong occurs, it's challenging sometimes to
figure out why. This patch adds some additional debug statements on
off-nominal paths to try and make debugging easier.

Change-Id: I7bffb73cc733b6f80193a23340881db4a102b640

4 years agores/res_corosync: Raise a Stasis message on node join/leave events
Matt Jordan [Mon, 19 Oct 2015 23:55:33 +0000 (18:55 -0500)]
res/res_corosync: Raise a Stasis message on node join/leave events

When res_corosync detects that a node leaves or joins, it currently is
informed of this via Corosync callbacks. However, there are a few
limitations with the information presented:
(1) While we have information that Corosync is aware of - such as the
    Corosync nodeid - that information is really only useful inside of
    Corosync or res_corosync. There's no way to translate a Corosync
    nodeid to some other internally useful unique identifier for the
    Asterisk instance that just joined or left the cluster.
(2) While res_corosync is notified of the instance joining or leaving
    the cluster, it has no mechanism to inform the Asterisk core or
    other modules of this event. This limits the usefulness of res_corosync
    as a heartbeat mechanism for other modules.

This patch addresses both issues.

First, it adds the notion of a cluster discovery message both within the
Stasis message bus, as well as the binary event messages that
res_corosync uses to transmit data back and forth within the cluster.
When Asterisk joins the cluster, it sends a discovery message to the other
nodes in the cluster, which correlates the Corosync nodeid along with
the Asterisk EID. res_corosync now maintains a hash of Corosync nodeids
to Asterisk EIDs, such that it can map changes in cluster state with the
Asterisk instance that has that nodeid. Likewise, when an Asterisk
instance receives a discovery message from a node in the cluster, it now
sends its own discovery message back to the originating node with the
local Asterisk EID. This lets Asterisk instances within the cluster
build a complete picture of the other Asterisk instances within the

Second, it publishes the discovery messages onto the Stasis message bus.
Said messages are published whenever a node joins or leaves the cluster.
Interested modules can subscribe for the ast_cluster_discovery_type()
message under the ast_system_topic() and be notified when changes in
cluster state occur.

Change-Id: I9015f418d6ae7f47e4994e04e18948df4d49b465

4 years agoBuildSystem: Avoid obsolete warning with pthread.m4 on autoconf.
Alexander Traud [Wed, 13 Jul 2016 13:57:08 +0000 (15:57 +0200)]
BuildSystem: Avoid obsolete warning with pthread.m4 on autoconf.

Updated the macro-set autoconf/ax_pthread.m4 to its latest upstream version.

ASTERISK-26046 #close

Change-Id: I11abc11d17acd2b6a8a5a5be8ae8e0949dab9cc7

4 years agoMerge "rest_api/channels: Fix multiple issues with create and dial"
zuul [Wed, 13 Jul 2016 13:08:41 +0000 (08:08 -0500)]
Merge "rest_api/channels:  Fix multiple issues with create and dial"

4 years agoMerge "res_pjsip: Fix statsd regression."
Joshua Colp [Wed, 13 Jul 2016 12:41:47 +0000 (07:41 -0500)]
Merge "res_pjsip: Fix statsd regression."

4 years agoMerge "BuildSystem: Allow own CFLAGS on ./configure."
Joshua Colp [Wed, 13 Jul 2016 11:42:57 +0000 (06:42 -0500)]
Merge "BuildSystem: Allow own CFLAGS on ./configure."

4 years agoMerge "install_prereq: Checkout of libSRTP 1.5.x."
Joshua Colp [Wed, 13 Jul 2016 00:30:38 +0000 (19:30 -0500)]
Merge "install_prereq: Checkout of libSRTP 1.5.x."

4 years agoMerge "chan_sip: Fix reference leaks in error paths."
Joshua Colp [Tue, 12 Jul 2016 23:49:13 +0000 (18:49 -0500)]
Merge "chan_sip: Fix reference leaks in error paths."

4 years agoMerge "res_sorcery_realtime: fix bug when successful UPDATE is treated as failed"
Joshua Colp [Tue, 12 Jul 2016 22:43:45 +0000 (17:43 -0500)]
Merge "res_sorcery_realtime: fix bug when successful UPDATE is treated as failed"

4 years agoMerge "res_pjsip: Added "subscribe_context" to endpoint"
Joshua Colp [Tue, 12 Jul 2016 22:14:23 +0000 (17:14 -0500)]
Merge "res_pjsip: Added "subscribe_context" to endpoint"

4 years agoMerge "BuildSystem: Avoid obsolete warning with libcurl.m4 on autoconf."
Joshua Colp [Tue, 12 Jul 2016 21:04:55 +0000 (16:04 -0500)]
Merge "BuildSystem: Avoid obsolete warning with libcurl.m4 on autoconf."

4 years agorest_api/channels: Fix multiple issues with create and dial
George Joseph [Tue, 12 Jul 2016 01:07:20 +0000 (19:07 -0600)]
rest_api/channels:  Fix multiple issues with create and dial

* We weren't properly subscribing to the channel and it's originator
  on create.
* We weren't doing a publish_dial after calling ast_call on dial.
* We weren't calling depart_bridge when a channel left the dial bridge.

The first 2 issues were causing events to not be generated and the third
was actually causing channels to not get properly destroyed when hung up.

Together these 3 issues were causing the new
rest_apichannels/create_dial_bridge tests to fail.

As a result of the fixes, the cdr state machine had to be slightly
tweaked to allow bridge leave events without asserting and the tests
themselves had to be updated to account for the channels now cleaning
themselves up.

Change-Id: Ibf23abf5a62de76e82afb4461af5099c961b97d8

4 years agores_pjsip: Fix statsd regression.
Richard Mudgett [Mon, 11 Jul 2016 15:25:04 +0000 (10:25 -0500)]
res_pjsip: Fix statsd regression.

The ASTERISK-25904 change-id I8fad8aae9305481469c38d2146e1ba3a56d3108f
patch introduced several regressions when the newly created "Updated"
state goes out for each endpoint registration refresh.

1) It restarted any OPTIONS RTT ping cycle.

2) It would interfere with a currently active ping and throw off that
ping's resulting RTT calculation.

3) It cleared the RTT time each time the endpoint was refreshed.

4) The cleared RTT time was sent out as a statsd update each time.

5) It created two AMI events for each update.

* Revert the original patch and reimplement it.  Now the current contact
status state is re-sent instead of the state being momentarily toggled
every time the endpoint refreshes its registration.  The statsd events are
not created for the re-sent refresh because they are sent after every

ASTERISK-26160 #close
Reported by: Matt Jordan

Change-Id: Ie072be790fbb2a8f5c1c874266e4143fa31f66d1

4 years agofunc_odbc: Fix connection deadlock.
Joshua Colp [Mon, 11 Jul 2016 00:08:28 +0000 (21:08 -0300)]
func_odbc: Fix connection deadlock.

The func_odbc module was modified to ensure that the
previous behavior of using a single database connection
was maintained. This was done by getting a single database
connection and holding on to it. With the new multiple
connection support in res_odbc this will actually starve
every other thread from getting access to the database as
it also maintains the previous behavior of having only
a single database connection.

This change disables the func_odbc specific behavior if
the res_odbc module is running with only a single database
connection active. The connection is only kept for the
duration of the request.

ASTERISK-26177 #close

Change-Id: I9bdbd8a300fb3233877735ad3fd07bce38115b7f

4 years agoBuildSystem: Allow own CFLAGS on ./configure.
Alexander Traud [Tue, 12 Jul 2016 08:50:22 +0000 (10:50 +0200)]
BuildSystem: Allow own CFLAGS on ./configure.

Before this change, make failed with the error
Unknown value '' found in build_tools/menuselect-deps for NATIVE_ARCH
when CFLAGS were supplied to the configure script. This was introduced with
<> which disabled BUILD_NATIVE when
CFLAGS were supplied. Those who need different -march= values, please, go for
make menuselect.makeopts or make menuselect
./menuselect/menuselect --disable BUILD_NATIVE

ASTERISK-25289 #close

Change-Id: Ic6365d5a97bb9b3556858f06432a8d1cfa83eebc

4 years agoast_expr2: Fix off-nominal memory leak.
Richard Mudgett [Mon, 11 Jul 2016 18:42:55 +0000 (13:42 -0500)]
ast_expr2: Fix off-nominal memory leak.

Thanks to ibercom for pointing out a memory leak that was missed
in the earlier patch for the issue.

Reported by: Alexei Gradinari

Change-Id: I9a151f5c4725d97fb82a9e938bc73dc659532b71

4 years agoinstall_prereq: Checkout of libSRTP 1.5.x.
Alexander Traud [Mon, 11 Jul 2016 15:17:47 +0000 (17:17 +0200)]
install_prereq: Checkout of libSRTP 1.5.x.

Since 5th November 2014, the master branch of libSRTP changed the prefix of
several member names and is not compatible with the source code in Asterisk
anymore. Therefore instead, this change checks out the latest version of the
libSRTP 1.5.x branch. Furthermore now, libSRTP is compiled with OpenSSL as
backend. This makes AES-GCM and AES-IN possible.

ASTERISK-22131 #close

Change-Id: I2e396cdc01da0ff610686e398ed210ca7408f7d6

4 years agochan_sip: Fix reference leaks in error paths.
Corey Farrell [Sat, 9 Jul 2016 18:32:27 +0000 (14:32 -0400)]
chan_sip: Fix reference leaks in error paths.

* get_sip_pvt_from_replaces leaks sip_pvt_ptr on any error.
* build_peer leaks peer on failure to allocate the endpoint.

This patch fixes get_sip_pvt by using an RAII_VAR, build_peer is fixed
with an unref in the appropriate place.

ASTERISK-26184 #close

Change-Id: I728b424648ad041409f7d90880f4c28b3ce2ca12

4 years agoMerge "chan_sip/res_pjsip_t38: Handle a request to negotiate T.38 after it is enabled."
Joshua Colp [Fri, 8 Jul 2016 20:21:35 +0000 (15:21 -0500)]
Merge "chan_sip/res_pjsip_t38: Handle a request to negotiate T.38 after it is enabled."

4 years agoMerge "REF_DEBUG: Prevent logging of container node objects."
Joshua Colp [Fri, 8 Jul 2016 12:09:25 +0000 (07:09 -0500)]
Merge "REF_DEBUG: Prevent logging of container node objects."

4 years agoREF_DEBUG: Prevent logging of container node objects.
Corey Farrell [Thu, 7 Jul 2016 17:44:39 +0000 (13:44 -0400)]
REF_DEBUG: Prevent logging of container node objects.

Using AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE can result in an unref being
recorded to the refs log for the node being replaced.  This prevents
logging of those unrefs since they would produce errors in

ASTERISK-26181 #close

Change-Id: Ie4fded84e8a1a58b3a59ce59dfd7eb0da3ddc5d4

4 years agores_sorcery_realtime: fix bug when successful UPDATE is treated as failed
Alexei Gradinari [Mon, 4 Jul 2016 21:38:57 +0000 (17:38 -0400)]
res_sorcery_realtime: fix bug when successful UPDATE is treated as failed

If the SQL UPDATE statement changes nothing then SQLRowCount returns 0.
This value should be treated as success.
But the function sorcery_realtime_update treats it as failed.

This bug was found using stress tests on PJSIP.
If there are 2 consecutive SIP REGISTER requests with the same contact data
during 1 second then res_pjsip_registrar adds contact location on 1st request
and tries to update contact location on 2nd.
The update fails and res_pjsip_registrar even removes correct contact location.

The test "object_update_uncreated" was removed from test_sorcery_realtime.c
because it's now a valid situation.

This patch also adds missing debug of extra SQL parameter.

ASTERISK-26172 #close

Change-Id: I05a7f3051455336c9dda29efc229decf86071303

4 years agochan_sip/res_pjsip_t38: Handle a request to negotiate T.38 after it is enabled.
Joshua Colp [Thu, 7 Jul 2016 15:38:45 +0000 (12:38 -0300)]
chan_sip/res_pjsip_t38: Handle a request to negotiate T.38 after it is enabled.

Some T.38 implementations may send another re-invite after the initial
one which adds additional negotiation details (such as the max bitrate).
Currently this will fail when passthrough is being done in chan_sip as we
do nothing if T.38 is already active.

Other handlers of T.38 inside of Asterisk (such as res_fax) handle this
scenario so this change adds support for it to chan_sip and res_pjsip_t38.
If a request to negotiate is received while T.38 is already enabled a
new re-INVITE is sent and negotiation is done again.

ASTERISK-26179 #close

Change-Id: I0298494d3da6df3219bbfa4be9aa04015043145c

4 years agoPJSIP: provide valid tcp nodelay option for reuse
Scott Griepentrog [Thu, 7 Jul 2016 15:55:42 +0000 (10:55 -0500)]
PJSIP: provide valid tcp nodelay option for reuse

When using TCP transport with chan_pjsip, the TCP_NODELAY
option value was allocated on the stack, then passed as a
pointer to the tcp transport configuration structure, and
later re-used on subsequently created sockets when it was
no longer valid.  This patch changes the allocation to be
a static.

ASTERISK-26180 #close
Reported by: Scott Griepentrog

Change-Id: I3251164c7f710dbdab031282f00e30a9770626a0

4 years agores_pjsip: Added "subscribe_context" to endpoint
Alexei Gradinari [Wed, 6 Jul 2016 14:29:27 +0000 (10:29 -0400)]
res_pjsip: Added "subscribe_context" to endpoint

If specified, incoming SUBSCRIBE requests will be searched for the matching
extension in the indicated context. If no "subscribe_context" is specified,
then the "context" setting is used.

ASTERISK-25471 #close

Change-Id: I3fb7a15f5bc154079bd348c08b7ad1cdd2d5e514

4 years agoBuildSystem: Avoid obsolete warning with libcurl.m4 on autoconf.
Alexander Traud [Mon, 4 Jul 2016 10:58:39 +0000 (12:58 +0200)]
BuildSystem: Avoid obsolete warning with libcurl.m4 on autoconf.

Updated the macro-set autoconf/libcurl.m4 to its latest upstream version. This
avoids a warning about an obsolete macro on AC_HELP_STRING, because Asterisk is
using AS_HELP_STRING everywhere else already.


Change-Id: I8299faf504ceaeee3e39930c59293809e116c631

4 years agoMerge "res_pjsip_session.c: Don't send extra BYE if SDP invalid."
Joshua Colp [Fri, 1 Jul 2016 16:37:03 +0000 (11:37 -0500)]
Merge "res_pjsip_session.c: Don't send extra BYE if SDP invalid."

4 years agoMerge "res_pjsip_session.c: End call on initial invalid SDP negotiation."
Joshua Colp [Fri, 1 Jul 2016 16:36:58 +0000 (11:36 -0500)]
Merge "res_pjsip_session.c: End call on initial invalid SDP negotiation."

4 years agoMerge "res_pjsip.c: Register PJMEDIA error code decoder."
Joshua Colp [Fri, 1 Jul 2016 16:36:53 +0000 (11:36 -0500)]
Merge "res_pjsip.c: Register PJMEDIA error code decoder."

4 years agoMerge "res_pjsip_session.c: Remove unused parameter from handle_incoming()."
Joshua Colp [Fri, 1 Jul 2016 16:36:48 +0000 (11:36 -0500)]
Merge "res_pjsip_session.c: Remove unused parameter from handle_incoming()."

4 years agoMerge "res_pjsip: Add missing NULL checks when using pjsip_inv_end_session()."
Joshua Colp [Fri, 1 Jul 2016 16:36:42 +0000 (11:36 -0500)]
Merge "res_pjsip: Add missing NULL checks when using pjsip_inv_end_session()."

4 years agoMerge "features: Fix channel datastore access."
zuul [Fri, 1 Jul 2016 16:12:48 +0000 (11:12 -0500)]
Merge "features: Fix channel datastore access."

4 years agoMerge "res_pjsip: improve realtime performance #2"
Joshua Colp [Thu, 30 Jun 2016 20:53:24 +0000 (15:53 -0500)]
Merge "res_pjsip: improve realtime performance #2"

4 years agores_pjsip_session.c: Don't send extra BYE if SDP invalid.
Richard Mudgett [Wed, 22 Jun 2016 22:26:38 +0000 (17:26 -0500)]
res_pjsip_session.c: Don't send extra BYE if SDP invalid.

When an answer SDP is invalid we were disconnecting the outgoing call and
sending two BYE requests.  The first BYE was sent by PJPROJECT because of
the invalid SDP answer.  The second BYE was sent by Asterisk because it
thought the canceled call was the result of the RFC5407 section 3.1.2 race

* Made not send the BYE on a canceled session if the SDP negotiation is
incomplete because PJPROJECT has already sent a BYE for the failed

ASTERISK-25772 #close
Reported by:  Dmitriy Serov

Change-Id: I44ad0bd0605e8eeb7035c890d6f97a1331f1a836

4 years agores_pjsip_session.c: End call on initial invalid SDP negotiation.
Richard Mudgett [Mon, 27 Jun 2016 22:19:08 +0000 (17:19 -0500)]
res_pjsip_session.c: End call on initial invalid SDP negotiation.

When an incoming call defers SDP negotiation and then sends us an invalid
SDP in the ACK, we need to send a BYE to disconnect the call.  In this
case SDP negotiation has failed and we don't have valid media streams


Change-Id: Ia358516b0fc1e6c4c139b78246f10b9da7a2dfb8

4 years agores_pjsip.c: Register PJMEDIA error code decoder.
Richard Mudgett [Thu, 23 Jun 2016 20:13:24 +0000 (15:13 -0500)]
res_pjsip.c: Register PJMEDIA error code decoder.

Registering the PJMEDIA error codes allows errors found when parsing an
incoming SDP to be easier to figure out.

"Missing SDP rtpmap for dynamic payload type (PJMEDIA_SDP_EMISSINGRTPMAP)"
is much easier to understand than "Unknown error 220030".


Change-Id: I44b2dcea656fedd7593171be9e845880a2c70ca0

4 years agores_pjsip_session.c: Remove unused parameter from handle_incoming().
Richard Mudgett [Mon, 27 Jun 2016 21:56:33 +0000 (16:56 -0500)]
res_pjsip_session.c: Remove unused parameter from handle_incoming().

Change-Id: Iedd182d189ec947c42edc2c66c4bda3c22060daa

4 years agores_pjsip: Add missing NULL checks when using pjsip_inv_end_session().
Richard Mudgett [Wed, 22 Jun 2016 23:02:59 +0000 (18:02 -0500)]
res_pjsip: Add missing NULL checks when using pjsip_inv_end_session().

pjsip_inv_end_session() is documented as being able to return the
passed in tdata parameter set to NULL on success.

Change-Id: I09d53725c49b7183c41bfa1be3ff225f3a8d3047

4 years agofeatures: Fix channel datastore access.
Richard Mudgett [Thu, 30 Jun 2016 20:17:02 +0000 (15:17 -0500)]
features: Fix channel datastore access.

Found as a result of the testsuite tests/callparking test crashing.

Several calls to ast_get_chan_featuremap_config() and
ast_get_chan_features_xfer_config() did not lock the channel before
calling so the channel's datastore list was accessed without the lock's
protection.  Apparently another thread deleted a datastore on the
channel's list while the crashing thread was walking the list.  Crash at
0xdeaddead due to MALLOC_DEBUG's memory filler value as a result.

* Add missing channel locks to calls that were not already protected
as the doxygen for those calls indicates.

Change-Id: Id273b3d305cc616406c353cbc841b2b7655efaa1

4 years agoconfigure: Fix HAVE_PJSIP_EVSUB_GRP_LOCK not set with external pjproject
George Joseph [Thu, 30 Jun 2016 13:25:09 +0000 (07:25 -0600)]
configure:  Fix HAVE_PJSIP_EVSUB_GRP_LOCK not set with external pjproject

There was a typo in preventing HAVE_PJSIP_EVSUB_GRP_LOCK
from getting set when using an external pjproject.

ASTERISK-26099 #close
Reported-by: Ross Beer

Change-Id: I709af70428e125fb5ccd44b171d25dd29141f0ae

4 years agoMerge "pjproject/patches/config_site: Increase the max number of ICE candidates"
Joshua Colp [Wed, 29 Jun 2016 23:49:38 +0000 (18:49 -0500)]
Merge "pjproject/patches/config_site: Increase the max number of ICE candidates"

4 years agohep.conf.sample: Default 'enabled' to 'no'
Matt Jordan [Wed, 29 Jun 2016 20:31:30 +0000 (15:31 -0500)]
hep.conf.sample: Default 'enabled' to 'no'

Following the principle of least surprise, we should not be sending
massive numbers of PJSIP and RTCP HEP packets out into the ether to some
only-slightly-random IP address. Having 'enabled' set to 'no' in the
sample configuration file should prevent this from happening for those
who run 'make samples'.

ASTERISK-26159 #close

Change-Id: I1753a64ca83a3442a6ebdc31061f8185c062d9b1

4 years agopjproject/patches/config_site: Increase the max number of ICE candidates
Matt Jordan [Wed, 29 Jun 2016 20:09:02 +0000 (15:09 -0500)]
pjproject/patches/config_site: Increase the max number of ICE candidates

When negotiating ICE candidates with WebRTC capable endpoints, many
networks will result in a browser offering ICE candidates that exceeds
the default number of max candidates, 16. This patch bumps the max
candidates to 32, with the max checks at twice the number of candidates.
In practice, this has shown to be sufficient for browser/WebRTC

Change-Id: Ifd8da8b315f5ae14814d4ce20e10d2e6355020e5

4 years agoMerge "codecs: Fix ABI incompatibility created by adding format_name to ast_codec"
zuul [Wed, 29 Jun 2016 17:24:14 +0000 (12:24 -0500)]
Merge "codecs:  Fix ABI incompatibility created by adding format_name to ast_codec"

4 years agoMerge "siren: Add format attribute modules for Siren7 and Siren14."
zuul [Wed, 29 Jun 2016 16:30:53 +0000 (11:30 -0500)]
Merge "siren: Add format attribute modules for Siren7 and Siren14."

4 years agoMerge "BuildSystem: Avoid obsolete warning with AC_TYPE_SIGNAL on autoconf."
zuul [Wed, 29 Jun 2016 16:16:05 +0000 (11:16 -0500)]
Merge "BuildSystem: Avoid obsolete warning with AC_TYPE_SIGNAL on autoconf."

4 years agocodecs: Fix ABI incompatibility created by adding format_name to ast_codec
George Joseph [Tue, 28 Jun 2016 14:00:32 +0000 (08:00 -0600)]
codecs:  Fix ABI incompatibility created by adding format_name to ast_codec

Adding format_name even to the end of ast_codec caused issued with
binary codec modules because the pointer would be garbage in asterisk
when they registered.  So, the ast_codec structure was reverted and an
internal_ast_codec structure was created just for use in codec.c.  A new
internal-only API was also added (__ast_codec_register_with_format) so
that codec_builtin could register codecs with the format_name in a
separate parameter rather than in the ast_codec structure.

ASTERISK-26144 #close
Reported-by: Alexei Gradinari

Change-Id: I6df1b08f6a6ae089db23adfe1ebc8636330265ba

4 years agoMerge "BuildSystem: Fix a few issues hightlighted by gcc 6.x"
Joshua Colp [Tue, 28 Jun 2016 19:57:06 +0000 (14:57 -0500)]
Merge "BuildSystem:  Fix a few issues hightlighted by gcc 6.x"

4 years agoBuildSystem: Fix a few issues hightlighted by gcc 6.x
George Joseph [Tue, 28 Jun 2016 13:22:24 +0000 (07:22 -0600)]
BuildSystem:  Fix a few issues hightlighted by gcc 6.x

gcc 6.1.1 caught a few more issues.
Made sure the unit tests still pass for the func_env and stdtime

ASTERISK-26157 #close

Change-Id: I6664d8f34a45bc1481d2a854481c7878b0c1cf8e

4 years agoconfigs/basic-pbx/modules.conf: Remove 'bad' modules
Matt Jordan [Tue, 28 Jun 2016 15:33:30 +0000 (10:33 -0500)]
configs/basic-pbx/modules.conf: Remove 'bad' modules

This patch removes the following modules:
 - pbx_functions: It never existed.
 - res_pjsip_log_forwarder: It no longer exists.
 - res_hep_pjsip: The base HEP module wasn't loaded, and most basic PBXs
                  aren't going to be installing HOMER
 - res_pjsip_phoneprov_provider: The basic res_phoneprov module isn't
                  loaded, and we aren't configured to make use of the

Change-Id: Id91f68cae7c9c8c3d370029fe1268cb51e4ff5a5

4 years agosiren: Add format attribute modules for Siren7 and Siren14.
Joshua Colp [Wed, 22 Jun 2016 16:19:32 +0000 (13:19 -0300)]
siren: Add format attribute modules for Siren7 and Siren14.

This change removes hardcoded SDP parsing and generation for
Siren7 and Siren14 from chan_sip and moves it to format attribute
modules so it can also be used by chan_pjsip.

With this the fmtp lines for both are added with the bitrate


Change-Id: Ibb004eda37a14c0a35ef0613f6237977fc800037

4 years agoBuildSystem: Avoid obsolete warning with AC_TYPE_SIGNAL on autoconf.
Alexander Traud [Thu, 23 Jun 2016 09:33:06 +0000 (11:33 +0200)]
BuildSystem: Avoid obsolete warning with AC_TYPE_SIGNAL on autoconf.

Removed the obsolete macro AC_TYPE_SIGNAL because Asterisk does not use K&R C
but requires ANSI C anyway.


Change-Id: I914c014385e1862102d90fe7650621def78db02e

4 years agoMerge "res_fax: Fix reference leak in fax_v21_session_new."
zuul [Thu, 23 Jun 2016 02:50:22 +0000 (21:50 -0500)]
Merge "res_fax: Fix reference leak in fax_v21_session_new."

4 years agoMerge "res_rtp_asterisk: Fix a self-comparison identified by gcc 6"
Joshua Colp [Thu, 23 Jun 2016 01:16:03 +0000 (20:16 -0500)]
Merge "res_rtp_asterisk:  Fix a self-comparison identified by gcc 6"

4 years agoMerge "chan_unistim: Fix memcpy in get_to_address"
zuul [Wed, 22 Jun 2016 23:50:57 +0000 (18:50 -0500)]
Merge "chan_unistim:  Fix memcpy in get_to_address"

4 years agoMerge "BuildSystem: Avoid obsolete warning with AC_FUNC_SETVBUF_REVERSED on autoconf."
zuul [Wed, 22 Jun 2016 23:50:48 +0000 (18:50 -0500)]
Merge "BuildSystem: Avoid obsolete warning with AC_FUNC_SETVBUF_REVERSED on autoconf."

4 years agoMerge "Fix Alembic upgrades."
Joshua Colp [Wed, 22 Jun 2016 21:06:06 +0000 (16:06 -0500)]
Merge "Fix Alembic upgrades."

4 years agores_fax: Fix reference leak in fax_v21_session_new.
Corey Farrell [Wed, 22 Jun 2016 20:04:54 +0000 (16:04 -0400)]
res_fax: Fix reference leak in fax_v21_session_new.

fax_v21_session_new created a session details object but only released
the allocation reference during error conditions.  fax_session_new adds
it's own reference to details if needed so the caller is always
responsible for cleaning it's own reference.

ASTERISK-26141 #close

Change-Id: Ie7fc52a83b6596ce9ce2d5a2bd9f3e204f48fc88

4 years agoMerge "res_pjproject.c: Replace inlined DEBUG_ATLEAST() with macro."
zuul [Wed, 22 Jun 2016 19:36:46 +0000 (14:36 -0500)]
Merge "res_pjproject.c: Replace inlined DEBUG_ATLEAST() with macro."

4 years agores_pjsip: improve realtime performance #2
Alexei Gradinari [Wed, 22 Jun 2016 19:25:23 +0000 (15:25 -0400)]
res_pjsip: improve realtime performance #2

The patch removes updating all Endpoints' status on startup.
Instead, only non-qualified aors with static contact
and non-qualified non-expired contacts are retrieved from the realtime to
update the endpoint status to ONLINE.
The endpoint name was added to the contact object to simply find the endpoint
that created this contact.

The status of endpoints with qualified aors will be updated by 'qualify'

ASTERISK-26061 #close

Change-Id: Id324c1776fa55d3741e0c5457ecac0304cb1a0df

4 years agores_rtp_asterisk: Fix a self-comparison identified by gcc 6
George Joseph [Wed, 22 Jun 2016 18:41:57 +0000 (12:41 -0600)]
res_rtp_asterisk:  Fix a self-comparison identified by gcc 6

gcc 6 caught a previously unidentified self-comparison in
ice_candidate_cmp.  Fixed it and re-ordered the predicates for better

ASTERISK-26140 #close

Change-Id: I3da713c568e24064430257b3502fbdafd35af7a7

4 years agochan_unistim: Fix memcpy in get_to_address
George Joseph [Wed, 22 Jun 2016 15:37:23 +0000 (09:37 -0600)]
chan_unistim:  Fix memcpy in get_to_address

A code block only enabled when HAVE_PKTINFO is not defined (FreeBSD)
was using a pointer to a pointer as the destination of a memcpy and a
'&' instead of '*' in the sizeof.

ASTERISK-26138 #close

Change-Id: Id4927ff256c0e470bdf7bcfc025146a2f656e708

4 years agoFix Alembic upgrades.
Mark Michelson [Mon, 20 Jun 2016 18:21:52 +0000 (13:21 -0500)]
Fix Alembic upgrades.

A non-existent constraint was being referenced in the upgrade script.
This patch corrects the problem by removing the reference.

In addition, the head of the alembic branch referred to a non-existent
revision. This has been fixed by referring to the proper revision.

This patch fixes another realtime problem as well. Our Alembic scripts
store booleans as yes or no values. However, Sorcery tries to insert
"true" or "false" instead. This patch introduces a new boolean type that
translates to "yes" or "no" instead.

ASTERISK-26128 #close

Change-Id: I51574736a881189de695a824883a18d66a52dcef

4 years agotest_res_pjsip_scheduler: Add 'depends' on pjproject in MODULEINFO
George Joseph [Wed, 22 Jun 2016 15:51:14 +0000 (09:51 -0600)]
test_res_pjsip_scheduler: Add 'depends' on pjproject in MODULEINFO

Since the file was missing the depends on pjproject, it wasn't
picking up the pjproject related include path.  If there was no
system installed pjproject and pjproject-bundled was used, a compile
would fail because pjsip.h wasn't found.

ASTERISK-26139 #close

Change-Id: I2ee64a999051452bc198c4e2c168c70769cd3757

4 years agoBuildSystem: Avoid obsolete warning with AC_FUNC_SETVBUF_REVERSED on autoconf.
Alexander Traud [Wed, 22 Jun 2016 15:55:05 +0000 (17:55 +0200)]
BuildSystem: Avoid obsolete warning with AC_FUNC_SETVBUF_REVERSED on autoconf.

Removed the obsolete macro AC_FUNC_SETVBUF_REVERSED because Asterisk does not
support the platform SVR2 from the year 1987 anymore.


Change-Id: I28161b037feb2d29ab46ed20e785928460226c22

4 years agoMerge "res_rtp_asterisk: fix memory leak in dtls"
Joshua Colp [Wed, 22 Jun 2016 15:52:54 +0000 (10:52 -0500)]
Merge "res_rtp_asterisk: fix memory leak in dtls"

4 years agoMerge "res_pjsip_pubsub: Address SEGV when attempting to terminate a subscription"
Joshua Colp [Wed, 22 Jun 2016 10:11:54 +0000 (05:11 -0500)]
Merge "res_pjsip_pubsub: Address SEGV when attempting to terminate a subscription"

4 years agores_rtp_asterisk: fix memory leak in dtls
Torrey Searle [Tue, 21 Jun 2016 11:52:20 +0000 (13:52 +0200)]
res_rtp_asterisk: fix memory leak in dtls

ensure that cert bios get freed after creating the fingerprint

ASTERISK-26129 #close

Change-Id: I44d23aea07dce80176ca1ff877c5ace9452ef451

4 years agoMerge "res_rtp_asterisk: Use latest DTLS version available by underlying platform."
Joshua Colp [Wed, 22 Jun 2016 00:39:51 +0000 (19:39 -0500)]
Merge "res_rtp_asterisk: Use latest DTLS version available by underlying platform."

4 years agoMerge "res_pjsip_session: Handle race condition at shutdown with timer."
Joshua Colp [Tue, 21 Jun 2016 23:53:33 +0000 (18:53 -0500)]
Merge "res_pjsip_session: Handle race condition at shutdown with timer."

4 years agores_pjproject.c: Replace inlined DEBUG_ATLEAST() with macro.
Richard Mudgett [Tue, 21 Jun 2016 22:42:28 +0000 (17:42 -0500)]
res_pjproject.c: Replace inlined DEBUG_ATLEAST() with macro.

Change-Id: I8799fb0a347ad76e747dafd0eacf1ea1086b9a8c

4 years agoMerge "PJSIP: provide transport type with received messages"
zuul [Tue, 21 Jun 2016 20:05:35 +0000 (15:05 -0500)]
Merge "PJSIP: provide transport type with received messages"

4 years agores_pjsip_pubsub: Address SEGV when attempting to terminate a subscription
George Joseph [Sun, 12 Jun 2016 16:19:27 +0000 (10:19 -0600)]
res_pjsip_pubsub: Address SEGV when attempting to terminate a subscription

Occasionally under load we'll attempt to send a final NOTIFY on a
subscription that's already been terminated and a SEGV will occur
down in pjproject's evsub_destroy function.  This is a result of a
race condition between all the paths that can generate a notify
and/or destroy the underlying pjproject evsub object:

 * The client can send a SUBSCRIBE with Expires: 0.
 * The client can send a SUBSCRIBE/refresh.
 * The subscription timer can expire.
 * An extension state can change.
 * An MWI event can be generated.
 * The pjproject transaction timer (timer_b) can expire.

Normally when our pubsub_on_evsub_state is called with a terminate,
we push a task to the serializer and return at which point the dialog
is unlocked.  This is usually not a problem because the task runs
immediately and locks the dialog again.  When the system is heavily
loaded though, there may be a delay between the unlock and relock
during which another event may occur such as the subscription timer
or timer_b expiring, an extension state change, etc.  These may also
cause a terminate to be processed and if so, we could cause pjproject
to try to destroy the evsub structure twice.  There's no way for us to
tell that the evsub was already destroyed and the evsub's group lock
can't tolerate this and SEGVs.

The remedy is twofold.

 * A patch has been submitted to Teluu and added to the bundled
   pjproject which adds add/decrement operations on evsub's group lock.

 * In res_pjsip_pubsub:
   * and pjproject-bundled's configure.m4 were updated
     to check for the new evsub group lock APIs.
   * We now add a reference to the evsub group lock when we create
     the subscription and remove the reference when we clean up the
     subscription.  This prevents evsub from being destroyed before
     we're done with it.
   * A state has been added to the subscription tree structure so
     termination progress can be tracked through the asyncronous tasks.
   * The pubsub_on_evsub_state callback has been split so it's not doing
     double duty.  It now only handles the final cleanup of the
     subscription tree.  pubsub_on_rx_refresh now handles both client
     refreshes and client terminates.  It was always being called for
     both anyway.
   * The serialized_on_server_timeout task was removed since
     serialized_pubsub_on_rx_refresh was almost identical.
   * Missing state checks and ao2_cleanups were added.
   * Some debug levels were adjusted to make seeing only off-nominal
     things at level 1 and nominal or progress things at level 2+.

ASTERISK-26099 #close
Reported-by: Ross Beer.

Change-Id: I779d11802cf672a51392e62a74a1216596075ba1