2 years agoMerge "res_config_ldap: Fix erroneous LDAP_MOD_REPLACE in LDAP modify"
zuul [Tue, 21 Feb 2017 23:57:24 +0000 (17:57 -0600)]
Merge "res_config_ldap: Fix erroneous LDAP_MOD_REPLACE in LDAP modify"

2 years agopbx_dundi: DUNDi weight parameter not processed correctly
Sean Bright [Tue, 21 Feb 2017 21:09:47 +0000 (16:09 -0500)]
pbx_dundi: DUNDi weight parameter not processed correctly

The DUNDi weight field is not always converted from network byte order
to host byte order. This can result in incorrect weight values and
incorrect selection of DUNDi destinations.

ASTERISK-18731 #close
Reported by: Peter Racz
dundi_weight.patch (license #6290) patch uploaded by Peter Racz

Change-Id: Iba3e1a700ff539db57211a7bbc26f7b22ea9a1be

2 years agoAdd initial SDP state code.
Mark Michelson [Wed, 15 Feb 2017 20:43:36 +0000 (14:43 -0600)]
Add initial SDP state code.

This establishes the basic allocation/destruction of an SDP state
object, plus some of the simpler getter methods involved. Subsequent
tasks will deal with adding a state machine, creating SDPs from
capabilities and options, and merging SDPs into a joint SDP.

Change-Id: Ie3757ce186f04b65e9d1883f5aace53f24e53709

2 years agoMerge changes from topic 'sdp_state_beginnings'
Joshua Colp [Tue, 21 Feb 2017 19:37:03 +0000 (13:37 -0600)]
Merge changes from topic 'sdp_state_beginnings'

* changes:
  Add SDP translator and PJMEDIA implementation.
  Add initial SDP options.

2 years agoMerge "build: Execute ldconfig to build cache."
Joshua Colp [Tue, 21 Feb 2017 19:36:38 +0000 (13:36 -0600)]
Merge "build: Execute ldconfig to build cache."

2 years agorealtime: Fix ast_load_realtime_multientry handling
Sean Bright [Tue, 21 Feb 2017 16:47:28 +0000 (11:47 -0500)]
realtime: Fix ast_load_realtime_multientry handling

ast_load_realtime_multientry() returns an ast_config structure whose
ast_categorys are keyed with the empty strings. Several modules were
giving semantic meaning to the category names causing problems at

* app_directory: Treated the category name as the mailbox name, and
  would fail to direct calls to the appropriate extension after an
  entry was chosen.

* app_queue: Queues, queue members, and queue rules were all affected
  and needed to be updated.

* pbx_realtime: Pattern matching would never succeed because the
  extension entered by the user was always compared to the empty

Change-Id: Ie7e44986344b0b76ea8f6ddb5879f5040c6ca8a7

2 years agorealtime: Centralize some common realtime backend code
Sean Bright [Tue, 21 Feb 2017 14:56:54 +0000 (09:56 -0500)]
realtime: Centralize some common realtime backend code

All of the realtime backends create artificial ast_categorys to pass
back into the core as query results. These categories have no filename
or line number information associated with them and the backends differ
slightly on how they create them. So create a couple helper macros to
help make things more consistent.

Also updated the call sites to remove redundant error messages about
memory allocation failure.

Note that res_config_ldap sets the category filename to the 'table name'
but that is not read by anything in the core, so I've dropped it.

Change-Id: I3a1fd91e0c807dea1ce3b643b0a6fe5be9002897

2 years agoMerge "realtime: Fix LIKE escaping in SQL backends"
zuul [Tue, 21 Feb 2017 12:26:30 +0000 (06:26 -0600)]
Merge "realtime: Fix LIKE escaping in SQL backends"

2 years agobuild: Execute ldconfig to build cache.
Joshua Colp [Thu, 16 Feb 2017 16:30:00 +0000 (16:30 +0000)]
build: Execute ldconfig to build cache.

On some platforms a multiarch approach is used for libraries.
The build system does not take this into account and still
places libraries into the lib directory if no --libdir is
specified to configure. On initial startup this results in not being found, as it is not in the multiarch
lib directory.

This change does the minimally invasive thing and executes
ldconfig so that the libraries in the lib directory are found
and their location cached. By doing so Asterisk starts up fine.

If DESTDIR is specified, however, the old logic is executed as
the install process may not have permission to alter the ldconfig


Change-Id: If4eca46ac510c6fea5568256280ffdb3888d7bb4

2 years agores_pjsip_authenticator_digest.c: Fix sorcery's immutable contract violation.
Richard Mudgett [Mon, 9 Jan 2017 02:32:17 +0000 (20:32 -0600)]
res_pjsip_authenticator_digest.c: Fix sorcery's immutable contract violation.

The inbound authentication object is supposed to be immutable when it is
stored in sorcery.  However, the immutable property is violated if the
authentication object does not have a realm set.

The immutable contract violation has a different effect depending upon
what sorcery back end is used.  If it is the config file back end you
would get the same object back until res_pjsip is reloaded.  If it is the
real-time or AstDB back end you would get a new object on each query.  If
it is cached you would get the same object back until it is refreshed from
the database.

Once an inbound authentication object has its realm set it may or may not
get updated again if the default_realm changes.

If the same authentication object is used for inbound and outbound
authentication then the immutable violation can make it very hard to
determine why the outbound authentication now fails.  The only diagnostic
message is a complaint about no realms matching when it had worked
earlier.  It fails because of the difference in behaviour for an empty
realm setting between inbound and outbound authentication objects.

* Fixed the sorcery object immutable violation by creating a new object
and setting the default_realm on it instead.  The new object is a shallow
copy for speed.

* The auth_store thread storage no longer holds an auth ref.  It
interferes with the shallow copy and never needed a ref anyway.

ASTERISK-26799 #close

Change-Id: I2328a52f61b78ed5fbba38180b7f183ee7e08956

2 years agores_pjsip: Update artificial auth whenever default_realm changes.
Richard Mudgett [Sun, 5 Feb 2017 02:17:36 +0000 (20:17 -0600)]
res_pjsip: Update artificial auth whenever default_realm changes.

There was code attempting to update the artificial authentication object
whenever the default_realm changed.  However, once the artificial
authentication object was created it would never get updated.  The
artificial authentication object would require a system restart for a
change to the default_realm to take effect.


Change-Id: Id59036e9529c2d3ed728af2ed904dc36e7094802

2 years agores_pjsip: Update authentication realm documentation.
Richard Mudgett [Sun, 1 Jan 2017 14:02:17 +0000 (08:02 -0600)]
res_pjsip: Update authentication realm documentation.

Using the same auth section for inbound and outbound authentication is not
recommended.  There is a difference in meaning for an empty realm setting
between inbound and outbound authentication uses.

An empty inbound auth realm represents the global section's default_realm
value when the authentication object is used to challenge an incoming
request.  An empty outgoing auth realm is treated as a don't care wildcard
when the authentication object is used to respond to an incoming
authentication challenge.


Change-Id: Id3952f7cfa1b6683b9954f2c5d2352d2f11059ce

2 years agoMerge "app_voicemail: vm_authenticate accesses uninitialized memory"
zuul [Tue, 21 Feb 2017 00:29:24 +0000 (18:29 -0600)]
Merge "app_voicemail: vm_authenticate accesses uninitialized memory"

2 years agoMerge "tcptls.c: Add some missing allocation failure checks."
zuul [Mon, 20 Feb 2017 23:43:27 +0000 (17:43 -0600)]
Merge "tcptls.c: Add some missing allocation failure checks."

2 years agopjproject: Fixes to resolve DNS SRV crashes.
Richard Mudgett [Mon, 13 Feb 2017 23:11:06 +0000 (17:11 -0600)]
pjproject: Fixes to resolve DNS SRV crashes.

* Re #1945 (misc): Don't trigger SRV complete callback when there is a
parse error.

* srv_resolver.c: Don't try to send query if already considered resolved.

** In resolve_hostnames() don't try to resolve a query that is already
considered resolved.

** In resolve_hostnames() fix DNS typo in comments.

** In build_server_entries() move a common expression assigning to cnt

* sip_transport.c: Fix tdata object name to actually contain the pointer.

It helps if the logs referencing a tdata object buffer actually have a
name that includes the correct pointer as part of the name.  Also since
the tdata has its own pool it helps if any logs referencing the pool have
the same name as the tdata object.  This change brings tdata logging in
line with how tsx objects are named.

ASTERISK-26669 #close
ASTERISK-26738 #close

Change-Id: I56af2ded25476b3e870ca586ee69ed6954ef75af

2 years agopjproject: Increase SENDER_WIDTH column size for 64-bit system logs.
Richard Mudgett [Mon, 20 Feb 2017 19:38:58 +0000 (13:38 -0600)]
pjproject: Increase SENDER_WIDTH column size for 64-bit system logs.


Change-Id: Ibae6fc8cae69a1f04df0c577c4c11200499d6fe0

2 years agopjsip_distributor.c: Update some debug messages to get transaction name.
Richard Mudgett [Mon, 6 Feb 2017 20:26:30 +0000 (14:26 -0600)]
pjsip_distributor.c: Update some debug messages to get transaction name.

* Removed overloaded unmatched response ignore.  We obviously sent the
request so we shouldn't ignore it because it isn't new work.


Change-Id: I55fb5cadc83a8e6699b347c6dc7fa32c5a617d37

2 years agoMerge "pjproject cli: Add object count after object lists"
zuul [Mon, 20 Feb 2017 22:25:34 +0000 (16:25 -0600)]
Merge "pjproject cli:  Add object count after object lists"

2 years agoMerge "res_config_sqlite3: Properly create missing columns when necessary"
zuul [Mon, 20 Feb 2017 21:43:16 +0000 (15:43 -0600)]
Merge "res_config_sqlite3: Properly create missing columns when necessary"

2 years agoapp_voicemail: vm_authenticate accesses uninitialized memory
Sean Bright [Mon, 20 Feb 2017 12:28:23 +0000 (07:28 -0500)]
app_voicemail: vm_authenticate accesses uninitialized memory

vm_authenticate doesn't always set the passed ast_vm_user argument, so
we initialize to 0 before passing it in.

ASTERISK-25893 #close
Reported by: Filip Jenicek

Change-Id: Ia3cc0128f93d352ed9add8d5c2f0f7232c2cbe4a

2 years agoMerge "Revert "build: Execute ldconfig to build cache.""
zuul [Mon, 20 Feb 2017 20:09:27 +0000 (14:09 -0600)]
Merge "Revert "build: Execute ldconfig to build cache.""

2 years agoRevert "build: Execute ldconfig to build cache."
Joshua Colp [Mon, 20 Feb 2017 17:19:55 +0000 (11:19 -0600)]
Revert "build: Execute ldconfig to build cache."

This reverts commit 8851c3e0885cb704a5a6159a51768ea5297e9b10.

Change-Id: I124380be5e3bd57da978428a2a93604336ccd0db

2 years agoMerge "Binaural synthesis (confbridge): Adds utils/conf_bridge_binaural_hrir_importer"
Joshua Colp [Mon, 20 Feb 2017 16:24:55 +0000 (10:24 -0600)]
Merge "Binaural synthesis (confbridge): Adds utils/conf_bridge_binaural_hrir_importer"

2 years agopjproject cli: Add object count after object lists
George Joseph [Mon, 20 Feb 2017 14:04:25 +0000 (07:04 -0700)]
pjproject cli:  Add object count after object lists

When listing a container, we now print the number of objects
in the container at the end of the list.

Change-Id: I791cbc3ee9da9a2af9adc655164b5d32953df812

2 years agores_config_ldap: Don't try to delete non-existent attributes
Sean Bright [Mon, 20 Feb 2017 11:53:47 +0000 (06:53 -0500)]
res_config_ldap: Don't try to delete non-existent attributes

OpenLDAP will raise an error when we try to delete an LDAP attribute
that doesn't exist. We need to filter out LDAP_MOD_DELETE requests
based on which attributes the current LDAP entry actually has. There
is of course a small window of opportunity for this to still fail,
but it is much less likely now.

Change-Id: I3fe1b04472733e43151563aaf9f8b49980273e6b

2 years agores_config_ldap: Remove extraneous line numbers from log messages
Sean Bright [Mon, 20 Feb 2017 11:49:17 +0000 (06:49 -0500)]
res_config_ldap: Remove extraneous line numbers from log messages

Extraneous line numbers were being output in many log messages. These
have been removed.

Change-Id: Ice9efa3d252ee87f37fa8f5ea852fda482675431

2 years agores_config_ldap: Make memory allocation more consistent
Sean Bright [Mon, 20 Feb 2017 11:45:54 +0000 (06:45 -0500)]
res_config_ldap: Make memory allocation more consistent

The code in update_ldap() and update2_ldap() was using both Asterisk's
memory allocation routines as well as OpenLDAP's. I've changed it so
that everything that is passed to OpenLDAP's functions are allocated
with their routines.

Change-Id: Iafec9c1fd8ea49ccc496d6316769a6a426daa804

2 years agores_config_ldap: Fix configuration inheritance from _general
Sean Bright [Mon, 20 Feb 2017 11:30:31 +0000 (06:30 -0500)]
res_config_ldap: Fix configuration inheritance from _general

The "_general" configuration section allows administrators to provide
both general configuration options (host, port, url, etc.) as well as a
global realtime-to-LDAP-attribute mapping that is a fallback if one of
the later sections do not override it. This neglected to exclude the
general configuration options from the mapping. As an example, during
my testing, chan_sip requested 'port' from realtime, and because I did
not have it defined, it pulled in the 'port' configuration option from
"_general." We now filter those out explicitly.

Change-Id: I1fc61560bf96b8ba623063cfb7e0a49c4690d778

2 years agores_config_ldap: Fix erroneous LDAP_MOD_REPLACE in LDAP modify
Sean Bright [Mon, 20 Feb 2017 11:27:38 +0000 (06:27 -0500)]
res_config_ldap: Fix erroneous LDAP_MOD_REPLACE in LDAP modify

We always treat the first change of our modification batch as a
replacement when it sometimes is actually a delete. So we have to pass
the correct arguments to the OpenLDAP library.

ASTERISK-26580 #close
Reported by: Nicholas John Koch
res_config_ldap.c-11.24.1.patch (license #6833) patch uploaded
by Nicholas John Koch

Change-Id: I0741d25de07c9539f1edc6eff3696165dfb64fbe

2 years agoMerge "res_config_sqlite3: Fix crash when loading with invalid config"
zuul [Sun, 19 Feb 2017 19:24:44 +0000 (13:24 -0600)]
Merge "res_config_sqlite3: Fix crash when loading with invalid config"

2 years agoMerge "pjproject-bundled: Fix checksum verification when using cURL"
Joshua Colp [Sun, 19 Feb 2017 18:46:09 +0000 (12:46 -0600)]
Merge "pjproject-bundled: Fix checksum verification when using cURL"

2 years agores_config_sqlite3: Fix crash when loading with invalid config
Sean Bright [Wed, 15 Feb 2017 17:55:19 +0000 (12:55 -0500)]
res_config_sqlite3: Fix crash when loading with invalid config

When ast_config_load() fails with CONFIG_STATUS_FILEINVALID, it has
already destroyed the ast_config struct for us. Trying to do it again
results in a crash.

Change-Id: If6a5c0ca718ad428e01a1fb25beb209a9ac18bc6

2 years agoMerge "Remove extra ast_iostream_close() calls."
zuul [Fri, 17 Feb 2017 23:41:06 +0000 (17:41 -0600)]
Merge "Remove extra ast_iostream_close() calls."

2 years agopjproject-bundled: Fix checksum verification when using cURL
Sean Bright [Fri, 17 Feb 2017 23:06:47 +0000 (18:06 -0500)]
pjproject-bundled: Fix checksum verification when using cURL

ASTERISK-26802 #close
Reported by: Michael L. Young

Change-Id: Iad293080f55d4d69ab615717a15211d916eed613

2 years agotcptls.c: Add some missing allocation failure checks.
Richard Mudgett [Fri, 17 Feb 2017 22:57:54 +0000 (16:57 -0600)]
tcptls.c: Add some missing allocation failure checks.

* Fix tcptls_session ref and fd leak in ast_tcptls_server_root().

Change-Id: I0ddf01cd3c10d3b6666d7bf68d4e206a37f4fbdb

2 years agoRemove extra ast_iostream_close() calls.
Mark Michelson [Fri, 17 Feb 2017 20:58:28 +0000 (14:58 -0600)]
Remove extra ast_iostream_close() calls.

When AMI encounters an error at the beginning of a session, it would
explicitly call ast_iostream_close() on its tcptls session's iostream.
It then would jump to a label where it would shut down the tcptls
session instance. The tcptls session instance would again attempt to
close the iostream.

Under normal circumstances, this might go by unnoticed. However, when
MALLOC_DEBUG is enabled, all fields on the iostream get set to
0xdeaddead when the iostream is freed. Thus a second call to
ast_iostream_close() after the iostream has been freed would reslt in an
attempt to call SSL_shutdown on 0xdeaddead, which would crash and burn

The fix here is to not directly close the iostream from the dangerous
scenarios. The specific scenarios are:
* Exceeding the configured authlimit
* Failing to build a mansession on a new connection

Change-Id: I908f98d516afd5a263bd36b072221008a4731acd

2 years agoAdd SDP translator and PJMEDIA implementation.
Mark Michelson [Tue, 14 Feb 2017 15:54:43 +0000 (09:54 -0600)]
Add SDP translator and PJMEDIA implementation.

This creates the following:
* Asterisk's internal representation of an SDP
* An API for translating SDPs from one format to another
* An implementation of a translator for PJMEDIA

Change-Id: Ie2ecd3cbebe76756577be9b133e84d2ee356d46b

2 years agoAdd initial SDP options.
Mark Michelson [Tue, 7 Feb 2017 15:50:52 +0000 (09:50 -0600)]
Add initial SDP options.

This is step one of adding an SDP API: defining some
configurable settings for SDPs. This is based on options
that are currently supported in Asterisk.

Change-Id: I1ede91aafed403b12a9ccdfb91a88389baa7e5d7

2 years agobuild: Execute ldconfig to build cache.
Joshua Colp [Thu, 16 Feb 2017 16:30:00 +0000 (16:30 +0000)]
build: Execute ldconfig to build cache.

On some platforms a multiarch approach is used for libraries.
The build system does not take this into account and still
places libraries into the lib directory if no --libdir is
specified to configure. On initial startup this results in not being found, as it is not in the multiarch
lib directory.

This change does the minimally invasive thing and executes
ldconfig so that the libraries in the lib directory are found
and their location cached. By doing so Asterisk starts up fine.


Change-Id: I6d30b6427e9d5e69470e11327c7ff203fa7da519

2 years agoMerge "stream: Rename creates/destroys to allocs/frees"
zuul [Thu, 16 Feb 2017 19:24:30 +0000 (13:24 -0600)]
Merge "stream:  Rename creates/destroys to allocs/frees"

2 years agorealtime: Fix LIKE escaping in SQL backends
Sean Bright [Thu, 16 Feb 2017 14:38:06 +0000 (09:38 -0500)]
realtime: Fix LIKE escaping in SQL backends

The realtime framework allows for components to look up values using a
LIKE clause with similar syntax to SQL's. pbx_realtime uses this
functionality to search for pattern matching extensions that start with
an underscore (_).

When passing an underscore to SQL's LIKE clause, it will be interpreted
as a wildcard matching a single character and therefore needs to be
escaped. It is (for better or for worse) the responsibility of the
component that is querying realtime to escape it with a backslash before
passing it in. Some RDBMs support escape characters by default, but the
SQL92 standard explicitly says that there are no escape characters
unless they are specified with an ESCAPE clause, e.g.

SELECT * FROM table WHERE column LIKE '\_%' ESCAPE '\'

This patch instructs 3 backends - res_config_mysql, res_config_pgsql,
and res_config_sqlite3 - to use the ESCAPE clause where appropriate.

Looking through documentation and source tarballs, I was able to
determine that the ESCAPE clause is supported in:

MySQL 5.0.15   (released 2005-10-22 - earliest version available from
PostgreSQL 7.1 (released 2001-04-13)
SQLite 3.1.0   (released 2005-01-21)

The versions of the relevant libraries that we depend on to access MySQL
and PostgreSQL will not work on versions that old, and I've added an
explicit check in res_config_sqlite3 to only use the ESCAPE clause when
we have a sufficiently new version of SQLite3.

res_config_odbc already handles the escape characters appropriately, so
no changes were required there.

ASTERISK-15858 #close
Reported by: Humberto Figuera

ASTERISK-26057 #close
Reported by: Stepan

Change-Id: I93117fbb874189ae819f4a31222df7c82cd20efa

2 years agoMerge "stream: Add unit tests for channel stream usage."
Joshua Colp [Thu, 16 Feb 2017 17:34:40 +0000 (11:34 -0600)]
Merge "stream: Add unit tests for channel stream usage."

2 years agoMerge "chan_unistim: fix char type to have consistent behavior on ARM"
zuul [Thu, 16 Feb 2017 17:32:32 +0000 (11:32 -0600)]
Merge "chan_unistim: fix char type to have consistent behavior on ARM"

2 years agoMerge "http: Ensure capath is defined on all http creations"
Joshua Colp [Thu, 16 Feb 2017 16:40:10 +0000 (10:40 -0600)]
Merge "http: Ensure capath is defined on all http creations"

2 years agoMerge "res_pjsip_pubsub: Correctly implement persisted subscriptions"
Joshua Colp [Thu, 16 Feb 2017 15:48:52 +0000 (09:48 -0600)]
Merge "res_pjsip_pubsub:  Correctly implement persisted subscriptions"

2 years agostream: Rename creates/destroys to allocs/frees
George Joseph [Thu, 16 Feb 2017 14:28:33 +0000 (07:28 -0700)]
stream:  Rename creates/destroys to allocs/frees

To be consistent with sdp implementation.

Change-Id: I714e300939b4188f58ca66ce9d1e84b287009500

2 years agoMerge "pjsip_distributor.c: Fix off-nominal tdata ref leak."
zuul [Thu, 16 Feb 2017 13:08:29 +0000 (07:08 -0600)]
Merge "pjsip_distributor.c: Fix off-nominal tdata ref leak."

2 years agores_config_sqlite3: Properly create missing columns when necessary
Sean Bright [Thu, 16 Feb 2017 11:46:04 +0000 (06:46 -0500)]
res_config_sqlite3: Properly create missing columns when necessary

There were two specific issues resolved here:

1) The code that iterated over the required fields
   (via ast_realtime_require) was broken for the RQ_INTEGER1 field
   type. Iteration would stop when the first RQ_INTEGER1 (0) field
   was encountered.

2) sqlite3_changes() was used to try and count the number of rows
   returned by a SELECT statement. sqlite3_changes() only counts
   affected rows, so this was always returning the value from the
   most recent data modification statement. We now separate read-only
   queries from data modification queries and count rows appropriately
   in both cases.

ASTERISK-23457 #close
Reported by: Scott Griepentrog

Change-Id: I91ed20494efc3fcfbc2a96ac7646999a49814884

2 years agohttp: Ensure capath is defined on all http creations
Joshua Elson [Wed, 15 Feb 2017 20:44:32 +0000 (13:44 -0700)]
http: Ensure capath is defined on all http creations

ASTERISK-26794 #close

Change-Id: I9cbc3b6b6a8aab590f5ccde9c262a98e4d5253a1

2 years agochan_unistim: fix char type to have consistent behavior on ARM
Igor Goncharovsky [Thu, 16 Feb 2017 05:09:35 +0000 (08:09 +0300)]
chan_unistim: fix char type to have consistent behavior on ARM

There is difference exists in behaviour of char type on x86 and ARM.
On x86 by default char variable type means signed char, but in ARM
unsigned char used. This make binary calculations and negative values
works wrong on ARM.

This patch change type of char variables used for store negative
values and binary calculations to signed char.


Change-Id: Id78716dee9568a58419d4ef63c038affc3dfc7ab

2 years agoMerge "stream: Add stream topology to channel"
George Joseph [Thu, 16 Feb 2017 01:29:52 +0000 (19:29 -0600)]
Merge "stream:  Add stream topology to channel"

2 years agores_pjsip_pubsub: Correctly implement persisted subscriptions
George Joseph [Tue, 7 Feb 2017 19:17:12 +0000 (12:17 -0700)]
res_pjsip_pubsub:  Correctly implement persisted subscriptions

This patch fixes 2 original issues and more that those 2 exposed.

* When we send a NOTIFY, and the client either doesn't respond or
  responds with a non OK, pjproject only calls our
  pubsub_on_evsub_state callback, no others.  Since
  pubsub_on_evsub_state (which does the sub_tree cleanup) does not
  expect to be called back without the other callbacks being called
  first, it just returns leaving the sub_tree orphaned.  Now
  pubsub_on_evsub_state checks the event for PJSIP_EVENT_TSX_STATE
  which is what pjproject will set to tell us that it was the
  transaction that timed out or failed and not the subscription
  itself timing our or being terminated by the client. If is
  TSX_STATE, pubsub_on_evsub_state now does the proper cleanup
  regardless of the state of the subscription.

* When a client renews a subscription, we don't update the
  persisted subscription with the new expires timestamp.  This causes
  subscription_persistence_recreate to prune the subscription if/when
  asterisk restarts.  Now, pubsub_on_rx_refresh calls
  subscription_persistence_update to apply the new expires timestamp.
  This exposed other issues however...

* When creating a dialog from rdata (which sub_persistence_recreate
  does from the packet buffer) there must NOT be a tag on the To
  header (which there will be when a client refreshes a
  subscription).  If there is one, pjsip_dlg_create_uas will fail.
  To address this, subscription_persistence_update now accepts a flag
  that indicates that the original packet buffer must not be updated.
  New subscribes don't set the flag and renews do.  This makes sure
  that when the rdata is recreated on asterisk startup, it's done
  from the original subscribe packet which won't have the tag on To.

* When creating a dialog from rdata, we were setting the dialog's
  remote (SUBSCRIBE) cseq to be the same as the local (NOTIFY) cseq.
  When the client tried to resubscribe after a restart with the
  correct cseq, we'd reject the request with an Invalid CSeq error.

* The acts of creating a dialog and evsub by themselves when
  recreating a subscription does NOT restart pjproject's subscription
  timer.  The result was that even if we did correctly recreate the
  subscription, we never removed it if the client happened to go away
  or send a non-OK response to a NOTIFY.  However, there is no
  pjproject function exposed to just set the timer on an evsub that
  wasn't created by an incoming subscribe request.  To address this,
  we create our own timer using ast_sip_schedule_task.  This timer is
  used only for re-establishing subscriptions after a restart.

  An earlier approach was to add support for setting pjproject's
  timer (via a pjproject patch) and while that patch is still included
  here, we don't use that call at the moment.

While addressing these issues, additional debugging was added and
some existing messages made more useful.  A few formatting changes
were also made to 'pjsip show scheduled tasks' to make displaying
the subscription timers a little more friendly.


Change-Id: I8c605fc1e3923f466a74db087d5ab6f90abce68e

2 years agores_rtp_asterisk: Use PJ_ICE_MAX_CAND instead of hard-coding 16
Sean Bright [Wed, 15 Feb 2017 17:03:00 +0000 (12:03 -0500)]
res_rtp_asterisk: Use PJ_ICE_MAX_CAND instead of hard-coding 16

pjsip limits the total number of ICE candidates to PJ_ICE_MAX_CAND,
which is a compile-time constant. Instead of hard-coding 16 when we
enumerate local interfaces, use PJ_ICE_MAX_CAND so that we can
potentially collect more interfaces if the compile time options are

Tangentially related to ASTERISK~24464

Change-Id: I1b85509e39e33b1fed63c86261fc229ba14bbabd

2 years agoBinaural synthesis (confbridge): Adds utils/conf_bridge_binaural_hrir_importer
Dennis Guse [Thu, 22 Dec 2016 15:42:46 +0000 (16:42 +0100)]
Binaural synthesis (confbridge): Adds utils/conf_bridge_binaural_hrir_importer

Adds the import tool for converting a HRIR database to hrirs.h


Change-Id: I51eb31b54c23ffd9b544bdc6a09d20c112c8a547

2 years agostream: Add unit tests for channel stream usage.
Joshua Colp [Tue, 14 Feb 2017 18:33:57 +0000 (18:33 +0000)]
stream: Add unit tests for channel stream usage.

This change adds unit tests cover the following:

1. That retrieving the first media stream of a specific media
type from a stream topology retrieves the expected media

2. That setting the native formats of a channel which does
not support streams results in the creation of streams on
its behalf according to the formats of the channel.

3. That setting a stream topology on a channel which supports
streams sets the topology to the provided one.


Change-Id: Ic53176dd3e4532e8c3e97d9e22f8a4b66a2bb755

2 years agoMerge "app_voicemail: Allow 'Comedian Mail' branding to be overriden"
zuul [Tue, 14 Feb 2017 23:42:07 +0000 (17:42 -0600)]
Merge "app_voicemail: Allow 'Comedian Mail' branding to be overriden"

2 years agoMerge "app_voicemail: VoiceMailPlayMsg did not play database stored messages"
zuul [Tue, 14 Feb 2017 23:18:08 +0000 (17:18 -0600)]
Merge "app_voicemail: VoiceMailPlayMsg did not play database stored messages"

2 years agoapp_voicemail: Allow 'Comedian Mail' branding to be overriden
Sean Bright [Mon, 13 Feb 2017 22:50:41 +0000 (17:50 -0500)]
app_voicemail: Allow 'Comedian Mail' branding to be overriden

Original patch by John Covert, slight modifications by me.

ASTERISK-17428 #close
Reported by: John Covert
app_voicemail.c.patch (license #5512) patch uploaded by
        John Covert

Change-Id: Ic3361b0782e5a5397a19ab18eb8550923a9bd6a6

2 years agostream: Add stream topology to channel
George Joseph [Mon, 13 Feb 2017 17:50:47 +0000 (10:50 -0700)]
stream:  Add stream topology to channel

Adds topology set and get to channel.


Change-Id: Ic379ea82a9486fc79dbd8c4d95c29fa3b46424f4

2 years agoMerge "app_record: Add option to prevent silence from being truncated"
zuul [Tue, 14 Feb 2017 21:04:40 +0000 (15:04 -0600)]
Merge "app_record: Add option to prevent silence from being truncated"

2 years agoMerge "cli: Fix various CLI documentation and completion issues"
zuul [Tue, 14 Feb 2017 20:34:03 +0000 (14:34 -0600)]
Merge "cli: Fix various CLI documentation and completion issues"

2 years agoMerge "channel: Protect flags in ast_waitfor_nandfds operation."
zuul [Tue, 14 Feb 2017 19:31:01 +0000 (13:31 -0600)]
Merge "channel: Protect flags in ast_waitfor_nandfds operation."

2 years agoMerge "stream: Add stream topology unit tests and fix uncovered bugs."
zuul [Tue, 14 Feb 2017 19:26:43 +0000 (13:26 -0600)]
Merge "stream: Add stream topology unit tests and fix uncovered bugs."

2 years agoapp_voicemail: VoiceMailPlayMsg did not play database stored messages
rrittgarn [Wed, 25 Jan 2017 22:25:21 +0000 (16:25 -0600)]
app_voicemail: VoiceMailPlayMsg did not play database stored messages

When attempting to use VoiceMailPlayMsg with a realtime data backend
the message is located, but never retrieved. This patch adds the
required RETRIEVE and DISPOSE calls that will fetch the message from
the database (and IMAP storage as well for that matter).

Also, removed extraneous make_file call.

ASTERISK-26723 #close

Change-Id: I1e122dd53c0f3d7faa10f3c2b7e7e76a47d51b8c

2 years agoMerge "libasteriskssl: do nothing with OpenSSL >= 1.1"
Joshua Colp [Tue, 14 Feb 2017 18:49:42 +0000 (12:49 -0600)]
Merge "libasteriskssl: do nothing with OpenSSL >= 1.1"

2 years agoMerge "tcptls: use TLS_client_method with OpenSSL 1.1"
zuul [Tue, 14 Feb 2017 18:41:06 +0000 (12:41 -0600)]
Merge "tcptls: use TLS_client_method with OpenSSL 1.1"

2 years agoMerge "openssl 1.1 support: use OPENSSL_VERSION_NUMBER"
zuul [Tue, 14 Feb 2017 18:33:01 +0000 (12:33 -0600)]
Merge "openssl 1.1 support: use OPENSSL_VERSION_NUMBER"

2 years agoapp_record: Add option to prevent silence from being truncated
Sean Bright [Tue, 14 Feb 2017 14:12:31 +0000 (09:12 -0500)]
app_record: Add option to prevent silence from being truncated

When using Record() with the silence detection feature, the stream is
written out to the given file. However, if only 'silence' is detected,
this file is then truncated to the first second of the recording.

This patch adds the 'u' option to Record() to override that behavior.

ASTERISK-18286 #close
Reported by: var
app_record- (license #6184) patch uploaded by var

Change-Id: Ia1cd163483235efe2db05e52f39054288553b957

2 years agoMerge "core: Cleanup some channel snapshot staging anomalies."
Joshua Colp [Tue, 14 Feb 2017 13:14:50 +0000 (07:14 -0600)]
Merge "core: Cleanup some channel snapshot staging anomalies."

2 years agoMerge "app_queue: reset abandoned in sl for sl2 calculations"
zuul [Mon, 13 Feb 2017 22:28:38 +0000 (16:28 -0600)]
Merge "app_queue:  reset abandoned in sl for sl2 calculations"

2 years agoMerge "stream: Add media stream topology definition and API"
zuul [Mon, 13 Feb 2017 19:02:20 +0000 (13:02 -0600)]
Merge "stream:  Add media stream topology definition and API"

2 years agoapp_queue: reset abandoned in sl for sl2 calculations
Sebastian Gutierrez [Tue, 7 Feb 2017 17:13:09 +0000 (14:13 -0300)]
app_queue:  reset abandoned in sl for sl2 calculations

ASTERISK-26775 #close

Change-Id: I86de4b1a699d6edc77fea9b70d839440e4088284

2 years agoMerge "res_pjsip.c: Fix inconsistency between warning and action."
Joshua Colp [Mon, 13 Feb 2017 18:08:03 +0000 (12:08 -0600)]
Merge "res_pjsip.c: Fix inconsistency between warning and action."

2 years agostream: Add stream topology unit tests and fix uncovered bugs.
Joshua Colp [Mon, 13 Feb 2017 17:00:42 +0000 (17:00 +0000)]
stream: Add stream topology unit tests and fix uncovered bugs.

This change adds unit tests for the various API calls relating
to stream topologies. This includes creation, destruction,
inspection, and manipulation.

Through this a few bugs were uncovered in the implementation:

1. Creating a topology using a format capabilities would fail as
the code considered a return value of 0 from the append stream
function to indicate an error which is incorrect.

2. Not all functions which placed a stream into a topology
set the position on the stream itself.

3. Appending a stream would cause a frack if the position
provided was the last one. This occurred because the existing
stream was queried but the index was outside of what the
vector was currently at for size.


Change-Id: Id5590e87c8a605deea1a89e53169a9c011d66fa0

2 years agocli: Fix various CLI documentation and completion issues
Sean Bright [Sat, 11 Feb 2017 15:57:03 +0000 (10:57 -0500)]
cli: Fix various CLI documentation and completion issues

* app_minivm: Use built-in completion facilities to complete optional

* app_voicemail: Use built-in completion facilities to complete
optional arguments.

* app_confbridge: Add missing colons after 'Usage' text.

* chan_alsa: Use built-in completion facilities to complete optional

* chan_sip: Use built-in completion facilities to complete optional
arguments. Add completions for 'load' for 'sip show user', 'sip show
peer', and 'sip qualify peer.'

* chan_skinny: Correct and extend completions for 'skinny reset' and
'skinny show line.'

* func_odbc: Correct completions for 'odbc read' and 'odbc write'

* main/astmm: Use built-in completion facilities to complete arguments
for 'memory' commands.

* main/bridge: Correct completions for 'bridge kick.'

* main/ccss: Use built-in completion facilities to complete arguments
for 'cc cancel' command.

* main/cli: Add 'all' completion for 'channel request hangup.' Correct
completions for 'core set debug channel.' Correct completions for 'core
show calls.'

* main/pbx_app: Remove redundant completions for 'core show

* main/pbx_hangup_handler: Remove unused completions for 'core show
hanguphandlers all.'

* res_sorcery_memory_cache: Add completion for 'reload' argument of
'sorcery memory cache stale' and properly implement.

Change-Id: Iee58c7392f6fec34ad9d596109117af87697bbca

2 years agoMerge "chan_pjsip: Multidomain endpoint finding on call"
zuul [Mon, 13 Feb 2017 15:43:50 +0000 (09:43 -0600)]
Merge "chan_pjsip: Multidomain endpoint finding on call"

2 years agostream: Add media stream topology definition and API
George Joseph [Fri, 10 Feb 2017 21:45:43 +0000 (14:45 -0700)]
stream:  Add media stream topology definition and API

This change adds the media stream topology definition and API for
accessing and using it.

Some refactoring of the stream was also done.


Change-Id: Ic930232d24d5ad66dcabc14e9b359e0ff8e7f568

2 years agoMerge "manager: Restore Originate failure behavior from Asterisk 11"
zuul [Mon, 13 Feb 2017 13:11:16 +0000 (07:11 -0600)]
Merge "manager: Restore Originate failure behavior from Asterisk 11"

2 years agoMerge "stream: Add media stream definition and API with unit tests."
Joshua Colp [Mon, 13 Feb 2017 13:05:07 +0000 (07:05 -0600)]
Merge "stream: Add media stream definition and API with unit tests."

2 years agochan_pjsip: Multidomain endpoint finding on call
Norbert Varga [Fri, 13 Jan 2017 17:21:36 +0000 (18:21 +0100)]
chan_pjsip: Multidomain endpoint finding on call

When PJSIP tries to call an endpoint with a domain (e.g.,
the user part is stripped down as it would be a trunk with a specified user,
and only the host part is called as a PJSIP endpoint and can't be found.
This is not correct in the case of a multidomain SIP account, so the stripping
after the @ sign is done only if the whole endpoint (in multidomain case can't be found.


Change-Id: I3a2dd6f57f3bd042df46b961eccd81d31ab202e6

2 years agochannel: Protect flags in ast_waitfor_nandfds operation.
Joshua Colp [Mon, 13 Feb 2017 11:05:51 +0000 (11:05 +0000)]
channel: Protect flags in ast_waitfor_nandfds operation.

The ast_waitfor_nandfds operation will manipulate the flags
of channels passed in. This was previously done without
the channel lock being held. This could result in incorrect
values existing for the flags if another thread manipulated
the flags at the same time.

This change locks the channel during flag manipulation.


Change-Id: I2c5c8edec17c9bdad4a93291576838cb552ca5ed

2 years agores_pjsip.c: Fix inconsistency between warning and action.
Richard Mudgett [Sat, 11 Feb 2017 17:25:30 +0000 (11:25 -0600)]
res_pjsip.c: Fix inconsistency between warning and action.

The original return value corresponded to AST_SIP_AUTHENTICATION_CHALLENGE
but we have no authenticator registered to create the challenge.

Change-Id: I62368180d774b497411b80fbaabd0c80841f8512

2 years agopjsip_distributor.c: Fix off-nominal tdata ref leak.
Richard Mudgett [Sat, 11 Feb 2017 17:26:58 +0000 (11:26 -0600)]
pjsip_distributor.c: Fix off-nominal tdata ref leak.

Change-Id: I571f371d0956a8039b197b4dbd8af6b18843598d

2 years agomanager: Restore Originate failure behavior from Asterisk 11
Sean Bright [Thu, 9 Feb 2017 16:01:22 +0000 (11:01 -0500)]
manager: Restore Originate failure behavior from Asterisk 11

In Asterisk 11, if the 'Originate' AMI command failed to connect the provided
Channel while in extension mode, a 'failed' extension would be looked up and
run. This was, I believe, unintentionally removed in 51b6c49. This patch
restores that behavior.

This also adds an enum for the various 'synchronous' modes in an attempt to
make them meaningful.

ASTERISK-26115 #close
Reported by: Nasir Iqbal

Change-Id: I8afbd06725e99610e02adb529137d4800c05345d

2 years agocore: Cleanup some channel snapshot staging anomalies.
Richard Mudgett [Wed, 8 Feb 2017 20:27:18 +0000 (14:27 -0600)]
core: Cleanup some channel snapshot staging anomalies.

We shouldn't unlock the channel after starting a snapshot staging because
another thread may interfere and do its own snapshot staging.

* app_dial.c:dial_exec_full() made hold the channel lock while setting up
the outgoing channel staging.  Made hold the channel lock after the called
party answers while updating the caller channel staging.

* chan_sip.c:sip_new() completed the channel staging on off-nominal exit.
Also we need to use ast_hangup() instead of ast_channel_unref() at that

* channel.c:__ast_channel_alloc_ap() added a comment about not needing to
complete the channel snapshot staging on off-nominal exit paths.

* rtp_engine.c:ast_rtp_instance_set_stats_vars() made hold the channel
locks while staging the channels for the stats channel variables.

Change-Id: Iefb6336893163f6447bad65568722ad5d5d8212a

2 years agostream: Add media stream definition and API with unit tests.
Joshua Colp [Tue, 7 Feb 2017 12:56:41 +0000 (12:56 +0000)]
stream: Add media stream definition and API with unit tests.

This change adds the media stream definition and API for
accessing and using it. Unit tests have also been written
which exercise aspects of the API.


Change-Id: I3dbe54065b55aaa51f467e1a3bafd67fb48cac87

2 years agoconfigs/samples: Fix placement of 'identify' entry in sorcery.conf
George Joseph [Fri, 10 Feb 2017 15:35:51 +0000 (08:35 -0700)]
configs/samples: Fix placement of 'identify' entry in sorcery.conf

The entry for 'identify' was incorrectly placed in the
res_pjsip section when it should be in

ASTERISK-26785 #close

Change-Id: Ia1372b12a952bfe2df6b1b1e0e725ca306a5d41a

2 years agoRevert "Update qualifies when AOR configuration changes."
Mark Michelson [Wed, 8 Feb 2017 17:50:11 +0000 (11:50 -0600)]
Revert "Update qualifies when AOR configuration changes."

This reverts commit 6492e91392b8fd394193e411c6eb64b45486093f.

The change in question was intended to prevent the need to reload in
order to update qualifies on contacts when an AOR changes. However, this
ended up causing a deadlock instead.

Change-Id: I1a835c90a5bb65b6dc3a1e94cddc12a4afc3d71e

2 years agoMerge "srv: Fix crash when ast_srv_lookup is used and 0 records are returned."
zuul [Wed, 8 Feb 2017 16:00:05 +0000 (10:00 -0600)]
Merge "srv: Fix crash when ast_srv_lookup is used and 0 records are returned."

2 years agosrv: Fix crash when ast_srv_lookup is used and 0 records are returned.
Joshua Colp [Tue, 7 Feb 2017 18:01:03 +0000 (18:01 +0000)]
srv: Fix crash when ast_srv_lookup is used and 0 records are returned.

When performing an SRV lookup using the ast_srv_lookup function it
did not properly handle the situation where 0 records are returned.
If this happened it would wrongly assume that at least one record
was present.

This change fixes the code so it will exit early if an error occurs
or if 0 records are returned.

  srv_lookup.patch submitted by nappsoft (license 6822)

Change-Id: I09b19081c74e0ad11c12bf54a257243b1bcb2351

2 years agores_stasis_device_state: Protect the adding/removing of subscriptions.
Joshua Colp [Mon, 6 Feb 2017 17:40:45 +0000 (17:40 +0000)]
res_stasis_device_state: Protect the adding/removing of subscriptions.

The adding and removing of device state subscriptions did not protect
fully against simultaneous manipulation. In particular the subscribe
case allowed a small window where two subscriptions could be added for
the same device state instead of just one.

This change makes the code hold the subscriptions lock for the entirety
of each operation to ensure that two are not occurring at the same time.


Change-Id: I3e7f8eb9d09de440c9024d2dd52029f6f20e725b

2 years agores_pjsip: Fix some off nominal tdata leaks.
Richard Mudgett [Wed, 1 Feb 2017 23:56:13 +0000 (17:56 -0600)]
res_pjsip: Fix some off nominal tdata leaks.

Change-Id: I243a4be5e7fbfe604923764969c4ee04eee89b9d

2 years agores_ari: fix memory leak for channelvars
Sebastien Duthil [Fri, 3 Feb 2017 21:26:23 +0000 (16:26 -0500)]
res_ari: fix memory leak for channelvars

In ari.conf, when setting the option channelvars, every Stasis channel
snapshot would create a list of variable/value that would not be freed
when the snapshot is freed, resulting in a often-recurring memory

ASTERISK-26767 #close

Change-Id: Ia37dd9d68063d7f879193df02ede293e5ded716d

2 years agoMerge "Update qualifies when AOR configuration changes."
Joshua Colp [Fri, 3 Feb 2017 15:32:53 +0000 (09:32 -0600)]
Merge "Update qualifies when AOR configuration changes."

2 years agoMerge "channel.c: Fix unbalanced read queue deadlocking local channels."
Joshua Colp [Fri, 3 Feb 2017 11:32:26 +0000 (05:32 -0600)]
Merge "channel.c: Fix unbalanced read queue deadlocking local channels."

2 years agoMerge "res_agi: Prevent an AGI from eating frames it should not. (Re-do)"
Joshua Colp [Fri, 3 Feb 2017 11:32:12 +0000 (05:32 -0600)]
Merge "res_agi: Prevent an AGI from eating frames it should not. (Re-do)"

2 years agolibasteriskssl: do nothing with OpenSSL >= 1.1
Tzafrir Cohen [Fri, 3 Feb 2017 08:25:33 +0000 (10:25 +0200)]
libasteriskssl: do nothing with OpenSSL >= 1.1

OpenSSL 1.1 requires no explicit initialization. The hacks in the
library are not needed. They also happen to fail running Asterisk.

Change-Id: I3b3efd5d80234a4c45a8ee58dcfe25b15d9ad100

2 years agotcptls: use TLS_client_method with OpenSSL 1.1
Tzafrir Cohen [Sat, 21 Jan 2017 05:59:15 +0000 (07:59 +0200)]
tcptls: use TLS_client_method with OpenSSL 1.1

OpenSSL 1.1 introduced TLS_client_method() and deprecated the previous
version-specific methods (such as TLSv1_client_method(). Other than
being simpler to use and more correct (gain support for TLS newer that
TLS1, in our case), the older ones produce a deprecation warning that
fails the build in dev-mode.

Change-Id: I257b1c8afd09dcb0d96cda3a41cb9f7a15d0ba07

2 years agoopenssl 1.1 support: use OPENSSL_VERSION_NUMBER
Tzafrir Cohen [Sat, 21 Jan 2017 05:57:33 +0000 (07:57 +0200)]
openssl 1.1 support: use OPENSSL_VERSION_NUMBER

the openssl 1.1 API.

Change-Id: I4e448f55ef516aedf6ad154037c35577a421a458

2 years agoMerge "Add reload options to CLI/AMI stale object commands."
George Joseph [Fri, 3 Feb 2017 00:34:03 +0000 (18:34 -0600)]
Merge "Add reload options to CLI/AMI stale object commands."