asterisk/asterisk.git
2 years agocore: Add digit filtering to ast_waitfordigit_full
Corey Farrell [Wed, 12 Jul 2017 18:24:36 +0000 (14:24 -0400)]
core: Add digit filtering to ast_waitfordigit_full

This adds a parameter to ast_waitfordigit_full which can be used to only
stop waiting when certain expected digits are received.  Any unexpected
DTMF digits are simply ignored.

This also creates a new dialplan application WaitDigit.

ASTERISK-27129 #close

Change-Id: Id233935ea3d13e71c75a0861834c5936c3700ef9

2 years agoMerge "app_stream_echo: misc bug fixes"
Joshua Colp [Wed, 12 Jul 2017 11:13:34 +0000 (06:13 -0500)]
Merge "app_stream_echo: misc bug fixes"

2 years agoMerge "res_rtp_asterisk: trigger source change control frame when dtls is established"
Joshua Colp [Wed, 12 Jul 2017 11:13:25 +0000 (06:13 -0500)]
Merge "res_rtp_asterisk: trigger source change control frame when dtls is established"

2 years agoMerge "res_musiconhold: Add kill_escalation_delay, kill_method to class"
Joshua Colp [Wed, 12 Jul 2017 10:48:01 +0000 (05:48 -0500)]
Merge "res_musiconhold:  Add kill_escalation_delay, kill_method to class"

2 years agoMerge "manager: Remove AMI "Queues" action."
Joshua Colp [Wed, 12 Jul 2017 09:25:45 +0000 (04:25 -0500)]
Merge "manager: Remove AMI "Queues" action."

2 years agoMerge "Avoid setting maxfiles for a remote asterisk"
Joshua Colp [Wed, 12 Jul 2017 09:24:43 +0000 (04:24 -0500)]
Merge "Avoid setting maxfiles for a remote asterisk"

2 years agoMerge "http.c: Reduce log spam"
Jenkins2 [Wed, 12 Jul 2017 00:42:10 +0000 (19:42 -0500)]
Merge "http.c:  Reduce log spam"

2 years agores_musiconhold: Add kill_escalation_delay, kill_method to class
George Joseph [Tue, 11 Jul 2017 12:26:27 +0000 (06:26 -0600)]
res_musiconhold:  Add kill_escalation_delay, kill_method to class

By default, when res_musiconhold reloads or unloads, it sends a HUP
signal to custom applications (and all descendants), waits 100ms,
then sends a TERM signal, waits 100ms, then finally sends a KILL
signal.  An application which is interacting with an external
device and/or spawns children of its own may not be able to exit
cleanly in the default times, expecially if sent a KILL signal, or
if it's children are getting signals directly from
res_musiconhoild.

* To allow extra time, the 'kill_escalation_delay'
  class option can be used to set the number of milliseconds
  res_musiconhold waits before escalating kill signals, with the
  default being the current 100ms.

* To control to whom the signals are sent, the "kill_method" class
  option can be set to "process_group" (the default, existing
  behavior), which sends signals to the application and its
  descendants directly, or "process" which sends signals only to the
  application itself.

Change-Id: Iff70a1a9405685a9021a68416830c0db5158603b

2 years agomanager: Remove AMI "Queues" action.
Benjamin Keith Ford [Wed, 5 Jul 2017 17:44:18 +0000 (12:44 -0500)]
manager: Remove AMI "Queues" action.

When performing the "Queues" action via AMI, it outputs the same
text that the Asterisk CLI outputs when running a "queue show"
command, which does not conform with the AMI spec. "QueueStatus"
already does what the "Queues" action should do, so instead of
correcting the output, the "Queues" action will be removed and
"QueueStatus" should be used instead.

ASTERISK-27073 #close
Reported by: Brian

Change-Id: Id11743859758255b69cc3a557750d7a56c6d16f8

2 years agoAvoid setting maxfiles for a remote asterisk
Tzafrir Cohen [Mon, 3 Jul 2017 12:30:37 +0000 (15:30 +0300)]
Avoid setting maxfiles for a remote asterisk

Setting maxfiles (maximum number of open files) has no practical
effect on a remote asterisk (rasterisk, rasterisk -x).

It has an ill effect of printing an extra message, which
may be annoying in case of -x.

ASTERISK-27105 #close

Change-Id: Iaf9eb344e4b4b517df91b736b27ec55f6a6921a2

2 years agohttp.c: Reduce log spam
George Joseph [Wed, 5 Jul 2017 20:31:43 +0000 (14:31 -0600)]
http.c:  Reduce log spam

Messages like "fwrite() failed: Connection reset by peer" are no
help whatsoever, especially since they can be caused simply by a
client disconnecting.

* Make those WARNINGs DEBUGs.
* Check the return from ast_iostream_printf of headers.

Change-Id: I17bd5f3621514152a7b2b263c801324c5e96568b

2 years agoMerge "res_pjsip: Fix crash with from_user containing invalid characters."
Jenkins2 [Tue, 11 Jul 2017 12:08:39 +0000 (07:08 -0500)]
Merge "res_pjsip: Fix crash with from_user containing invalid characters."

2 years agoMerge "json.c: Add backtrace log to find 'Invalid UTF-8 string' errors"
Jenkins2 [Mon, 10 Jul 2017 16:41:17 +0000 (11:41 -0500)]
Merge "json.c: Add backtrace log to find 'Invalid UTF-8 string' errors"

2 years agoMerge "res_rtp_asterisk.c: Fix TURN deadlock by using ICE session group lock."
Jenkins2 [Mon, 10 Jul 2017 16:19:16 +0000 (11:19 -0500)]
Merge "res_rtp_asterisk.c: Fix TURN deadlock by using ICE session group lock."

2 years agoMerge "bridge_native_rtp.c: Fix direct media video RTP instance ACL check."
Jenkins2 [Mon, 10 Jul 2017 15:53:11 +0000 (10:53 -0500)]
Merge "bridge_native_rtp.c: Fix direct media video RTP instance ACL check."

2 years agores_pjsip: Fix crash with from_user containing invalid characters.
Benjamin Keith Ford [Fri, 7 Jul 2017 16:19:13 +0000 (11:19 -0500)]
res_pjsip: Fix crash with from_user containing invalid characters.

If the from_user field contains certain characters (like @, {, ^, etc.),
PJSIP will return a null value for the URI when attempting to parse it.
This causes a crash when trying to dial out through a trunk that contains
these invalid characters in its from_user field.

This change checks the configuration and ensures that an endpoint will
not be created if the from_user contains an invalid character. It also
adds a null check to the PJSIP URI parsing as a backup.

ASTERISK-27036 #close
Reported by: Maxim Vasilev

Change-Id: I0396fdb5080604e0bdf1277464d5c8a85db913d0

2 years agoMerge "app_queue: Add priority to AMI QueueStatus"
George Joseph [Mon, 10 Jul 2017 14:50:37 +0000 (09:50 -0500)]
Merge "app_queue: Add priority to AMI QueueStatus"

2 years agojson.c: Add backtrace log to find 'Invalid UTF-8 string' errors
Richard Mudgett [Wed, 28 Jun 2017 00:27:43 +0000 (19:27 -0500)]
json.c: Add backtrace log to find 'Invalid UTF-8 string' errors

Change-Id: I9020ff9f2b3749904317c0c173f47a1bbed6f929

2 years agoMerge "app_voicemail: Cleanup ODBC connection handling"
Joshua Colp [Fri, 7 Jul 2017 21:38:21 +0000 (16:38 -0500)]
Merge "app_voicemail: Cleanup ODBC connection handling"

2 years agoMerge "core: Remove 'Data Retrieval API'"
Jenkins2 [Fri, 7 Jul 2017 20:42:56 +0000 (15:42 -0500)]
Merge "core: Remove 'Data Retrieval API'"

2 years agores_rtp_asterisk.c: Fix TURN deadlock by using ICE session group lock.
Richard Mudgett [Wed, 5 Jul 2017 18:39:45 +0000 (13:39 -0500)]
res_rtp_asterisk.c: Fix TURN deadlock by using ICE session group lock.

When a message is received on the TURN socket, the code processing the
message needs to call into the ICE/STUN session for further processing.
This code path locks the TURN group lock then the ICE/STUN group lock.  In
another thread an ICE/STUN timer can fire off to send a keep alive message
over the TURN socket.  In this code path, the ICE/STUN group lock is
obtained then the TURN group lock is obtained to send the packet.  A
classic deadlock case if the group locks are not the same.

* Made TURN get created using the ICE/STUN session's group lock.

NOTE: I was originally concerned that the ICE/STUN session can get
recreated by ice_reset_session() for an event like RTCP multiplexing
causing a change during SDP negotiation.  In this case the TURN group lock
would become different.  However, TURN is also recreated as part of the
ICE/STUN recreation in ice_create() when all known ICE candidates are
added to the new ICE session.  While the ICE/STUN and TURN sessions are
being recreated there is a period where the group locks could be
different.

ASTERISK-27023 #close
Patches:
    res_rtp_asterisk-turn-deadlock-fix.patch (license #6502)
        patch uploaded by Michael Walton (modified)

Change-Id: Ic870edb99ce4988a8c8eb6e678ca7f19da1432b9

2 years agoFix alembic branches
George Joseph [Thu, 6 Jul 2017 10:55:17 +0000 (04:55 -0600)]
Fix alembic branches

Change-Id: I04f607f084bda9b1b7f626e8e9735c37dc751187

2 years agoMerge "channel: Clear channel flag in error branch."
Joshua Colp [Wed, 5 Jul 2017 23:46:10 +0000 (18:46 -0500)]
Merge "channel: Clear channel flag in error branch."

2 years agoMerge "pjproject_bundled: Allow passing configure options to bundled"
Jenkins2 [Wed, 5 Jul 2017 22:59:39 +0000 (17:59 -0500)]
Merge "pjproject_bundled:  Allow passing configure options to bundled"

2 years agobridge_native_rtp.c: Fix direct media video RTP instance ACL check.
Richard Mudgett [Fri, 23 Jun 2017 16:17:51 +0000 (11:17 -0500)]
bridge_native_rtp.c: Fix direct media video RTP instance ACL check.

The video stream was using the audio stream RTP instance addresses to
check if the video RTP gets directed to an allowed direct media Access
Control List (ACL) address.  There is no guarantee that the video RTP
instance uses the same addresses as the audio RTP instance.

This looks like it has been a bug since v11 when direct media ACL was
first added to chan_sip and then faithfully reproduced through a couple
code refactorings into the new bridging architecture.

Change-Id: I8ddd56320e0eea769f3ceed3fa5b6bdfb51d681a

2 years agoMerge "bridge_native_rtp: Keep rtp instance refs on bridge_channel"
George Joseph [Wed, 5 Jul 2017 22:03:28 +0000 (17:03 -0500)]
Merge "bridge_native_rtp: Keep rtp instance refs on bridge_channel"

2 years agoMerge "chan_sip: Fix a typo for tlsbindaddr in autodomain (SIP Domain Support)."
Jenkins2 [Wed, 5 Jul 2017 21:37:39 +0000 (16:37 -0500)]
Merge "chan_sip: Fix a typo for tlsbindaddr in autodomain (SIP Domain Support)."

2 years agoMerge "chan_sip: Only when different, add TCP|TLS in autodomain (SIP Domain Support)."
Jenkins2 [Wed, 5 Jul 2017 21:29:45 +0000 (16:29 -0500)]
Merge "chan_sip: Only when different, add TCP|TLS in autodomain (SIP Domain Support)."

2 years agoMerge "pjsip_distributor.c: Fix deadlock with TCP type transports."
George Joseph [Wed, 5 Jul 2017 21:08:46 +0000 (16:08 -0500)]
Merge "pjsip_distributor.c: Fix deadlock with TCP type transports."

2 years agoMerge "pjsip_distributor.c: Fix unidentified_requests hash functions."
Jenkins2 [Wed, 5 Jul 2017 20:32:40 +0000 (15:32 -0500)]
Merge "pjsip_distributor.c: Fix unidentified_requests hash functions."

2 years agoMerge "chan_pjsip: Fix ability to send UPDATE on COLP"
Jenkins2 [Wed, 5 Jul 2017 19:17:23 +0000 (14:17 -0500)]
Merge "chan_pjsip:  Fix ability to send UPDATE on COLP"

2 years agocore: Remove 'Data Retrieval API'
Sean Bright [Wed, 5 Jul 2017 15:29:01 +0000 (11:29 -0400)]
core: Remove 'Data Retrieval API'

This API was not actively maintained, was not added to new modules
(such as res_pjsip), and there exist better alternatives to acquire the
same information, such as the ARI.

Change-Id: I4b2185a83aeb74798b4ad43ff8f89f971096aa83

2 years agochan_sip: Only when different, add TCP|TLS in autodomain (SIP Domain Support).
Alexander Traud [Mon, 3 Jul 2017 15:59:43 +0000 (17:59 +0200)]
chan_sip: Only when different, add TCP|TLS in autodomain (SIP Domain Support).

When sip.conf contained tcpenable=yes and autodomain=yes, the TCP domain was
added in any case, because of a local Boolean-negation error of the return value
of ast_sockaddr_cmp. After fixing this error for TCP and TLS, the TLS domain was
still always added with tlsenable=yes, because the domains were not compared
just on the address but also on the port – and TLS is always on a different port
than UDP/TCP.

ASTERISK-27106

Change-Id: I14fe9e319e238320b094016980445ef3a5b3337c

2 years agochan_sip: Fix a typo for tlsbindaddr in autodomain (SIP Domain Support).
Alexander Traud [Mon, 3 Jul 2017 15:38:32 +0000 (17:38 +0200)]
chan_sip: Fix a typo for tlsbindaddr in autodomain (SIP Domain Support).

Because of a copy-and-paste error when the struct ast_sockaddr changed,
tlsbindaddr was not added, when sip.conf contained autodomain=yes; see
"show sip domains" on the command-line interface (CLI) of Asterisk.

ASTERISK-27106

Change-Id: I3d0957150017c223136968ef1266f275d0d6695e

2 years agoapp_voicemail: Cleanup ODBC connection handling
Sean Bright [Thu, 29 Jun 2017 18:58:35 +0000 (14:58 -0400)]
app_voicemail: Cleanup ODBC connection handling

The primary focus of this patch is adding a missing call to
ast_odbc_release_obj(), but is also a general cleanup of the ODBC
related code in app_voicemail.

ASTERISK-27093 #close

Change-Id: I8e285142eaeb3146b4287a928276b70db76c902b

2 years agochannel: Clear channel flag in error branch.
Corey Farrell [Sat, 1 Jul 2017 04:57:31 +0000 (00:57 -0400)]
channel: Clear channel flag in error branch.

Clear channel flag AST_FLAG_END_DTMF_ONLY in ast_waitfordigit_full when
ast_read returns NULL.

ASTERISK-27100 #close

Change-Id: Id3039e9a4e74e0cb359f636c9fd0c9740ebf7d9d

2 years agoMerge "app_queue: Fix returning to dialplan when a queue is empty"
Jenkins2 [Fri, 30 Jun 2017 20:52:38 +0000 (15:52 -0500)]
Merge "app_queue: Fix returning to dialplan when a queue is empty"

2 years agopjsip_distributor.c: Fix deadlock with TCP type transports.
Richard Mudgett [Thu, 29 Jun 2017 23:27:20 +0000 (18:27 -0500)]
pjsip_distributor.c: Fix deadlock with TCP type transports.

When a SIP message comes in on a transport, pjproject obtains the lock on
the transport and pulls the data out of the socket.  Unlike UDP, the TCP
transport does not allow concurrent access.  Without concurrency the
transport lock is not released when the transport's message complete
callback is called.  The processing continues and eventually Asterisk
starts processing the SIP message.  The first thing Asterisk tries to do
is determine the associated dialog of the message to determine the
associated serializer.  To get the associated serializer safely requires
us to get the dialog lock.

To send a request or response message for a dialog, pjproject obtains the
dialog lock and then obtains the transport lock.  Deadlock can result
because of the opposite order the locks are obtained.

* Fix the deadlock by obtaining the serializer associated with the dialog
another way that doesn't involve obtaining the dialog lock.  In this case,
we use an ao2 container to hold the associated endpoint and serializer.
The new locks are held a brief time and won't overlap other existing lock
times.

ASTERISK-27090 #close

Change-Id: I9ed63f4da9649e9db6ed4be29c360968917a89bd

2 years agopjsip_distributor.c: Fix unidentified_requests hash functions.
Richard Mudgett [Thu, 29 Jun 2017 23:22:33 +0000 (18:22 -0500)]
pjsip_distributor.c: Fix unidentified_requests hash functions.

The OBJ_SEARCH_xxx defines should not be used as if they were individual
bits.  They represent a multi-bit enumeration value field.

Change-Id: I32abc9a475396dab02402a7014357dd94284e17b

2 years agoMerge "res_pjsip: Add DTMF INFO Failback mode"
Jenkins2 [Fri, 30 Jun 2017 16:57:00 +0000 (11:57 -0500)]
Merge "res_pjsip:  Add DTMF INFO Failback mode"

2 years agoMerge "res_rtp_asterisk: Fix issues with ICE renegotiation."
Joshua Colp [Fri, 30 Jun 2017 16:47:42 +0000 (11:47 -0500)]
Merge "res_rtp_asterisk: Fix issues with ICE renegotiation."

2 years agoapp_stream_echo: misc bug fixes
Kevin Harwell [Thu, 29 Jun 2017 20:06:21 +0000 (15:06 -0500)]
app_stream_echo: misc bug fixes

Fixed the following bugs:

* calls to stream_echo_write had the last two parameters swapped
* ast_read should have been ast_read_stream
* added a null check on the frame's subclass format

This also resets the update_sent flag upon receiving SRRCHANGE control frame.
This will then force a video update.

ASTERISK-26997

Change-Id: I6ad7c8253559b800800433c52339e7f5aa583566

2 years agores_rtp_asterisk: trigger source change control frame when dtls is established
Kevin Harwell [Thu, 29 Jun 2017 19:56:10 +0000 (14:56 -0500)]
res_rtp_asterisk: trigger source change control frame when dtls is established

There needed to be a way to notify handlers upstream that DTLS had been
established. This patch makes it so once DTLS has been estalished a source
change control frame is put into the read queue. Any handlers can then watch
for that frame and trigger off of it.

ASTERISK-27096 #close

Change-Id: I27ff344f5a8c691a1890dfe3254a4b1a49e7f4a0

2 years agopjproject_bundled: Allow passing configure options to bundled
George Joseph [Fri, 30 Jun 2017 13:31:52 +0000 (07:31 -0600)]
pjproject_bundled:  Allow passing configure options to bundled

There wasn't any good way to pass options like --host or --build
down to the pjproject configure which makes cross-compiling difficult.

* Added a new PJPROJECT_CONFIGURE_OPTS environment variable which
  can be used to pass arbitrary options to pjproject configure.
* Automatically set the pjproject configure --host and --build
  options to match those supplied for the asterisk configure.

ASTERISK-27097 #close
Reported-by: Kinsey Moore

Change-Id: I5fa776e110262851173002a26ffe1172e4c35b2e

2 years agochan_pjsip: Fix ability to send UPDATE on COLP
George Joseph [Thu, 29 Jun 2017 19:50:14 +0000 (13:50 -0600)]
chan_pjsip:  Fix ability to send UPDATE on COLP

When connected_line_method is "invite", we're supposed to determine
if the client can support UPDATE and if it can, send UPDATE instead
of INVITE to avoid the SDP renegotiation.  Not only was pjproject
not setting the PJSIP_INV_SUPPORT_UPDATE flag, we were testing
that invite_tsx wasn't NULL which isn't always the case.

* Updated chan_pjsip/update_connected_line_information to drop the
  requirement that invite_tsx isn't NULL.
* Submitted patch to pjproject sip_inv.c that sets the
  PJSIP_INV_SUPPORT_UPDATE flag correctly.
* Updated pjsip.conf.sample to clarify what happens when "invite"
  is specified.

ASTERISK-27095

Change-Id: Ic2381b3567b8052c616d96fbe79564c530e81560

2 years agoMerge "app_voicemail: IMAP connection control"
Jenkins2 [Thu, 29 Jun 2017 14:51:54 +0000 (09:51 -0500)]
Merge "app_voicemail: IMAP connection control"

2 years agores_pjsip: Add DTMF INFO Failback mode
Torrey Searle [Thu, 15 Jun 2017 08:12:41 +0000 (10:12 +0200)]
res_pjsip:  Add DTMF INFO Failback mode

The existing auto dtmf mode reverts to inband if 4733 fails to be
negotiated.  This patch adds a new mode auto_info which will
switch to INFO instead of inband if 4733 is not available.

ASTERISK-27066 #close

Change-Id: Id185b11e84afd9191a2f269e8443019047765e91

2 years agoapp_queue: Add priority to AMI QueueStatus
Niklas Larsson [Thu, 29 Jun 2017 08:47:41 +0000 (10:47 +0200)]
app_queue: Add priority to AMI QueueStatus

Add priority to callers in AMI QueueStatus response

ASTERISK-27092 #close

Change-Id: I8d1f737a72c7c38f4cfe1a4ee3ecc0a4f85bd199

2 years agochan_pjsip: Add support for multiple streams of the same type.
Mark Michelson [Tue, 30 May 2017 14:12:47 +0000 (09:12 -0500)]
chan_pjsip: Add support for multiple streams of the same type.

The stream topology (list of streams and order) is now stored with the
configured PJSIP endpoints and used during the negotiation process.

Media negotiation state information has been changed to be stored
in a separate object. Two of these objects exist at any one time
on a session. The active media state information is what was previously
negotiated and the pending media state information is what the
media state will become if negotiation succeeds. Streams and other
state information is stored in this object using the index (or
position) of each individual stream for easy lookup.

The ability for a media type handler to specify a callback for
writing has been added as well as the ability to add file
descriptors with a callback which is invoked when data is available
to be read on them. This allows media logic to live outside of
the chan_pjsip module.

Direct media has been changed so that only the first audio and
video stream are directly connected. In the future once the RTP
engine glue API has been updated to know about streams each individual
stream can be directly connected as appropriate.

Media negotiation itself will currently answer all the provided streams
on an offer within configured limits and on an offer will use the
topology created as a result of the disallow/allow codec lines.

If a stream has been removed or declined we will now mark it as such
within the resulting SDP.

Applications can now also request that the stream topology change.
If we are told to do so we will limit any provided formats to the ones
configured on the endpoint and send a re-invite with the new topology.

Two new configuration options have also been added to PJSIP endpoints:

max_audio_streams: determines the maximum number of audio streams to
offer/accept from an endpoint. Defaults to 1.

max_video_streams: determines the maximum number of video streams to
offer/accept from an endpoint. Defaults to 1.

ASTERISK-27076

Change-Id: I8afd8dd2eb538806a39b887af0abd046266e14c7

2 years agores_rtp_asterisk: Fix issues with ICE renegotiation.
Joshua Colp [Wed, 28 Jun 2017 14:03:31 +0000 (14:03 +0000)]
res_rtp_asterisk: Fix issues with ICE renegotiation.

When re-inviting to add more streams it is possible for
the role of existing ICE sessions to be changed to the
incorrect value. This results in subsequent refreshes
within the sessions getting a role conflict and the ICE
session breaking down. This change only sets the role to
be the new value if an ICE renegotiation is actually
going to happen, otherwise the existing role is preserved.

As well if we encounter a situation where a unidirectional
ICE negotiation happens and the other side does not send us
candidates we will not store any information for sending
traffic, even though we know where they are reachable. This
change fixes this by using the source of the ICE traffic
itself as the target if no candidates are known and we
receive some ICE traffic.

ASTERISK-27088

Change-Id: I71228181e358917fcefc3100fad21b2fc02a59a9

2 years agores/res_pjsip_t38: fix incorrect increment of media_count
Torrey Searle [Tue, 27 Jun 2017 15:46:43 +0000 (17:46 +0200)]
res/res_pjsip_t38: fix incorrect increment of media_count

The T38 sdp callback incorrectly has a side effect of incrementing
the media_count.  This can lead to core dumps.

Change-Id: I7bb2f4987de4046ec52cfc34e5ea0662dae32af8

2 years agobridge_native_rtp: Keep rtp instance refs on bridge_channel
George Joseph [Fri, 9 Jun 2017 03:50:43 +0000 (21:50 -0600)]
bridge_native_rtp: Keep rtp instance refs on bridge_channel

There have been reports of deadlocks caused by an attempt to send a frame
to a channel's rtp instance after the channel has left the native bridge
and been destroyed.  This patch effectively causes the bridge channel to
keep a reference to the glue and both the audio and video rtp instances
so what gets started will get stopped.

ASTERISK-26978 #close
Reported-by: Ross Beer

Change-Id: I9e1ac49fa4af68d64826ccccd152593cf8cdb21a

2 years agoapp_queue: Fix returning to dialplan when a queue is empty
Ivan Poddubny [Tue, 27 Jun 2017 09:37:11 +0000 (11:37 +0200)]
app_queue: Fix returning to dialplan when a queue is empty

The fix for ASTERISK-25665 introduced a regression.
The return value of queue_exec used to be 0 in case of leavewhenempty
but it was changed to -1 (returned from wait_our_turn and passed
transparently by queue_exec), thus leading to hangup instead of returning
back to dialplan.

This commit resets the value back to 0 in this case, restoring
original behavior.

ASTERISK-27065 #close
Reported by: Marek Cervenka

Change-Id: Id9c83b75aeda463250155e88c5004be52bbca5ac

2 years agoMerge "res_pjsip_mwi: update unsolicited MWI subscriptions on updating contact"
Jenkins2 [Thu, 22 Jun 2017 21:01:52 +0000 (16:01 -0500)]
Merge "res_pjsip_mwi: update unsolicited MWI subscriptions on updating contact"

2 years agoapp_voicemail: IMAP connection control
Alexei Gradinari [Mon, 19 Jun 2017 22:21:29 +0000 (18:21 -0400)]
app_voicemail: IMAP connection control

A new global option "imap_poll_logout" was added to specify whether need to
disconnect from the IMAP server after polling of mailboxes.

ASTERISK-27068 #close

Closing IMAP connection after loading mailbox from voicemail.conf

ASTERISK-24052 #close

Change-Id: Ib7558ba04516240a32b65f42e9be64372a0ae12a

2 years agores_pjsip_mwi.c: Eliminate RAII_VAR in contact delete observer
Richard Mudgett [Wed, 21 Jun 2017 22:57:11 +0000 (17:57 -0500)]
res_pjsip_mwi.c: Eliminate RAII_VAR in contact delete observer

Change-Id: I0bc97c6608de1d1a4228826b3b3be43f162f05f3

2 years agores_pjsip_mwi: update unsolicited MWI subscriptions on updating contact
Alexei Gradinari [Fri, 16 Jun 2017 23:08:30 +0000 (19:08 -0400)]
res_pjsip_mwi: update unsolicited MWI subscriptions on updating contact

Do not need to unsubscribe/subscribe on creating the ednpoint's contact.
The modified function create_mwi_subscriptions_for_endpoint adds
the subscription only if it does not exist.

The subscriptions aren't added for active contacts
which are retrieved on startup from realtime
if mwi_disable_initial_unsolicited=yes.
Because the mwi_contact_added is not called.
So the subscriptions also should be created on updating contact.

ASTERISK-26230 #close

Change-Id: I47e265af9296ca09aa42a316fdacac104148cee4

2 years agoMerge "bridge: stuck channel(s) after failed attended transfer"
Jenkins2 [Wed, 21 Jun 2017 22:57:21 +0000 (17:57 -0500)]
Merge "bridge: stuck channel(s) after failed attended transfer"

2 years agoMerge "core_local: local channel data not being properly unref'ed and unlocked"
Jenkins2 [Wed, 21 Jun 2017 22:30:01 +0000 (17:30 -0500)]
Merge "core_local: local channel data not being properly unref'ed and unlocked"

2 years agocore_local: local channel data not being properly unref'ed and unlocked
Kevin Harwell [Tue, 20 Jun 2017 21:05:08 +0000 (16:05 -0500)]
core_local: local channel data not being properly unref'ed and unlocked

In an earlier version of Asterisk a local channel [un]lock all functions were
added in order to keep a crash from occurring when a channel hung up too early
during an attended transfer. Unfortunately, when a transfer failure occurs and
depending on the timing, the local channels sometime do not get properly
unlocked and deref'ed after being locked and ref'ed. This happens because the
underlying local channel structure gets NULLed out before unlocking.

This patch reworks those [un]lock functions and makes sure the values that get
locked and ref'ed later get unlocked and deref'ed.

ASTERISK-27074 #close

Change-Id: Ice96653e29bd9d6674ed5f95feb6b448ab148b09

2 years agobridge: stuck channel(s) after failed attended transfer
Kevin Harwell [Tue, 20 Jun 2017 21:01:48 +0000 (16:01 -0500)]
bridge: stuck channel(s) after failed attended transfer

If an attended transfer failed it was possible for some of the channels
involved to get "stuck" because Asterisk was not hanging up the transfer target.

This patch ensures Asterisk hangs up the transfer target when an attended
transfer failure occurs.

ASTERISK-27075 #close

Change-Id: I98a6ecd92d3461ab98c36f0d9451d23adaf3e5f9

2 years agoMerge "res_corosync: Change thread stack size"
Jenkins2 [Tue, 20 Jun 2017 23:18:19 +0000 (18:18 -0500)]
Merge "res_corosync: Change thread stack size"

2 years agoMerge "cdr: fix mistake spelling of a word for Unanswered."
Jenkins2 [Tue, 20 Jun 2017 14:25:17 +0000 (09:25 -0500)]
Merge "cdr: fix mistake spelling of a word for Unanswered."

2 years agoMerge "res_pjsip_mwi: unsubscribe unsolicited MWI on deleting endpoint last contact"
Joshua Colp [Tue, 20 Jun 2017 10:47:46 +0000 (05:47 -0500)]
Merge "res_pjsip_mwi: unsubscribe unsolicited MWI on deleting endpoint last contact"

2 years agoMerge "res_stasis: Plug reference leak on stolen channels"
Joshua Colp [Mon, 19 Jun 2017 21:49:39 +0000 (16:49 -0500)]
Merge "res_stasis:  Plug reference leak on stolen channels"

2 years agocdr: fix mistake spelling of a word for Unanswered.
Rodrigo Ramírez Norambuena [Mon, 19 Jun 2017 16:28:18 +0000 (12:28 -0400)]
cdr: fix mistake spelling of a word for Unanswered.

Change-Id: I7a610bef369924523a445c7e849ee88cc45dc5df

2 years agoMerge "SDP: Add get/set option calls for RTP sched context per type."
George Joseph [Mon, 19 Jun 2017 14:27:43 +0000 (09:27 -0500)]
Merge "SDP: Add get/set option calls for RTP sched context per type."

2 years agoMerge "res_pjsip: New endpoint option "notify_early_inuse_ringing""
Jenkins2 [Mon, 19 Jun 2017 14:09:58 +0000 (09:09 -0500)]
Merge "res_pjsip: New endpoint option "notify_early_inuse_ringing""

2 years agoMerge "app_voicemail: IMAP logout on reload/unload"
Jenkins2 [Mon, 19 Jun 2017 13:52:12 +0000 (08:52 -0500)]
Merge "app_voicemail: IMAP logout on reload/unload"

2 years agores_pjsip_mwi: unsubscribe unsolicited MWI on deleting endpoint last contact
Alexei Gradinari [Mon, 12 Jun 2017 21:17:38 +0000 (17:17 -0400)]
res_pjsip_mwi: unsubscribe unsolicited MWI on deleting endpoint last contact

If the endpoint's last contact is deleted unsolicited MWI has to be
unsubscribed.

ASTERISK-27051 #close

Change-Id: I33e174e0b9dba0998927d16d6d100fda5c7254e0

2 years agoMerge "formats/format_g729: Fix typo in comment"
Joshua Colp [Fri, 16 Jun 2017 21:37:18 +0000 (16:37 -0500)]
Merge "formats/format_g729: Fix typo in comment"

2 years agores_stasis: Plug reference leak on stolen channels
George Joseph [Fri, 16 Jun 2017 14:31:04 +0000 (08:31 -0600)]
res_stasis:  Plug reference leak on stolen channels

When a stasis channel is stolen by another app, the control
structure is unreffed but never unlinked from the app_controls
container.  This causes the channel reference to leak.

Added OBJ_UNLINK to the callback in channel_stolen_cb.

Also added some additional channel lifecycle debug messages to
channel.c.

ASTERISK-27059 #close
Repoorted-by: George Joseph

Change-Id: Ib820936cd49453f20156971785e7f4f182c56e14

2 years agoformats/format_g729: Fix typo in comment
Matthew Fredrickson [Fri, 16 Jun 2017 19:56:37 +0000 (14:56 -0500)]
formats/format_g729: Fix typo in comment

There was a typo in a comment.  This commit is to fix the typo.

ASTERISK-27060 #close

Change-Id: Ic2699f8dbeaacd58ccb6ec3203e853e1babe3235

2 years agoCore/PBX: Deadlock between dialplan execution and application unregistration.
Frederic LE FOLL [Thu, 8 Jun 2017 17:28:12 +0000 (19:28 +0200)]
Core/PBX: Deadlock between dialplan execution and application unregistration.

Not easy to reproduce, but we have noticed deadlocks when unloading a module
while dialplan is handling a request.

The deadlock is between :
1) Dialplan execution: pbx_extension_helper() first taking conlock,
then pbx_findapp() [when called] asking for lock on apps list.
2) Application unregistration: ast_unregister_application() first taking lock
on apps list, then unreference_cached_app() [when called] asking for conlock.

As a protection, I suggest to modify ast_unregister_application(), so that it
anticipates the need of conlock, before taking the lock on apps list.
The side effect is a longer unavailability of conlock when unregistering an
application.

ASTERISK-27041

Change-Id: I0db0f1eb320da6a5758cce3a47d765be1face8e2

2 years agoMerge "SDP: Search for the ice-lite attribute in the right place."
Joshua Colp [Fri, 16 Jun 2017 17:00:38 +0000 (12:00 -0500)]
Merge "SDP: Search for the ice-lite attribute in the right place."

2 years agoMerge changes from topic 'sdp_api_adjustments'
Jenkins2 [Fri, 16 Jun 2017 16:51:41 +0000 (11:51 -0500)]
Merge changes from topic 'sdp_api_adjustments'

* changes:
  SDP: Set the remote c= line in RTP instance.
  SDP: Add t= line in sdp_create_from_state()
  stream: Ignore declined streams for some topology calls.

2 years agoMerge "stream: Add ast_stream_topology_del_stream() and unit test."
Jenkins2 [Fri, 16 Jun 2017 16:50:32 +0000 (11:50 -0500)]
Merge "stream: Add ast_stream_topology_del_stream() and unit test."

2 years agores_pjsip: New endpoint option "notify_early_inuse_ringing"
Alexei Gradinari [Mon, 12 Jun 2017 14:23:56 +0000 (10:23 -0400)]
res_pjsip: New endpoint option "notify_early_inuse_ringing"

This option was added to control whether to notify dialog-info state
'early' or 'confirmed' on Ringing when already INUSE.
The value "yes" is useful for some SIP phones (Cisco SPA)
to be able to indicate and pick up ringing devices.

ASTERISK-26919 #close

Change-Id: Ie050bc30023543c7dfb4365c5be3ce58c738c711

2 years agoMerge "res_ari: Add "module loaded" check to ari stubs"
Jenkins2 [Fri, 16 Jun 2017 16:12:48 +0000 (11:12 -0500)]
Merge "res_ari:  Add "module loaded" check to ari stubs"

2 years agoapp_voicemail: IMAP logout on reload/unload
Alexei Gradinari [Thu, 15 Jun 2017 18:48:13 +0000 (14:48 -0400)]
app_voicemail: IMAP logout on reload/unload

Closing IMAP connection on module reload or unload.

ASTERISK-24052 #close

Change-Id: I2a40182aa9ef249fa6865d33570430e9ada68525

2 years agores_corosync: Change thread stack size
Jan Friesse [Thu, 30 Mar 2017 14:33:51 +0000 (16:33 +0200)]
res_corosync: Change thread stack size

In Corosync 2.x libraries were changed to use LibQB IPC.
Sadly LibQB IPC doesn't support copy-free access to received buffer, so
Corosync libraries were rewritten to use stack as buffer. Mostly the
needed stack size is quite small, but for all *_dispatch functions, 1MiB
is needed.

Asterisk function ast_pthread_create_background set stack size for new
thread to much smaller AST_BACKGROUND_STACKSIZE (~500KiB).

This results in Asterisk crash when running with Corosync 2.x.

Patch solves this issue by creating it's own version of
ast_pthread_create_background which sets stack size to much higher value
(actually it's AST_BACKGROUND_STACKSIZE + 3MiB).

Another problem may appear when "corosync show members" netconsole
command is executed. It is also executed in thread and also has only
500KiB stack size. Sadly it calls corosync_cfg_get_node_addrs which
again needs at least 1MiB stack.

Solution is to use HAVE_COROSYNC_CFG_STATE_TRACK as a discriminator
between Corosync 1.x and 2.x. If 1.x is found, nothing changes. If 2.x
is found, NodeID is displayed instead of IP address.

ASTERISK-25370 #close
Reported by: mdu113

Change-Id: Id95b0d21ab6e708e7d74ad8786c587211676fa08

2 years agoMerge "chan_pjsip: Fix PJSIP_MEDIA_OFFER dialplan function read."
Jenkins2 [Fri, 16 Jun 2017 12:51:17 +0000 (07:51 -0500)]
Merge "chan_pjsip: Fix PJSIP_MEDIA_OFFER dialplan function read."

2 years agores_ari: Add "module loaded" check to ari stubs
George Joseph [Tue, 13 Jun 2017 16:33:34 +0000 (10:33 -0600)]
res_ari:  Add "module loaded" check to ari stubs

The recent change to make the use of LOAD_DECLINE more consistent
caused res_ari to unload itself before declining if the ari.conf
file wasn't found.  The ari stubs though still tried to use the
configuration resulting in segfaults.

This patch creates a new CHECK_ARI_MODULE_LOADED macro which tests
to see if res_ari is actually loaded and causes the stubs to also
decline if it isn't.  The macro was then added to the mustache
template's "load_module" function.

ASTERISK-27026 #close
Reported-by: Ronald Raikes

Change-Id: I263d56efa628ee3c411bdcd16d49af6260c6c91d

2 years agoMerge "channel: Fix reference counting in ast_channel_suppress."
Joshua Colp [Thu, 15 Jun 2017 21:24:55 +0000 (16:24 -0500)]
Merge "channel: Fix reference counting in ast_channel_suppress."

2 years agoMerge "res_pjsip_pubsub: Fix reference to released endpoint"
Jenkins2 [Thu, 15 Jun 2017 20:24:25 +0000 (15:24 -0500)]
Merge "res_pjsip_pubsub:  Fix reference to released endpoint"

2 years agoMerge "bridge: Add a deferred queue."
Joshua Colp [Thu, 15 Jun 2017 20:02:26 +0000 (15:02 -0500)]
Merge "bridge: Add a deferred queue."

2 years agochan_pjsip: Fix PJSIP_MEDIA_OFFER dialplan function read.
Richard Mudgett [Thu, 15 Jun 2017 17:33:22 +0000 (12:33 -0500)]
chan_pjsip: Fix PJSIP_MEDIA_OFFER dialplan function read.

The construction of the returned string assumed incorrectly that the
supplied buffer would always be initialized as an empty string.  If it is
not an empty string we could overrun the supplied buffer by the length of
the non-empty buffer string plus one.  It is also theoreticaly possible
for the supplied buffer to be overrun by a string terminator during a read
operation even if the supplied buffer is an empty string.

* Fix the assumption that the supplied buffer would already be an empty
string.  The buffer is not guaranteed to contain an empty string by all
possible callers.

* Fix string terminator buffer overrun potential.

Change-Id: If6a0806806527678c8554b1dcb34fd7808aa95c9

2 years agoSDP: Add get/set option calls for RTP sched context per type.
Richard Mudgett [Thu, 8 Jun 2017 16:38:33 +0000 (11:38 -0500)]
SDP: Add get/set option calls for RTP sched context per type.

Change-Id: I82dc75c63c48904e9e5a49e2205dcc06e88487e4

2 years agoSDP: Search for the ice-lite attribute in the right place.
Richard Mudgett [Thu, 11 May 2017 23:49:09 +0000 (18:49 -0500)]
SDP: Search for the ice-lite attribute in the right place.

* Pulled finding the rtcp-mux attribute flag out of the ICE candidate for
loop.  Also ordered the RTCP ICE candidate skip test to fail earlier.

Change-Id: I8905d9c68563027a46cd3ae14dbcc27e9c814809

2 years agoSDP: Set the remote c= line in RTP instance.
Richard Mudgett [Thu, 11 May 2017 23:46:52 +0000 (18:46 -0500)]
SDP: Set the remote c= line in RTP instance.

Change-Id: I23b646392082deab65bedeb19b12dcbcb9216d0c

2 years agostream: Add ast_stream_topology_del_stream() and unit test.
Richard Mudgett [Sat, 10 Jun 2017 00:03:05 +0000 (19:03 -0500)]
stream: Add ast_stream_topology_del_stream() and unit test.

Change-Id: If07e3c716a2e3ff85ae905c17572ea6ec3cdc1f9

2 years agoSDP: Add t= line in sdp_create_from_state()
Richard Mudgett [Thu, 11 May 2017 19:09:06 +0000 (14:09 -0500)]
SDP: Add t= line in sdp_create_from_state()

Change-Id: I4060391328a893101ed87d0d9bacbbab4fd8b141

2 years agostream: Ignore declined streams for some topology calls.
Richard Mudgett [Wed, 14 Jun 2017 18:07:17 +0000 (13:07 -0500)]
stream: Ignore declined streams for some topology calls.

* Made ast_format_cap_from_stream_topology() not include any formats from
declined streams.

* Made ast_stream_topology_get_first_stream_by_type() ignore declined
streams to return the first active stream of the type.

* Updated unit tests to check these changes have the expected effect.

Change-Id: Iabbc6a3e8edf263a25fd3056c3c614407c7897df

2 years agoMerge "app_voicemail.c: Fix compile error when IMAP enabled."
George Joseph [Thu, 15 Jun 2017 14:06:23 +0000 (09:06 -0500)]
Merge "app_voicemail.c: Fix compile error when IMAP enabled."

2 years agoMerge "app_voicemail: IMAP logout on MWI unsubscribe"
George Joseph [Thu, 15 Jun 2017 14:05:57 +0000 (09:05 -0500)]
Merge "app_voicemail: IMAP logout on MWI unsubscribe"

2 years agoMerge "res_pjsip_refer/session: Calls dropped during transfer"
Jenkins2 [Thu, 15 Jun 2017 13:12:43 +0000 (08:12 -0500)]
Merge "res_pjsip_refer/session: Calls dropped during transfer"

2 years agochannel: Fix reference counting in ast_channel_suppress.
Joshua Colp [Thu, 15 Jun 2017 12:32:32 +0000 (12:32 +0000)]
channel: Fix reference counting in ast_channel_suppress.

The ast_channel_suppress function wrongly decremented the
reference count of the underlying structure used to keep
track of what should be suppressed on a channel if the
function was called multiple times on the same channel.

This change cleans up the reference counting a bit so
this no longer occurs.

ASTERISK-27016

Change-Id: I2eed4077cb4916e6626f9f120b63b963acc5c136

2 years agoMerge "res_rtp_asterisk: Fix ssrc change for rtcp srtp"
George Joseph [Wed, 14 Jun 2017 21:05:37 +0000 (16:05 -0500)]
Merge "res_rtp_asterisk:  Fix ssrc change for rtcp srtp"

2 years agoMerge "res_pjsip_session: Correct inverted test in session_outgoing_nat_hook"
Jenkins2 [Wed, 14 Jun 2017 20:54:22 +0000 (15:54 -0500)]
Merge "res_pjsip_session:  Correct inverted test in session_outgoing_nat_hook"

2 years agoMerge "res_pjsip_transport_websocket: Add NULL check in get_write_timeout"
Jenkins2 [Wed, 14 Jun 2017 20:24:32 +0000 (15:24 -0500)]
Merge "res_pjsip_transport_websocket: Add NULL check in get_write_timeout"