Commit Graph

28168 Commits

Author SHA1 Message Date
George Joseph 1b4922466b chan_sip: Prevent deadlock when issuing "sip show channels"
sip_show_channels locks the dialogs container first then locks each
sip_pvt so it can spit out the details.  The rest of sip dialog
processing locks the sip_pvt first then locks the dialogs container
if it needs to.  Both lock in the order they need but deadlocks can
result.  To fix, sip_show_channels and sip_show_channelstats have
been converted to use an iterator rather than ao2_callback.  This way
the container is locked only while getting the next entry and is
unlocked when the callback is called.

ASTERISK-23013 #close

Change-Id: Id9980419909e811f89484950ed46ef117b9eb990
2016-07-21 17:11:28 -05:00
zuul 194d0f606b Merge "pbx: Create pbx_sw.c for management of 'struct ast_sw'." 2016-07-21 15:55:10 -05:00
zuul fbdeb01edf Merge "Add conditional support for noreturn functions." 2016-07-21 15:29:22 -05:00
Corey Farrell a36a174c4b pbx: Create pbx_sw.c for management of 'struct ast_sw'.
This changes context switches from a linked list to a vector, makes
'struct ast_sw' opaque to pbx.c.

Although ast_walk_context_switches 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
macros.
* ast_context_switches_count (AST_VECTOR_SIZE)
* ast_context_switches_get (AST_VECTOR_GET)

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

Change-Id: I08deb016df22eee8288eb03de62593e45a1f0998
2016-07-21 13:58:26 -04:00
zuul 3ca6407dab Merge "Makefile: Retain XML Declaration and DTD in docs." 2016-07-20 11:36:08 -05:00
zuul 7ff9bed7b0 Merge "Unit tests: Use AST_TEST_DEFINE in conditional code only." 2016-07-20 11:31:52 -05:00
zuul b1c45dc815 Merge "pbx: Create pbx_ignorepat.c for management of 'struct ast_ignorepat'." 2016-07-20 10:57:41 -05:00
zuul e51b40bd87 Merge "res_rtp_asterisk: Count a roll-over of the sequence number even on lost packets." 2016-07-20 10:29:19 -05:00
zuul b93c602198 Merge "res_pjsip_mwi: remove unneeded check on endpoint's contacts." 2016-07-20 09:57:58 -05:00
Corey Farrell 8f6e9ffcc6 Add conditional support for noreturn functions.
This adds support for tagging functions with the noreturn attribute.
If DO_CRASH is enabled then ast_do_crash never returns.  If AST_DEVMODE
and DO_CRASH are enabled then failed assertions never return.  This can
resolve a large number of false positives with static analyzers.

ASTERISK-26220 #close

Change-Id: Icfb61e5fe54574eced4c3e88b317244f467ec753
2016-07-19 22:45:10 -05:00
zuul 333a0fed33 Merge "Makefile: Suppress echoing of target 'config' again." 2016-07-19 17:35:59 -05:00
Alexander Traud 6fca2b3bf0 Makefile: Retain XML Declaration and DTD in docs.
Since Asterisk 12, the documentation got an XML Stylesheet. Because of a typo,
the XML Declaration and DTD were overwritten by this.

ASTERISK-26212 #close

Change-Id: If5ee4625068042e98ab3fcb22a25e2f15d0c68bd
2016-07-19 12:06:10 +02:00
Corey Farrell cf1188a1be Unit tests: Use AST_TEST_DEFINE in conditional code only.
If AST_TEST_DEFINE is not conditional to TEST_FRAMEWORK it produces dead
code.  This places all existing unit tests into a conditional block if
they weren't already.

ASTERISK-26211 #close

Change-Id: I8ef83ee11cbc991b07b7a37ecb41433e8c734686
2016-07-18 19:40:22 -04:00
Alexei Gradinari e9daa34261 res_pjsip_mwi: remove unneeded check on endpoint's contacts.
The function create_mwi_subscriptions_for_endpoint checks
if there is active contacts by retrieving aors and contacts.

This function is used to create all unsolicited mwi subscriptions
on startup and is used when contact added.

In both cases it's not necessary to check if there are contacts.
The contacts are needed when asterisk sends mwi.

ASTERISK-26200 #close

Change-Id: I98e43bdc97f3c0829951cd9bf5f3c6348c6ac1fa
2016-07-18 10:24:05 -04:00
Joshua Colp 943bb48b59 Merge "pbx: Create pbx_include.c for management of 'struct ast_include'." 2016-07-18 07:07:36 -05:00
Alexander Traud cb5e3445be res_rtp_asterisk: Count a roll-over of the sequence number even on lost packets.
With this change, the initial RTP sequence number is randomly chosen not between
0 and 65535 (0xffff) but 0 and 32767 (0x7fff). This assures, the roll-over
counter (ROC) synchronization is not lost for sRTP, when the very first RTP
packets get lost; see http://srtp.sourceforge.net/faq.html#Q6

ASTERISK-26207 #close

Change-Id: I9a527e3aa3ce8f3becc5131d7ba32b57b5845464
2016-07-18 12:19:56 +02:00
Alexander Traud 6428580e7f Makefile: Suppress echoing of target 'config' again.
ASTERISK-26038 #close

Change-Id: I5746cf639f3fdc6332e8a97cf01f979e30bf403f
2016-07-18 11:22:55 +02:00
Corey Farrell e2e8713b84 pbx: Create pbx_ignorepat.c for management of 'struct ast_ignorepat'.
This changes context ignore patterns from a linked list to a vector,
makes 'struct ast_ignorepat' opaque to pbx.c.

Although ast_walk_context_ignorepats 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
macros.
* ast_context_ignorepats_count (AST_VECTOR_SIZE)
* ast_context_ignorepats_get (AST_VECTOR_GET)

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

Change-Id: I78f2157d275ef1b7d624b4ff7d770d38e5d7f20a
2016-07-18 03:21:43 -04:00
zuul 26b4760808 Merge "app_queue: Only remove queue member from pending when state changes." 2016-07-15 11:57:52 -05:00
Corey Farrell be36bd7ca5 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
macros.
* 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
functions.

Change-Id: Ib5c882e27cf96fb2aec67a39c18b4c71c9c83b60
2016-07-15 05:34:29 -04:00
Corey Farrell d3348c51b5 features.c: Remove unneeded adsi.h include.
adsi.h is no longer used by features.c since parking was moved to a
module.

Change-Id: I2248b8a455225a17cb6ddaafd6c20c511a1eaf59
2016-07-14 21:23:47 -05:00
Mark Michelson 273052f404 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
2016-07-14 15:59:49 -05:00
zuul 3cf33dd4e7 Merge "translate: explicit format destination not properly set" 2016-07-14 13:40:43 -05:00
zuul afcc519dff Merge "threadpool: Fix leak in ast_threadpool_serializer_group error path." 2016-07-14 13:33:52 -05:00
zuul 707dbcbcd1 Merge "pbx: Fix leak of timezone for time based includes." 2016-07-14 12:14:44 -05:00
zuul bea3e9b6fb Merge "BuildSystem: Avoid obsolete warning with pthread.m4 on autoconf." 2016-07-14 12:05:19 -05:00
Joshua Colp 89f0a7d3f4 Merge "res_rtp_asterisk: Enable Forward Secrecy (PFS) for DTLS." 2016-07-14 10:32:54 -05:00
zuul f0f137e5bd Merge "stasis_endpoint.c: Fix contactstatus_to_json()." 2016-07-14 09:37:00 -05:00
zuul 153875be24 Merge "pjsip_options.c: Fix container operation." 2016-07-14 08:37:06 -05:00
zuul 43596895f9 Merge "pjsip_configuration.c: Misc cleanups." 2016-07-14 08:37:05 -05:00
Joshua Colp 31967dacdf 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
patches:
  app_queue.diff submitted by Richard Miller (license 5685)

Change-Id: Ie5a7f17a44f98e9159e9b85009ce3f8393aa78c0
2016-07-14 07:53:17 -05:00
Joshua Colp 5703374cc5 Merge "chan_sip: Fix reference leak in mwi_event_cb" 2016-07-14 04:54:48 -05:00
Corey Farrell f3608b50d7 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
2016-07-14 02:59:56 -05:00
zuul 2567e57624 Merge "res/res_corosync: Raise a Stasis message on node join/leave events" 2016-07-13 22:11:40 -05:00
zuul 3849f23bff Merge "res/res_pjsip_session: Check for presence of an active negotiator" 2016-07-13 18:48:39 -05:00
Kevin Harwell 63ac4c9487 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
2016-07-13 17:45:27 -05:00
Richard Mudgett 2f26512fd8 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
2016-07-13 15:12:19 -05:00
Richard Mudgett bc1ff41be7 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
2016-07-13 15:12:18 -05:00
Richard Mudgett eabcfeeaa3 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
persistent_endpoint_contact_deleted_observer()

Change-Id: Id8e34f5d09e7eebac3af22501c44c1110a3e29d8
2016-07-13 15:12:18 -05:00
Corey Farrell f73ddde7d4 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
2016-07-13 14:10:41 -05:00
Corey Farrell fd54d69feb 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
2016-07-13 11:47:56 -05:00
Alexander Traud 85212f2799 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
patches:
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
2016-07-13 18:46:59 +02:00
Matt Jordan 0d487b53b1 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
2016-07-13 09:12:04 -05:00
Matt Jordan c49833653b 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
2016-07-13 09:11:46 -05:00
Matt Jordan f12311ee69 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
cluster.

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
2016-07-13 09:11:37 -05:00
Alexander Traud a3f4141f6f 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
2016-07-13 16:00:29 +02:00
zuul 73d8cb587d Merge "rest_api/channels: Fix multiple issues with create and dial" 2016-07-13 08:08:41 -05:00
Joshua Colp e049248161 Merge "res_pjsip: Fix statsd regression." 2016-07-13 07:41:47 -05:00
Joshua Colp c48016e2f2 Merge "BuildSystem: Allow own CFLAGS on ./configure." 2016-07-13 06:42:57 -05:00
Joshua Colp c2a72e6aa6 Merge "install_prereq: Checkout of libSRTP 1.5.x." 2016-07-12 19:30:38 -05:00