5 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

5 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"

5 years agoPJSIP: provide transport type with received messages
Scott Griepentrog [Tue, 21 Jun 2016 15:53:05 +0000 (10:53 -0500)]
PJSIP: provide transport type with received messages

The receipt of a SIP MESSAGE may occur over any transport including TCP
and TLS. When the message is received, the original URI is added to the
message in the field PJSIP_RECVADDR, but this is insufficient to ensure
a reply message can reach the originating endpoint. This patch adds the
PJSIP_TRANSPORT field populated with the transport type.

ASTERISK-26132 #close

Change-Id: I28c4b1e40d573a056c81deb213ecf53e968f725e

5 years agoBuildSystem: Avoid obsolete warning with HELP_STRING on autoconf.
Alexander Traud [Tue, 21 Jun 2016 13:01:40 +0000 (15:01 +0200)]
BuildSystem: Avoid obsolete warning with HELP_STRING on autoconf.

Some configure scripts used both AC_HELP_STRING and its replacement
AS_HELP_STRING. For consistency and to avoid obsolete warnings, those were
changed to AS_HELP_STRING.


Change-Id: I8aad4fd2bdee40aa2a31ce3339a1eb33ff4f5b0f

5 years agoMerge "fix: memory leaks, resource leaks, out of bounds and bugs"
zuul [Tue, 21 Jun 2016 12:26:12 +0000 (07:26 -0500)]
Merge "fix: memory leaks, resource leaks, out of bounds and bugs"

5 years agoMerge "app_voicemail.c: Fix IMAP compile error."
zuul [Mon, 20 Jun 2016 19:45:16 +0000 (14:45 -0500)]
Merge "app_voicemail.c: Fix IMAP compile error."

5 years agoMerge "http: leverage 'bindaddr' for TLS in http.conf"
zuul [Mon, 20 Jun 2016 18:28:12 +0000 (13:28 -0500)]
Merge "http: leverage 'bindaddr' for TLS in http.conf"

5 years agoapp_voicemail.c: Fix IMAP compile error.
Richard Mudgett [Mon, 20 Jun 2016 17:13:27 +0000 (12:13 -0500)]
app_voicemail.c: Fix IMAP compile error.

Fix compile error introduced by the patch for

Change-Id: I5b02876266f2824f4cec2b54d6ff4db5de5778d3

5 years agofix: memory leaks, resource leaks, out of bounds and bugs
Alexei Gradinari [Fri, 17 Jun 2016 18:51:57 +0000 (14:51 -0400)]
fix: memory leaks, resource leaks, out of bounds and bugs

ASTERISK-26119 #close

Change-Id: Iecbf7d0f360a021147344c4e83ab242fd1e7512c

5 years agoARI: Ensure announcer channels are destroyed.
Mark Michelson [Mon, 13 Jun 2016 22:40:07 +0000 (17:40 -0500)]
ARI: Ensure announcer channels are destroyed.

Announcer channels were not being destroyed because the
stasis_app_control structure that referenced them was not being
destroyed. The control structure was not being destroyed because it was
not being unlinked from its container. It was not being unlinked from
its container because the after bridge callback for the announcer
channel was not being run. The after bridge callback was not being run
because the after bridge datastore was not being removed from the
channel on destruction. The channel was not being destroyed because the
hangup that used to destroy the channel was now only reducing the
reference count to one. The reference count of the channel was only
being reduced to one because the stasis_app_control structure was
holding the final reference...

The control structure used to not keep a reference to the channel, so
that loop described above did not happen.

The solution is to manually remove the control structure from its
container when the playback on a bridge is complete.

ASTERISK-26083 #close
Reported by Joshua Colp

Change-Id: I0ddc0f64484ea0016245800b409b567dfe85cfb4

5 years agohttp: leverage 'bindaddr' for TLS in http.conf
Alexander Traud [Mon, 20 Jun 2016 13:05:09 +0000 (15:05 +0200)]
http: leverage 'bindaddr' for TLS in http.conf

The internal HTTP/WebSocket server supports both TCP and TLS, which can be
activated separately via the file http.conf. The source code intends to re-use
the TCP parameter 'bindaddr' for TLS, even if 'tlsbindaddr' is not specified
explicitly. This did not work because of a typo. This change resolves this typo.

ASTERISK-26126 #close

Change-Id: I5efb0409ae12044dfb3495b6b97b6d40a8c9c51f

5 years agoMerge "Add support for OGG/Speex file format"
Joshua Colp [Fri, 17 Jun 2016 19:03:57 +0000 (14:03 -0500)]
Merge "Add support for OGG/Speex file format"

5 years agoMerge "chan_sip: bigger buffers for headers, better failure mode"
zuul [Thu, 16 Jun 2016 22:59:32 +0000 (17:59 -0500)]
Merge "chan_sip: bigger buffers for headers, better failure mode"

5 years agores_pjsip_transport_management.c: Misc cleanups to survive shutdown.
Richard Mudgett [Wed, 18 May 2016 22:37:27 +0000 (17:37 -0500)]
res_pjsip_transport_management.c: Misc cleanups to survive shutdown.

* In unload_module(), reordered destroying things to minimize the window
that the global transports container could be used by other threads on
shutdown.  When shutting down you need to stop things in the opposite
order of creation.

* Put the global transports container into an AO2_GLOBAL_OBJ_STATIC to
eliminate the crash potential by other threads using the container on

* Made struct monitored_transport.sip_received not use
ast_atomic_fetchadd_int() since it is used as a boolean value that is only
set TRUE.  It was previously incremented for every received SIP message
and could theoretically overflow.

* In monitored_transport_state_callback(), allocated the monitored
transport object without a lock since the lock was unused.

* In keepalive_global_loaded(), removed releasing the transports container
if the keepalive_thread could not be started.  I set it up to be tried
again if the user reloads the configuration.

Change-Id: I8d12d16ef564290fa6d25a32334bb5ce8fdf87ff

5 years agores_pjsip.c: Add check that timer actually got scheduled.
Richard Mudgett [Wed, 6 Jan 2016 01:08:24 +0000 (19:08 -0600)]
res_pjsip.c: Add check that timer actually got scheduled.

Change-Id: Iabaa2e5dccf0762c258101ea0eb1487cf6959ad1

5 years agoMerge "res_pjsip_session.c: Reorganize ast_sip_session_terminate()."
zuul [Tue, 14 Jun 2016 18:36:41 +0000 (13:36 -0500)]
Merge "res_pjsip_session.c: Reorganize ast_sip_session_terminate()."

5 years agores_rtp_multicast.c: Fix warning message typo.
Richard Mudgett [Mon, 13 Jun 2016 18:33:53 +0000 (13:33 -0500)]
res_rtp_multicast.c: Fix warning message typo.

Change-Id: Ic9928208b9957e09866abe3d9649030942ec52b3

5 years agores_pjsip_session.c: Reorganize ast_sip_session_terminate().
Richard Mudgett [Fri, 12 Feb 2016 00:15:31 +0000 (18:15 -0600)]
res_pjsip_session.c: Reorganize ast_sip_session_terminate().

Change-Id: I68a2128bcba4830985d2d441e70dfd1ac5bd712b

5 years agoMerge "core: Not the configured but granted number of possible file descriptors."
zuul [Fri, 10 Jun 2016 20:50:35 +0000 (15:50 -0500)]
Merge "core: Not the configured but granted number of possible file descriptors."

5 years agocore: Not the configured but granted number of possible file descriptors.
Alexander Traud [Wed, 8 Jun 2016 11:15:15 +0000 (13:15 +0200)]
core: Not the configured but granted number of possible file descriptors.

With CLI "core show settings", simply the parameter maxfiles of the file
asterisk.conf was shown. If that parameter was not set, nothing was displayed
although the environment might have set a default number itself. Or if maxfiles
were not granted (completely), still maxfiles was shown. Now, the maximum number
of possible file descriptors in the environment is shown.


Change-Id: I2df5c58863b5007b34b77adbe28b885dfcdf7e0b

5 years agoMerge "astfd: With RLIMIT_NOFILE only the current value is sensible."
Joshua Colp [Fri, 10 Jun 2016 18:46:48 +0000 (13:46 -0500)]
Merge "astfd: With RLIMIT_NOFILE only the current value is sensible."

5 years agotranslate: Enables native Packet-Loss Concealment (PLC) for supporting codecs.
Joshua Colp [Fri, 10 Jun 2016 15:39:27 +0000 (12:39 -0300)]
translate: Enables native Packet-Loss Concealment (PLC) for supporting codecs.

This reverts commit 5bfef2a8b4674382f959b21a3b8e14cf1d942bab as it
caused fax test failures.


Change-Id: I79de974dc4f63a1cafe0d2509169fd9a6b3cbaf4

5 years agoastfd: With RLIMIT_NOFILE only the current value is sensible.
Alexander Traud [Wed, 8 Jun 2016 11:05:22 +0000 (13:05 +0200)]
astfd: With RLIMIT_NOFILE only the current value is sensible.

With menuselect "DEBUG_FD_LEAKS" and CLI "core show fd", both the maximum max
and current max of possible file descriptors were shown. Both show the same
value always. Not to confuse users, just the current maximum is shown now.


Change-Id: I49cf7952d73aec9e3f6a88942842c39be18380fa

5 years agoMerge "cel: Ensure only one dial status per channel exists."
zuul [Fri, 10 Jun 2016 03:38:52 +0000 (22:38 -0500)]
Merge "cel: Ensure only one dial status per channel exists."

5 years agoMerge "ARI: Ensure proper channel state on operations."
zuul [Fri, 10 Jun 2016 02:50:07 +0000 (21:50 -0500)]
Merge "ARI: Ensure proper channel state on operations."

5 years agoMerge "test_http_media_cache: Fix failing test."
zuul [Fri, 10 Jun 2016 02:50:05 +0000 (21:50 -0500)]
Merge "test_http_media_cache: Fix failing test."

5 years agoMerge "chan_sip: Support auth username for callbackextension feature"
zuul [Fri, 10 Jun 2016 02:35:42 +0000 (21:35 -0500)]
Merge "chan_sip: Support auth username for callbackextension feature"

5 years agoMerge "res_pjsip_registrar.c: Eliminate rx REGISTER request race condition."
Joshua Colp [Thu, 9 Jun 2016 21:45:59 +0000 (16:45 -0500)]
Merge "res_pjsip_registrar.c: Eliminate rx REGISTER request race condition."

5 years agoMerge "stasis: Add setting subscription congestion levels."
Joshua Colp [Thu, 9 Jun 2016 21:45:54 +0000 (16:45 -0500)]
Merge "stasis: Add setting subscription congestion levels."

5 years agoMerge "sorcery: Add setting object type congestion levels."
Joshua Colp [Thu, 9 Jun 2016 21:45:48 +0000 (16:45 -0500)]
Merge "sorcery: Add setting object type congestion levels."

5 years agoMerge "taskprocessors: Implement high/low water mark alerts."
Joshua Colp [Thu, 9 Jun 2016 21:45:44 +0000 (16:45 -0500)]
Merge "taskprocessors: Implement high/low water mark alerts."

5 years agoMerge "res_pjsip_session: Use distributor serializer for incoming calls."
Joshua Colp [Thu, 9 Jun 2016 21:45:39 +0000 (16:45 -0500)]
Merge "res_pjsip_session: Use distributor serializer for incoming calls."

5 years agoMerge "res_pjsip_pubsub.c: Recreate subscriptions using distributor serializer."
Joshua Colp [Thu, 9 Jun 2016 21:45:34 +0000 (16:45 -0500)]
Merge "res_pjsip_pubsub.c: Recreate subscriptions using distributor serializer."

5 years agoMerge "res_pjsip_pubsub.c: Use distributor serializer for incoming subscriptions."
Joshua Colp [Thu, 9 Jun 2016 21:45:29 +0000 (16:45 -0500)]
Merge "res_pjsip_pubsub.c: Use distributor serializer for incoming subscriptions."

5 years agoMerge "pjsip_distributor.c: Consistently pick a serializer for messages."
Joshua Colp [Thu, 9 Jun 2016 21:45:24 +0000 (16:45 -0500)]
Merge "pjsip_distributor.c: Consistently pick a serializer for messages."

5 years agoMerge "pjsip_distributor.c: Ignore messages until fully booted."
zuul [Thu, 9 Jun 2016 21:17:33 +0000 (16:17 -0500)]
Merge "pjsip_distributor.c: Ignore messages until fully booted."

5 years agocel: Ensure only one dial status per channel exists.
Joshua Colp [Tue, 7 Jun 2016 23:45:37 +0000 (20:45 -0300)]
cel: Ensure only one dial status per channel exists.

CEL wrongly assumed that a channel would only have a single dial
event on it. This is incorrect. Particularly in a queue each
call attempt to a member will result in a dial event, adding
a new dial status in CEL without removing the old one. This
would cause the container to grow with only one dial status
being removed when the channel went away. The other dial status
entries would remain leaking memory.

This change fixes the memory leak by ensuring that only one dial
status will only ever exist for each channel.

The behavior during the scenario where multiple events are received
has also been improved. For failure cases the first failure will
be the dial status. If an answer dial status is received, though,
it will take priority and the dial status for the channel will be

Memory usage has also been decreased by storing the minimal
amount of information and the code has been cleaned up slightly.

ASTERISK-25262 #close

Change-Id: I5944eb923db17b6a0faa7317ff6abc9307c009fe

5 years agoARI: Ensure proper channel state on operations.
Mark Michelson [Wed, 1 Jun 2016 18:48:00 +0000 (13:48 -0500)]
ARI: Ensure proper channel state on operations.

ARI was recently outfitted with operations to create and dial channels.
This leads to the ability to try funny stuff. You could create a channel
and then immediately try to play back media on it. You could create a
channel, dial it, and while it is ringing attempt to make it continue in
the dialplan.

This commit attempts to fix this by adding a channel state check to
operations that should not be able to operate on outbound channels that
have not yet answered. If a channel is in an invalid state, we will send
a 412 response.

ASTERISK-26047 #close
Reported by Mark Michelson

Change-Id: I2ca51bf9ef2b44a1dc5a73f2d2de35c62c37dfd8

5 years agotest_http_media_cache: Fix failing test.
Mark Michelson [Wed, 8 Jun 2016 16:27:41 +0000 (11:27 -0500)]
test_http_media_cache: Fix failing test.

The retrieve_cache_control_directives test has been failing occasionally
in Jenkins. The apparent failure occurs when attempting to validate the
expiration of the retrieved file.

After reproducing, the problem was pretty clear. At the beginning of the
test, the current time is retrieved. The seconds value of this timestamp
is X. When the file is retrieved, res_http_media_cache calculates the
expiration and in doing so retrieves the current time. In most cases,
since the test executes quickly, it will also retrieve a timestamp with
X seconds. However, if the test starts very near to when the timestamp
seconds are set to increment, res_http_media_cache may retrieve a
timestamp with X+1 seconds instead.

The test attempted to account for this by allowing a tolerance of 1
second when validating the expiration. However, the problem was that the
comparisons being used in the validation used > and < operations. This
meant that values that fell within the tolerance (because they equaled
the upper bound of the tolerance) would fail.

The solution is to use >= and <= operators in the expiration validation.

However, I estimated that while the one second tolerance should be
fine on most machines, it would still be possible on a very slow machine
to end up falling outside the one second tolerance. So I have also
relaxed the tolerance of expiration validation to be three seconds

The final change here is to add a debug message when validating
expiration so that we can see what values are being compared.

ASTERISK-25959 #close
Reported by Joshua Colp

Change-Id: Ic1a0e10722c1c5d276d5a4d6a67136d6ec26c247

5 years agoAdd support for OGG/Speex file format
Timo Teräs [Fri, 3 Jun 2016 06:20:39 +0000 (09:20 +0300)]
Add support for OGG/Speex file format

ASTERISK-18995 #close

Change-Id: I98518bd28fc8f95668b3fe27d2cab45045ff3f7a

5 years agoMerge "chan_pjsip: Lock channel when checking for RTP changes."
zuul [Thu, 9 Jun 2016 18:53:58 +0000 (13:53 -0500)]
Merge "chan_pjsip: Lock channel when checking for RTP changes."

5 years agocdr.c: Remove assert in base_process_dial_end
George Joseph [Thu, 9 Jun 2016 15:33:48 +0000 (09:33 -0600)]
cdr.c: Remove assert in base_process_dial_end

Scenario: Caller blonde transfer
Bob calls Charlie who answers.
Bob puts Charlie on hold and calls Alice.
Before Alice answers, Bob transfers Charlie to Alice.

Charlie's channel triggers an assert because he gets an "ANSWERED"
event even though he never dialed anything. With recent changes to dial
events, this is now a valid scenario so the assert needed to be removed.

ASTERISK-26103 #close

Change-Id: I2679b517b696e7952ab7fb29403df9140e7d1de2

5 years agochan_pjsip: Lock channel when checking for RTP changes.
Mark Michelson [Thu, 9 Jun 2016 15:37:53 +0000 (10:37 -0500)]
chan_pjsip: Lock channel when checking for RTP changes.

bridge_native_rtp can call into an RTP-capable channel driver in order
for the driver to update information about who the channel is
communicating with. For SIP channel drivers, this means deactivating
RTCP and sending a reinvite so that the endpoints can communicate

bridge_native_rtp does the right thing and has the channel locked when
calling into the channel driver. chan_pjsip can't alter session
properties in this thread, though. chan_pjsip queues a task on the
session serializer in order to update properties there.

The problem is that this queued task was not locking the channel. This
meant that the queued task could attempt to deactivate RTCP at the same
time that the channel thread was attempting to process an incoming RTCP
packet. This could lead to a crash.

This patch fixes the issue by locking the channel in the queued task
when altering RTP properties.

ASTERISK-26092 #close
Reported by Niklas Larsson

Change-Id: I3464e226a3c41f6b915f97891e07fa1599e2a159

5 years agores_pjsip_registrar.c: Eliminate rx REGISTER request race condition.
Richard Mudgett [Sat, 4 Jun 2016 03:44:46 +0000 (22:44 -0500)]
res_pjsip_registrar.c: Eliminate rx REGISTER request race condition.

This patch fixes a race condition processing received REGISTER requests
and their retransmissions caused by REGISTER requests being processed by
two threads.  The "sip_transaction Unable to register REGISTER transaction
(key exists)" message is a notable symptom of this issue.

This issue was more likely to happen before the pjsip/distributor
serializers were created.  Instead of steps one and two below placing the
REGISTER messages into the same pjsip/distributor they were placed in
random pjsip/default serializers.

1) REGISTER requests come in and get placed on the pjsip/distributor

2) Before the first request is processed a retransmission comes in and is
placed on the same pjsip/distributor serializer.

3) The first request goes up the pjsip stack and is then shunted off to
the pjsip/aor/<aor> serializer.

4) Before the first request is completed processing in the pjsip/aor/<aor>
serializer, the second request goes up the pjsip stack and is also shunted
off to the pjsip/aor/<aor> serializer.

5) The first request completes processing and sends out its response.

6) The second request completes processing and tries to send out its
response but pjlib complains that the REGISTER transaction key already

7) Sadness ensues.

* The race is eliminated by removing the pjsip/aor/<aor> serializer and
continuing the processing in the pjsip/distributor serializer.  Now any
retransmissions queued in the pjsip/distributor serializer will be
processed after the first message is completely processed.

ASTERISK-26088 #close
Reported by:  Richard Mudgett

Change-Id: I842d714346088bf717ea27437f1dd85bff0bab5a

5 years agostasis: Add setting subscription congestion levels.
Richard Mudgett [Fri, 3 Jun 2016 16:35:49 +0000 (11:35 -0500)]
stasis: Add setting subscription congestion levels.

Stasis subscriptions and message routers create taskprocessors to process
the event messages.  API calls are needed to be able to set the congestion
levels of these taskprocessors for selected subscriptions and message

* Updated CDR, CEL, and manager's stasis subscription congestion levels
based upon stress testing.  Increased the congestion levels to reduce the
potential for bursty call setup/teardown activity from triggering the
taskprocessor overload alert.  CDRs in particular need an extra high
congestion level because they can take awhile to process the stasis

Reported by:  Richard Mudgett

Change-Id: Id0a716394b4eee746dd158acc63d703902450244

5 years agosorcery: Add setting object type congestion levels.
Richard Mudgett [Thu, 2 Jun 2016 23:19:13 +0000 (18:19 -0500)]
sorcery: Add setting object type congestion levels.

Sorcery creates taskprocessors for object types to process object observer
callbacks.  An API call is needed to be able to set the congestion levels
of these taskprocessors for selected object types.

* Updated PJSIP's contact and contact_status sorcery object type observer
default congestion levels based upon stress testing.  Increased the
congestion levels to reduce the potential for bursty register/unregister
and subscribe/unsubscribe activity from triggering the taskprocessor
overload alert.

Reported by:  Richard Mudgett

Change-Id: I4542e83b556f0714009bfeff89505c801f1218c6

5 years agotaskprocessors: Implement high/low water mark alerts.
Richard Mudgett [Thu, 2 Jun 2016 21:08:19 +0000 (16:08 -0500)]
taskprocessors: Implement high/low water mark alerts.

When taskprocessors get backed up, there is a good chance that we are
being overloaded and need to defer adding new work to the system.

* Implemented a high/low water alert mechanism for modules to check if the
system is being overloaded and take appropriate action.  When a
taskprocessor is created it has default congestion levels set.  A
taskprocessor can later have those congestion levels altered for specific
needs if stress testing shows that the taskprocessor is a symptom of
overloading or needs to handle bursty activity without triggering an
overload alert.

* Add CLI "core show taskprocessor" low/high water columns.

* Fixed __allocate_taskprocessor() to not use RAII_VAR().  RAII_VAR() was
never a good thing to use when creating a taskprocessor because of the
nature of how its references needed to be cleaned up on a partial

* Made res_pjsip's distributor check if the taskprocessor overload alert
is active before placing a message representing brand new work onto a
distributor serializer.

Reported by:  Richard Mudgett

Change-Id: I182f1be603529cd665958661c4c05ff9901825fa

5 years agores_pjsip_session: Use distributor serializer for incoming calls.
Richard Mudgett [Fri, 27 May 2016 22:31:52 +0000 (17:31 -0500)]
res_pjsip_session: Use distributor serializer for incoming calls.

We must continue using the serializer that the original INVITE came in on
for the dialog.  There may be retransmissions already enqueued in the
original serializer that can result in reentrancy and message sequencing

Outgoing call legs create the pjsip/outsess/<endpoint> serializers for
their dialogs.

Reported by:  Richard Mudgett

Change-Id: I24d7948749c582b8045d5389ba3f6588508adbbc

5 years agores_pjsip_pubsub.c: Recreate subscriptions using distributor serializer.
Richard Mudgett [Fri, 27 May 2016 21:28:39 +0000 (16:28 -0500)]
res_pjsip_pubsub.c: Recreate subscriptions using distributor serializer.

* Resolves potential reentrancy problems if system restarted in the middle
of subscription message transactions.

* Fixes memory leak recreating persistent subscriptions when the
subscription resource tree could not be created.

Reported by:  Richard Mudgett

Change-Id: I71e34d7ae8ed35a694f1030e820e2548c48697be

5 years agores_pjsip_pubsub.c: Use distributor serializer for incoming subscriptions.
Richard Mudgett [Fri, 27 May 2016 17:50:14 +0000 (12:50 -0500)]
res_pjsip_pubsub.c: Use distributor serializer for incoming subscriptions.

We must continue using the serializer that the original SUBSCRIBE came in
on for the dialog.  There may be retransmissions already enqueued in the
original serializer that can result in reentrancy and message sequencing
problems.  The "sip_transaction Unable to register SUBSCRIBE transaction
(key exists)" message is a notable symptom of this issue.

Outgoing subscriptions still create the pjsip/pubsub/<endpoint>
serializers for their dialogs.

Reported by:  Richard Mudgett

Change-Id: I18b00bb74a56747b2c8c29543a82440b110bf0b0

5 years agopjsip_distributor.c: Consistently pick a serializer for messages.
Richard Mudgett [Thu, 26 May 2016 22:35:04 +0000 (17:35 -0500)]
pjsip_distributor.c: Consistently pick a serializer for messages.

Incoming messages that are not part of a dialog or a recognized response
to one of our requests need to be sent to a consistent serializer.  Under
load we may be queueing retransmissions before we can process the original
message.  We don't need to throw these messages onto random serializers
and cause reentrancy and message sequencing problems.

* Created a pool of pjsip/distributor serializers that get picked by
hashing the call-id and remote tag strings of the received messages.

* Made ast_sip_destroy_distributor() destroy items in the reverse order of

Reported by:  Richard Mudgett

Change-Id: I2ce769389fc060d9f379977f559026fbcb632407

5 years agopjsip_distributor.c: Ignore messages until fully booted.
Richard Mudgett [Thu, 2 Jun 2016 17:51:31 +0000 (12:51 -0500)]
pjsip_distributor.c: Ignore messages until fully booted.

We should not be processing any incoming messages until we are fully
booted.  We may not have dialplan or other needed configuration loaded

ASTERISK-26089 #close
Reported by: Scott Griepentrog

Reported by:  Richard Mudgett

Change-Id: I584aefb4f34b885a8927e1f13a2c64babd606264

5 years agobuild: Fix ast_sockaddr initialization to be more portable
George Joseph [Thu, 9 Jun 2016 14:20:33 +0000 (08:20 -0600)]
build:  Fix ast_sockaddr initialization to be more portable

A change to glibc 2.22 changed the order of the sockadddr_storage
members which caused the places where we do an initialization of
ast_sockaddr with '{ { 0, 0, } }' to fail compilation.  Those
initializers (which we shouldn't have been using anyway) have been
replaced with memsets.

Change-Id: Idd1b3b320903d8771bfe221f0b015685de628fa4

5 years agoMerge "translate: Enables native Packet-Loss Concealment (PLC) for supporting codecs."
Joshua Colp [Thu, 9 Jun 2016 12:24:46 +0000 (07:24 -0500)]
Merge "translate: Enables native Packet-Loss Concealment (PLC) for supporting codecs."

5 years agoMerge "chan_sip: No rtpmap for static RTP payload IDs in SDP."
Joshua Colp [Thu, 9 Jun 2016 09:40:43 +0000 (04:40 -0500)]
Merge "chan_sip: No rtpmap for static RTP payload IDs in SDP."

5 years agoMerge "BuildSystem: Avoid 'ar cru' and use 'ar cr' instead."
Joshua Colp [Thu, 9 Jun 2016 09:40:37 +0000 (04:40 -0500)]
Merge "BuildSystem: Avoid 'ar cru' and use 'ar cr' instead."

5 years agoMerge "Detect and use proper libraries for musl toolchains"
Joshua Colp [Thu, 9 Jun 2016 09:40:30 +0000 (04:40 -0500)]
Merge "Detect and use proper libraries for musl toolchains"

5 years agoMerge "Fixes to include signal.h"
Joshua Colp [Thu, 9 Jun 2016 09:40:24 +0000 (04:40 -0500)]
Merge "Fixes to include signal.h"

5 years agoMerge "Make use of GLOB_BRACE and GLOB_NOMAGIC optional"
Joshua Colp [Thu, 9 Jun 2016 09:40:14 +0000 (04:40 -0500)]
Merge "Make use of GLOB_BRACE and GLOB_NOMAGIC optional"

5 years agoMerge "res_hep_{pjsip|rtcp}: Decline module loads if res_hep had not loaded"
Joshua Colp [Wed, 8 Jun 2016 22:17:38 +0000 (17:17 -0500)]
Merge "res_hep_{pjsip|rtcp}: Decline module loads if res_hep had not loaded"

5 years agoMerge "Fix res_search usage"
Joshua Colp [Wed, 8 Jun 2016 19:43:35 +0000 (14:43 -0500)]
Merge "Fix res_search usage"

5 years agoMerge "Fix #include poll.h and sys/cdefs.h"
Joshua Colp [Wed, 8 Jun 2016 19:43:13 +0000 (14:43 -0500)]
Merge "Fix #include poll.h and sys/cdefs.h"

5 years agoDetect and use proper libraries for musl toolchains
Timo Teräs [Fri, 3 Jun 2016 05:59:30 +0000 (08:59 +0300)]
Detect and use proper libraries for musl toolchains

Change-Id: I8d9b212f70813404b82918a3f99439e500d4bfcb

5 years agoFixes to include signal.h
Timo Teräs [Fri, 3 Jun 2016 05:57:02 +0000 (08:57 +0300)]
Fixes to include signal.h

POSIX defines signal.h. sys/signal.h should not be used as it is
c-library internal header which may or may not exist. Notably with
musl it generates warning of being incorrect.

Change-Id: Ia56b0aa1d84b5c590114867b1b384a624f39a6fc

5 years agores_hep_{pjsip|rtcp}: Decline module loads if res_hep had not loaded
Matt Jordan [Wed, 8 Jun 2016 17:26:29 +0000 (12:26 -0500)]
res_hep_{pjsip|rtcp}: Decline module loads if res_hep had not loaded

A crash can occur in res_hep_pjsip or res_hep_rtcp if res_hep has not
loaded and does not have a configuration file. Previously when this
occurred, checks were put in to see if the configuration was loaded
successfully. While this is a good idea - and has been added to the
offending function in res_hep - the reality is res_hep_pjsip and
res_hep_rtcp have no business running if res_hep isn't also running.

As such, this patch also adds a function to res_hep that returns whether
or not it successfully loaded. Oddly enough, ast_module_check returns
"everything is peachy" even if a module declined its load - so it cannot
be solely relied on. res_hep_pjsip and res_hep_rtcp now also check this
function to see if they should continue to load; if it fails, they
decline their load as well.

ASTERISK-26096 #close

Change-Id: I007e535fcc2e51c2ca48534f48c5fc2ac38935ea

5 years agoMerge "chan_rtp.c: Simplify options to UnicastRTP channel creation."
Joshua Colp [Wed, 8 Jun 2016 10:13:59 +0000 (05:13 -0500)]
Merge "chan_rtp.c: Simplify options to UnicastRTP channel creation."

5 years agoMerge "apps/app_voicemail.c and main/say.c: Add support for Icelandic language"
Joshua Colp [Wed, 8 Jun 2016 10:13:52 +0000 (05:13 -0500)]
Merge "apps/app_voicemail.c and main/say.c: Add support for Icelandic language"

5 years agoMerge "ari/resource_channels: Add 'formats' to channel create/originate"
Joshua Colp [Wed, 8 Jun 2016 10:13:37 +0000 (05:13 -0500)]
Merge "ari/resource_channels:  Add 'formats' to channel create/originate"

5 years agochan_sip: No rtpmap for static RTP payload IDs in SDP.
Alexander Traud [Wed, 8 Jun 2016 07:11:40 +0000 (09:11 +0200)]
chan_sip: No rtpmap for static RTP payload IDs in SDP.

This saves around 100 bytes when G.711, G.722, G.729, and GSM are advertised in
SDP. This reduces the chance to hit the MTU bearer of 1300 bytes for SIP over
UDP, if many codecs are allowed in Asterisk. This new feature is enabled
together with the optional feature compactheaders=yes via the file sip.conf.

ASTERISK-25578 #close

Change-Id: I16491b1937862de26f84fa0ffe679a6bab925044

5 years agoMerge "res_odbc: Implement a connection pool."
Joshua Colp [Tue, 7 Jun 2016 17:17:16 +0000 (12:17 -0500)]
Merge "res_odbc: Implement a connection pool."

5 years agores_odbc: Implement a connection pool.
Joshua Colp [Thu, 2 Jun 2016 17:04:45 +0000 (14:04 -0300)]
res_odbc: Implement a connection pool.

Testing has shown that our usage of UnixODBC is problematic
due to bugs within UnixODBC itself as well as the heavy weight
cost of connecting and disconnecting database connections, even
when pooling is enabled.

For users of UnixODBC 2.3.1 and earlier crashes would occur due
to insufficient protection of the disconnect operation. This was
fixed in UnixODBC 2.3.2 and above.

For users of UnixODBC 2.3.3 and higher a slow-down would occur
under heavy database use due to repeated connection establishment.
A regression is present where on each connection the database
configuration is cached again, with the cache growing out of

The connection pool implementation present in this change helps
to mitigate these issues by reducing how much we connect and
disconnect database connections. We also solve the issue of
crashes under UnixODBC 2.3.1 by defaulting the maximum number of
connections to 1, returning us to the previous working behavior.
For users who may have a fixed version the maximum concurrent
connection limit can be increased helping with performance.

The connection pool works by keeping a list of active connections.
If the connection limit has not been reached a new connection is
established. If the connection limit has been reached then the
request waits until a connection becomes available before

ASTERISK-26074 #close
ASTERISK-26054 #close

Change-Id: I6774bf4bac49a0b30242c76a09c403d2e856ecff

5 years agochan_sip: bigger buffers for headers, better failure mode
Vasil Kolev [Tue, 31 May 2016 14:10:29 +0000 (17:10 +0300)]
chan_sip: bigger buffers for headers, better failure mode

Currently chan_sip can give weird messages if the contacts don't
fit in the From: or To: headers. This fix changes the from,to and
invite variables to use ast_str, allocates and deallocates them and
resizes them if needed.

ASTERISK-26069 #close

Change-Id: I1b68fcbddca6f6cc7d7a92fe1cb0d5430282b2b3

5 years agoapps/app_voicemail.c and main/say.c: Add support for Icelandic language
Örn Arnarson [Mon, 6 Jun 2016 16:13:01 +0000 (16:13 +0000)]
apps/app_voicemail.c and main/say.c: Add support for Icelandic language

Icelandic has some weird grammar rules when dealing with dates and
numbers. There are different genders used depending on which number
you're dealing with, and only a handful of numbers do change depending
on the gender. There is also an implied gender in several cases.

This patch was originally written for asterisk 1.6, and has been in use
for several years without crashes. I cleaned it up a bit and rewrote
what was necessary for Asterisk 13.

The functions were copied from other similar languages and modified
where appropriate. If i recall correctly, the German and Danish
functions were used as a base.

Reported by: Örn Arnarson
Tested by: Örn Arnarson

Change-Id: Ib7d8bd7b0fede5767921ed821315b5b508c0e665

5 years agores_srtp: Instead of libSRTP use OpenSSL as random source.
Alexander Traud [Tue, 7 Jun 2016 10:45:34 +0000 (12:45 +0200)]
res_srtp: Instead of libSRTP use OpenSSL as random source.

Since libSRTP 1.5, its Random Number Generator (RNG) is not maintained anymore.
Therefore, the symbol RAND_bytes is used instead of crypto_get_random.

ASTERISK-24436 #close

Change-Id: Iea0bae4d4e3c9aa0926ea442b6484b5159789d96

5 years agoBuildSystem: Avoid 'ar cru' and use 'ar cr' instead.
Alexander Traud [Tue, 7 Jun 2016 07:16:02 +0000 (09:16 +0200)]
BuildSystem: Avoid 'ar cru' and use 'ar cr' instead.

In several internal library projects, the files are archived with the help of
'ar cr'. Only the projects editline and the Objective Open H.323 stack
implementation in C (ooh323c) use 'ar cru' instead. Recently, some platforms
changed the default parameters of AR which creates "/usr/bin/ar: `u' modifier
ignored since `D' is the default (see `U')". For consistency and to avoid this
message all projects use 'ar cr' now.

ASTERISK-26091 #close

Change-Id: I710a9b1c01c1b5a1931a646098c044c8161ead40

5 years agochan_rtp.c: Simplify options to UnicastRTP channel creation.
Richard Mudgett [Wed, 1 Jun 2016 21:57:36 +0000 (16:57 -0500)]
chan_rtp.c: Simplify options to UnicastRTP channel creation.

Change the awkward and not as flexible UnicastRTP options format

Where <options> can be standard Asterisk flag options:
c(<codec>) - Specify which codec/format to use such as 'ulaw'.
e(<engine>) - Specify which RTP engine to use such as 'asterisk'.

More option flags can be easily added later such as the codec's RTP
payload type to use when the codec does not have a static payload type

Change-Id: I0c297aaf09e2ee515536cb7437bb8042ff8ff3c9

5 years agotranslate: Enables native Packet-Loss Concealment (PLC) for supporting codecs.
Jaco Kroon [Mon, 2 May 2016 10:57:03 +0000 (12:57 +0200)]
translate: Enables native Packet-Loss Concealment (PLC) for supporting codecs.

ASTERISK-25629 #close

Change-Id: Ibfcf0670e094e9718d82fd9920f1fb2dae122006

5 years agocore/dial: New channel variable FORWARDERNAME
Alexei Gradinari [Wed, 25 May 2016 15:34:42 +0000 (11:34 -0400)]
core/dial: New channel variable FORWARDERNAME

Added a new channel variable FORWARDERNAME which indicates which
channel was responsible for a forwarding requests received on dial attempt.

Fixed a bug in the app_queue: FORWARD_CONTEXT is not used.

ASTERISK-26059 #close

Change-Id: I34e93e8c1b5e17776a77b319703c48c8ca48e7b2

5 years agoari/resource_channels: Add 'formats' to channel create/originate
George Joseph [Fri, 27 May 2016 19:49:42 +0000 (13:49 -0600)]
ari/resource_channels:  Add 'formats' to channel create/originate

If you create a local channel and don't specify an originator channel
to take capabilities from, we automatically add all audio formats to
the new channel's capabilities. When we try to make the channel
compatible with another, the "best format" functions pick the best
format available, which in this case will be slin192.  While this is
great for preserving quality, it's the worst for performance and
overkill for the vast majority of applications.

In the absense of any other information, adding all formats is the
correct thing to do and it's not always possible to supply an
originator so a new parameter 'formats' has been added to the channel
create/originate functions. It's just a comma separated list of formats
to make availalble for the channel. Example: "ulaw,slin,slin16".
'formats' and 'originator' are mutually exclusive.

To facilitate determination of format names, the format name has been
added to "core show codecs".

ASTERISK-26070 #close

Change-Id: I091b23ecd41c1b4128d85028209772ee139f604b

5 years agoMerge "core/manager: Add uptime field to FullyBooted"
Joshua Colp [Fri, 3 Jun 2016 13:09:52 +0000 (08:09 -0500)]
Merge "core/manager: Add uptime field to FullyBooted"

5 years agochan_sip: Support auth username for callbackextension feature
Timo Teräs [Fri, 3 Jun 2016 06:33:08 +0000 (09:33 +0300)]
chan_sip: Support auth username for callbackextension feature

ASTERISK-20527 #close

Change-Id: I659cf7f00836a09d09d146ad226a40477d731239

5 years agoMake use of GLOB_BRACE and GLOB_NOMAGIC optional
Timo Teräs [Fri, 3 Jun 2016 05:39:02 +0000 (08:39 +0300)]
Make use of GLOB_BRACE and GLOB_NOMAGIC optional

These flags are non-portable GNU extensions. Make their use
optional. This fixes complication error on e.g. musl c-library
based systems.

Change-Id: I0aa06efc62aa8995f091445c8b762a75a91042f3

5 years agoFix res_search usage
Timo Teräs [Thu, 2 Jun 2016 19:57:49 +0000 (22:57 +0300)]
Fix res_search usage

Resolver state is not part of res_search API. This fixes
compilation error:

dns.c:261:8: error: too many arguments to function 'res_search'
  ret = res_search(&dns_state,

Change-Id: Ia600a58557040df83f744da3dde23225293845a5

5 years agoFix #include poll.h and sys/cdefs.h
Timo Teräs [Thu, 2 Jun 2016 19:53:39 +0000 (22:53 +0300)]
Fix #include poll.h and sys/cdefs.h

POSIX defines poll.h, sys/poll.h should not be used at is c-library
internal header which may or may not exist. Notable in musl it
generates warning of being incorrect. And add explict include of
sys/cdefs.h where needed.

Change-Id: I142930df53fe7585a06b854b6faddc5301e024be

5 years agocore/manager: Add uptime field to FullyBooted
Niklas Larsson [Wed, 25 May 2016 13:45:08 +0000 (15:45 +0200)]
core/manager: Add uptime field to FullyBooted

Add Uptime and LastReload to event FullyBooted.

ASTERISK-26058 #close
Reported by: Niklas Larsson

Change-Id: I909b330801c0990d78df9b272ab0adc95aecb15e

5 years agoalembic: Fix migration.
Joshua Colp [Thu, 2 Jun 2016 09:59:06 +0000 (06:59 -0300)]
alembic: Fix migration.

The script was attempting
to use UniqueConstraint and failing. It was not imported and after
importing it also continued to fail.

I've changed the script to use the explicit name of the constraint

Change-Id: I2438b0be90b7ce583b47dd27983c0c1a02cea5b9

5 years agoMerge "pjsip_distributor.c: Use correct rdata info access method (Part 2)."
Joshua Colp [Wed, 1 Jun 2016 23:15:53 +0000 (18:15 -0500)]
Merge "pjsip_distributor.c: Use correct rdata info access method (Part 2)."

5 years agoMerge "logging,cdr,cel: Fix stringfield memory leak."
Joshua Colp [Wed, 1 Jun 2016 21:51:55 +0000 (16:51 -0500)]
Merge "logging,cdr,cel: Fix stringfield memory leak."

5 years agoMerge "pjproject_bundled: Move to pjproject 2.5"
Joshua Colp [Wed, 1 Jun 2016 20:13:48 +0000 (15:13 -0500)]
Merge "pjproject_bundled:  Move to pjproject 2.5"

5 years agologging,cdr,cel: Fix stringfield memory leak.
Richard Mudgett [Wed, 1 Jun 2016 18:57:53 +0000 (13:57 -0500)]
logging,cdr,cel: Fix stringfield memory leak.

The stringfields refactor to allow adding stringfields to the end of a
structure (f6f4cf459f43f072604927209b39646f84aaa2e2) exposed some
incomplete cleanup code by some stringfield users.

The most noticeable leaker is the logging system where there is a leak for
every log message generated.

ASTERISK-26078 #close
Reported by:  Etienne Lessard
      jira_asterisk_26078_v13.patch (license #5621) patch uploaded
      by Richard Mudgett

Change-Id: If6a08b31336b492c3de6f9dfd07c447f8d5a8782

5 years agoMerge "Expand the scope of Dial Events"
Joshua Colp [Tue, 31 May 2016 21:36:35 +0000 (16:36 -0500)]
Merge "Expand the scope of Dial Events"

5 years agopjsip_distributor.c: Use correct rdata info access method (Part 2).
Richard Mudgett [Tue, 31 May 2016 18:02:15 +0000 (13:02 -0500)]
pjsip_distributor.c: Use correct rdata info access method (Part 2).

The pjproject doxygen for rdata-> says to call
pjsip_rx_data_get_info() instead of accessing the struct member directly.
You need to call the function mostly because the function will generate
the struct member value if it is not already setup.

Change-Id: I4d519385a577f3e9d9193a88125e493cf17fa799

5 years agoMerge "followme: allow disabling callee prompt"
Joshua Colp [Tue, 31 May 2016 18:20:49 +0000 (13:20 -0500)]
Merge "followme: allow disabling callee prompt"

5 years agoMerge "ARI: Re-implement the ARI dial command, allowing for early bridging."
zuul [Tue, 31 May 2016 17:39:53 +0000 (12:39 -0500)]
Merge "ARI: Re-implement the ARI dial command, allowing for early bridging."

5 years agoMerge "res_pjsip_mwi_body_generator: Re-order the body items"
zuul [Tue, 31 May 2016 17:39:51 +0000 (12:39 -0500)]
Merge "res_pjsip_mwi_body_generator:  Re-order the body items"

5 years agoExpand the scope of Dial Events
Mark Michelson [Mon, 9 May 2016 20:00:56 +0000 (15:00 -0500)]
Expand the scope of Dial Events

Dial events up to this point have come in two flavors
* A Dial event with no status to indicate that dialing has begun
* A Dial event with a status to indicate that dialing has ended

With this change, Dial events have been expanded to also give
intermediate events, such as "RINGING", "PROCEEDING", and "PROGRESS".
This is especially useful for ARI dialing, as it gives the application
writer the opportunity to place a channel into an early bridge when
early media is detected.

AMI handles these in-progress dial events by sending a new event called
"DialState" that simply indicates that dial state has changed but has
not ended. ARI never distinguished between DialBegin and DialEnd, so no
change was made to the event itself.

Another change here relates to dial forwards. A forward-related event
was previously only sent when a channel was successfully able to forward
a call to a new channel. With this set of changes, if forwarding is
blocked, we send a Dial event with a forwarding destination but no
forwarding channel, since we were prevented from creating one. This is
again useful for ARI since application writers can now handle call
forward attempts from within their own application.

ASTERISK-25925 #close
Reported by Mark Michelson

Change-Id: I42cbec7730d84640a434d143a0d172a740995543

5 years agoMerge "res_pjsip: add "via_addr", "via_port", "call_id" to contact"
Joshua Colp [Tue, 31 May 2016 13:23:12 +0000 (08:23 -0500)]
Merge "res_pjsip: add "via_addr", "via_port", "call_id" to contact"

5 years agoMerge "res_pjsip: Add clarifying documentation to PJSIP_HEADER help text"
zuul [Tue, 31 May 2016 11:59:58 +0000 (06:59 -0500)]
Merge "res_pjsip: Add clarifying documentation to PJSIP_HEADER help text"

5 years agoMerge "multicast RTP: Add dialing options"
zuul [Tue, 31 May 2016 11:53:38 +0000 (06:53 -0500)]
Merge "multicast RTP: Add dialing options"

5 years agoMerge "res_pjsip: chatty verbose messages"
zuul [Tue, 31 May 2016 11:52:15 +0000 (06:52 -0500)]
Merge "res_pjsip: chatty verbose messages"