Commit Graph

5600 Commits

Author SHA1 Message Date
Joshua Colp 6cc890b880 channel: Add support for writing to a specific stream.
This change adds an ast_write_stream function which allows
writing a frame to a specific media stream. It also moves
ast_write() to using this underneath by writing media
frames provided to it to the default streams of the channel.
Existing functionality (such as audiohooks, framehooks, etc)
are limited to being applied to the default stream only.

Unit tests have also been added which test the behavior of
both non-multistream and multistream channels to confirm that
the write() and write_stream() callbacks are invoked
appropriately.

ASTERISK-26793

Change-Id: I4df20d1b65bd4d787fce0b4b478e19d2dfea245c
2017-02-23 18:31:15 +00:00
Joshua Colp 16b0bb39c1 Merge changes from topic 'sdp_state_beginnings'
* changes:
  Add SDP translator and PJMEDIA implementation.
  Add initial SDP options.
2017-02-21 13:37:03 -06:00
Joshua Colp 28c8e4f58f 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
libasteriskssl.so 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
cache.

ASTERISK-26705

Change-Id: If4eca46ac510c6fea5568256280ffdb3888d7bb4
2017-02-21 05:25:13 -06:00
zuul 8dde33d184 Merge "tcptls.c: Add some missing allocation failure checks." 2017-02-20 17:43:27 -06:00
zuul 496a7b0b4c Merge "Revert "build: Execute ldconfig to build cache."" 2017-02-20 14:09:27 -06:00
Joshua Colp 7739b0b3ae Revert "build: Execute ldconfig to build cache."
This reverts commit 8851c3e088.

Change-Id: I124380be5e3bd57da978428a2a93604336ccd0db
2017-02-20 11:19:55 -06:00
zuul c227745bc7 Merge "Remove extra ast_iostream_close() calls." 2017-02-17 17:41:06 -06:00
Richard Mudgett 0b427f9b59 tcptls.c: Add some missing allocation failure checks.
* Fix tcptls_session ref and fd leak in ast_tcptls_server_root().

Change-Id: I0ddf01cd3c10d3b6666d7bf68d4e206a37f4fbdb
2017-02-17 17:00:24 -06:00
Mark Michelson dbc3598014 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
horribly.

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
2017-02-17 15:12:30 -06:00
Mark Michelson 5a130b2e17 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
2017-02-17 09:47:47 -06:00
Mark Michelson 8af6342555 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
2017-02-17 09:23:12 -06:00
Joshua Colp 8851c3e088 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
libasteriskssl.so 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.

ASTERISK-26705

Change-Id: I6d30b6427e9d5e69470e11327c7ff203fa7da519
2017-02-16 14:21:14 -06:00
zuul ab34e46b3a Merge "stream: Rename creates/destroys to allocs/frees" 2017-02-16 13:24:30 -06:00
George Joseph f8f513d363 stream: Rename creates/destroys to allocs/frees
To be consistent with sdp implementation.

Change-Id: I714e300939b4188f58ca66ce9d1e84b287009500
2017-02-16 09:10:02 -06:00
Joshua Elson ac7a34c531 http: Ensure capath is defined on all http creations
ASTERISK-26794 #close

Change-Id: I9cbc3b6b6a8aab590f5ccde9c262a98e4d5253a1
2017-02-16 05:48:41 -06:00
George Joseph ca7fa7bbd2 Merge "stream: Add stream topology to channel" 2017-02-15 19:29:52 -06:00
George Joseph bf2f091bbb stream: Add stream topology to channel
Adds topology set and get to channel.

ASTERISK-26790

Change-Id: Ic379ea82a9486fc79dbd8c4d95c29fa3b46424f4
2017-02-14 14:09:37 -07:00
zuul 182c737353 Merge "cli: Fix various CLI documentation and completion issues" 2017-02-14 14:34:03 -06:00
zuul cea835e565 Merge "channel: Protect flags in ast_waitfor_nandfds operation." 2017-02-14 13:31:01 -06:00
zuul b1e0b26145 Merge "stream: Add stream topology unit tests and fix uncovered bugs." 2017-02-14 13:26:44 -06:00
Joshua Colp 84a232ffb3 Merge "libasteriskssl: do nothing with OpenSSL >= 1.1" 2017-02-14 12:49:42 -06:00
zuul 2f0a036e4b Merge "tcptls: use TLS_client_method with OpenSSL 1.1" 2017-02-14 12:41:06 -06:00
zuul d4f512e7d9 Merge "openssl 1.1 support: use OPENSSL_VERSION_NUMBER" 2017-02-14 12:33:01 -06:00
Joshua Colp 72845bd4b5 Merge "core: Cleanup some channel snapshot staging anomalies." 2017-02-14 07:14:51 -06:00
zuul 09fcfb26fa Merge "stream: Add media stream topology definition and API" 2017-02-13 13:02:20 -06:00
Joshua Colp 6c4657e28e 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.

ASTERISK-26786

Change-Id: Id5590e87c8a605deea1a89e53169a9c011d66fa0
2017-02-13 17:00:42 +00:00
Sean Bright 3f94373778 cli: Fix various CLI documentation and completion issues
* app_minivm: Use built-in completion facilities to complete optional
arguments.

* 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
arguments.

* 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
applications.'

* 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
2017-02-13 11:33:15 -05:00
George Joseph 8b72ec312b 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.

ASTERISK-26786

Change-Id: Ic930232d24d5ad66dcabc14e9b359e0ff8e7f568
2017-02-13 07:49:25 -07:00
zuul f9f74f4b75 Merge "manager: Restore Originate failure behavior from Asterisk 11" 2017-02-13 07:11:16 -06:00
Joshua Colp 89871576b9 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.

ASTERISK-26788

Change-Id: I2c5c8edec17c9bdad4a93291576838cb552ca5ed
2017-02-13 05:09:30 -06:00
Sean Bright 0910773077 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
2017-02-10 18:04:41 -05:00
Richard Mudgett 16fdb11bc3 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
location.

* 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
2017-02-10 12:05:56 -06:00
Joshua Colp bab4885f1e 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.

ASTERISK-26773

Change-Id: I3dbe54065b55aaa51f467e1a3bafd67fb48cac87
2017-02-10 09:58:03 -07:00
Joshua Colp 5422ec140c 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.

ASTERISK-26772
patches:
  srv_lookup.patch submitted by nappsoft (license 6822)

Change-Id: I09b19081c74e0ad11c12bf54a257243b1bcb2351
2017-02-07 12:13:23 -06:00
Sebastien Duthil 7b280e7ccf
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
leak.

ASTERISK-26767 #close

Change-Id: Ia37dd9d68063d7f879193df02ede293e5ded716d
2017-02-03 16:42:52 -05:00
Tzafrir Cohen c6c7f17206 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
2017-02-03 10:28:14 +02:00
Tzafrir Cohen bc041ca14a 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
2017-02-03 10:28:14 +02:00
Tzafrir Cohen 2c8d0764de openssl 1.1 support: use OPENSSL_VERSION_NUMBER
Use OPENSSL_VERSION_NUMBER instead of OPENSSL_API_COMPAT to detect
the openssl 1.1 API.

Change-Id: I4e448f55ef516aedf6ad154037c35577a421a458
2017-02-03 10:28:14 +02:00
Richard Mudgett 50029f585e channel.c: Fix unbalanced read queue deadlocking local channels.
Using the timerfd timing module can cause channel freezing, lingering, or
deadlock issues.  The problem is because this is the only timing module
that uses an associated alert-pipe.  When the alert-pipe becomes
unbalanced with respect to the number of frames in the read queue bad
things can happen.  If the alert-pipe has fewer alerts queued than the
read queue then nothing might wake up the thread to handle received frames
from the channel driver.  For local channels this is the only way to wake
up the thread to handle received frames.  Being unbalanced in the other
direction is less of an issue as it will cause unnecessary reads into the
channel driver.

ASTERISK-26716 is an example of this deadlock which was indirectly fixed
by the change that found the need for this patch.

* In channel.c:__ast_queue_frame(): Adding frame lists to the read queue
did not add the same number of alerts to the alert-pipe.  Correspondingly,
when there is an exceptionally long queue event, any removed frames did
not also remove the corresponding number of alerts from the alert-pipe.

ASTERISK-26632 #close

Change-Id: Ia98137c5bf6e9d6d202ce0eb36441851875863f6
2017-02-02 13:02:03 -06:00
Richard Mudgett 72e3fc5845 Frame deferral: Revert API refactoring.
There are several issues with deferring frames that are caused by the
refactoring.

1) The code deferring frames mishandles adding a deferred frame to the
deferred queue.  As a result the deferred queue can only be one frame
long.

2) Deferrable frames can come directly from the channel driver as well as
the read queue.  These frames need to be added to the deferred queue.

3) Whoever is deferring frames is really only doing the __ast_read() to
collect deferred frames and doesn't care about the returned frames except
to detect a hangup event.  When frame deferral is completed we must make
the normal frame processing see the hangup as a frame anyway.  As such,
there is no need to have varying hangup frame deferral methods.  We also
need to be aware of the AST_SOFTHANGUP_ASYNCGOTO hangup that isn't real.
That fake hangup is to cause the PBX thread to break out of loops to go
execute a new dialplan location.

4) To properly deal with deferrable frames from the channel driver as
pointed out by (2) above, means that it is possible to process a dialplan
interception routine while frames are deferred because of the
AST_CONTROL_READ_ACTION control frame.  Deferring frames is not
implemented as a re-entrant operation so you could have the unsupported
case of two sections of code thinking they have control of the media
stream.

A worse problem is because of the bad implementation of the AMI PlayDTMF
action.  It can cause two threads to be deferring frames on the same
channel at the same time.  (ASTERISK_25940)

* Rather than fix all these problems simply revert the API refactoring as
there is going to be only autoservice and safe_sleep deferring frames
anyway.

ASTERISK-26343

ASTERISK-26716 #close

Change-Id: I45069c779aa3a35b6c863f65245a6df2c7865496
2017-02-02 13:02:03 -06:00
Richard Mudgett 97c308471d res_agi: Prevent an AGI from eating frames it should not. (Re-do)
A dialplan intercept routine is equivalent to an interrupt routine.  As
such, the routine must be done quickly and you do not have access to the
media stream.  These restrictions are necessary because the media stream
is the responsibility of some other code and interfering with or delaying
that processing is bad.  A possible future dialplan processing
architecture change may allow the interception routine to run in a
different thread from the main thread handling the media and remove the
execution time restriction.

* Made res_agi.c:run_agi() running an AGI in an interception routine run
in DeadAGI mode.  No touchy channel frames.

ASTERISK-25951

ASTERISK-26343

ASTERISK-26716

Change-Id: I638f147ca7a7f2590d7194a8ef4090eb191e4e43
2017-02-02 13:02:03 -06:00
Sean Bright 2849b726b6 audiohooks: Muting a hook can mute underlying frames
If an audiohook is placed on a channel that does not require transcoding,
muting that hook will cause the underlying frames to be muted as well.

The original patch is from David Woolley but I have modified slightly.

ASTERISK-21094 #close
Reported by: David Woolley
Patches:
      ASTERISK-21094-Patch-1.8-1.txt (license #5737) patch uploaded
      by David Woolley

Change-Id: Ib2b68c6283e227cbeb5fa478b2d0f625dae338ed
2017-02-01 17:00:26 -06:00
zuul 6cbe894828 Merge "debug_utilities: Add ast_logescalator" 2017-01-29 11:22:05 -06:00
George Joseph ef4deb8ecd debug_utilities: Add ast_logescalator
The escalator works by creating a set of startup commands in cli.conf
that set up logger channels and issue the debug commands for the
subsystems specified.  If asterisk is running when it is executed,
the same commands will be issued to the running instance.  The original
cli.conf is saved before any changes are made and can be restored by
executing '$prog --reset'.

The log output will be stored in...
$astlogdir/message.$uniqueid
$astlogdir/debug.$uniqueid
$astlogdir/dtmf.$uniqueid
$astlogdir/fax.$uniqueid
$astlogdir/security.$uniqueid
$astlogdir/pjsip_history.$uniqueid
$astlogdir/sip_history.$uniqueid

Some minor tweaks were made to chan_sip, and res_pjsip_history
so their history output could be send to a log channel as packets
are captured.

A minor tweak was also made to manager so events are output to verbose
when "manager set debug on" is issued.

Change-Id: I799f8e5013b86dc5282961b27383d134bf09e543
2017-01-27 15:10:02 -06:00
Torrey Searle 178b90af02 libastssl/pj: libastssl/pj should have an so_version
Issue introduced in b59956a87.  In the non-darwin case libastssl/pj
should be versioned.  This causes the symbol file for this lib
to not be generated.

Change-Id: Ib07ae8c40252813c488e2c1ac6204fd42816dd4c
(cherry picked from commit 54b027916a)
2017-01-27 08:21:01 -06:00
George Joseph 6f645a6d4e Merge "media: Add experimental support for RTCP feedback." 2017-01-27 07:04:52 -06:00
zuul 10631bb209 Merge "PJPROJECT logging: Fix detection of max supported log level." 2017-01-26 18:46:22 -06:00
George Joseph 0ad6d2b3cf Merge "ari: Implement 'debug all' and request/response logging" 2017-01-26 17:06:40 -06:00
George Joseph 2484c3ee39 Merge "frame.c: Fix off-nominal format ref leaks." 2017-01-26 16:03:50 -06:00
George Joseph 96dbf54e97 Merge "T.140: Fix format ref and memory leaks." 2017-01-26 10:23:14 -06:00