19 months agocore: Fix ABI mismatch of ao2_global_obj.
Corey Farrell [Mon, 23 Sep 2019 02:04:44 +0000 (22:04 -0400)]
core: Fix ABI mismatch of ao2_global_obj.

astobj2.c declares DEBUG_THREADS_LOOSE_ABI to avoid overhead of debug
threads tracking information in the internal structures of astobj2.
Unfortunately this means that ao2_global_obj contains the statically
allocated debug threads tracking fields which are used by initialization
and cleanup but main/astobj2.c believed those fields and associated
space did not exist.

Change-Id: Icef41ad97d88a8c1d1515e034ec8133cab3b1527

19 months agoMerge "func_jitterbuffer: Add audio/video sync support."
Joshua Colp [Thu, 19 Sep 2019 13:23:15 +0000 (08:23 -0500)]
Merge "func_jitterbuffer: Add audio/video sync support."

19 months agoMerge "core: Add H.265/HEVC passthrough support"
Friendly Automation [Wed, 18 Sep 2019 21:50:23 +0000 (16:50 -0500)]
Merge "core: Add H.265/HEVC passthrough support"

19 months agofunc_jitterbuffer: Add audio/video sync support.
Joshua Colp [Fri, 6 Sep 2019 13:18:55 +0000 (13:18 +0000)]
func_jitterbuffer: Add audio/video sync support.

This change adds support to the JITTERBUFFER dialplan function
for audio and video synchronization. When enabled the RTCP SR
report is used to produce an NTP timestamp for both the audio and
video streams. Using this information the video frames are queued
until their NTP timestamp is equal to or behind the NTP timestamp
of the audio. The audio jitterbuffer acts as the leader deciding
when to shrink/grow the jitterbuffer when adaptive is in use. For
both adaptive and fixed the video buffer follows the size of the
audio jitterbuffer.


Change-Id: I3fd75160426465e6d46bb2e198c07b9d314a4492

19 months agoMerge "chan_pjsip: Relock correct channel during "fax" redirect."
Friendly Automation [Wed, 18 Sep 2019 12:44:27 +0000 (07:44 -0500)]
Merge "chan_pjsip: Relock correct channel during "fax" redirect."

19 months agoMerge "chan_dahdi: Fix build with clang/llvm"
George Joseph [Tue, 17 Sep 2019 14:30:36 +0000 (09:30 -0500)]
Merge "chan_dahdi: Fix build with clang/llvm"

19 months agocore: Add H.265/HEVC passthrough support
Florian Floimair [Thu, 22 Aug 2019 12:44:07 +0000 (14:44 +0200)]
core: Add H.265/HEVC passthrough support

This change adds H.265/HEVC as a known codec and creates a cached
"h265" media format for use.

Note that RFC 7798 section 7.2 also describes additional SDP
parameters. Handling of these is not yet supported.


Change-Id: I26d262cc4110b4f7e99348a3ddc53bad0d2cd1f2

19 months agochan_dahdi: Fix build with clang/llvm
Guido Falsi [Sat, 14 Sep 2019 15:05:23 +0000 (17:05 +0200)]
chan_dahdi: Fix build with clang/llvm

On FreeBSD using the clang/llvm compiler build fails to build due
to the switch statement argument being a non integer type expression.
Switch to an if/else if/else construct to sidestep the issue.

ASTERISK-28536 #close

Change-Id: Idf4a82cc1e94580a2d017fe9e351c226f23e20c8

19 months agochan_pjsip: Relock correct channel during "fax" redirect.
Joshua Colp [Sun, 15 Sep 2019 19:35:45 +0000 (19:35 +0000)]
chan_pjsip: Relock correct channel during "fax" redirect.

When fax detection occurs on an outbound PJSIP channel the
redirect operation will result in a masquerade occurring and
the underlying channel on the session changing. The code
incorrectly relocked the new channel instead of the old
channel when returning. This resulted in the new channel
being locked indefinitely. The code now always acts on the
expected channel.


Change-Id: I2b2e60d07e74383ae7e90d752c036c4b02d6b3a3

19 months agores_rtp_asterisk.c: Send RTCP as compound packets.
Ben Ford [Tue, 3 Sep 2019 17:20:20 +0000 (12:20 -0500)]
res_rtp_asterisk.c: Send RTCP as compound packets.

According to RFC3550, ALL RTCP packets must be sent in a compond packet
of at least two individual packets, including SR/RR and SDES. REMB,
FIR, and NACK were not following this format, and as a result, would
fail the packet check in ast_rtcp_interpret. This was found from writing
unit tests for RTCP. The browser would accept the way we were
constructing these RTCP packets, but when sending directly from one
Asterisk instance to another, the above mentioned problem would occur.

Change-Id: Ieb140e9c22568a251a564cd953dd22cd33244605

19 months agochannels: Allow updating variable value
Sean Bright [Wed, 11 Sep 2019 20:58:29 +0000 (16:58 -0400)]
channels: Allow updating variable value

When modifying an already defined variable in some channel drivers they
add a new variable with the same name to the list, but that value is
never used, only the first one found.

Introduce ast_variable_list_replace() and use it where appropriate.

ASTERISK-23756 #close
  setvar-multiplie.patch submitted by Michael Goryainov

Change-Id: Ie1897a96c82b8945e752733612ee963686f32839

19 months agoMerge "res_rtp: Add unit tests for RTCP stats."
Friendly Automation [Thu, 12 Sep 2019 20:22:38 +0000 (15:22 -0500)]
Merge "res_rtp: Add unit tests for RTCP stats."

19 months agoMerge "ChanIsAvail() generates a CDR when unanswered=yes in cdr.conf."
Joshua Colp [Wed, 11 Sep 2019 14:27:09 +0000 (09:27 -0500)]
Merge "ChanIsAvail() generates a CDR when unanswered=yes in cdr.conf."

19 months agoMerge "res_musiconhold: Added unregister realtime moh class"
Friendly Automation [Wed, 11 Sep 2019 14:00:47 +0000 (09:00 -0500)]
Merge "res_musiconhold: Added unregister realtime moh class"

19 months agoMerge "chan_dahdi: set CHANNEL(hangupsource) when a PRI channel hangs up"
Friendly Automation [Wed, 11 Sep 2019 12:13:30 +0000 (07:13 -0500)]
Merge "chan_dahdi: set CHANNEL(hangupsource) when a PRI channel hangs up"

19 months agoMerge "chan_sip: Update links referenced in deprecation notice"
Joshua Colp [Wed, 11 Sep 2019 12:12:48 +0000 (07:12 -0500)]
Merge "chan_sip:  Update links referenced in deprecation notice"

19 months agoMerge "codec_resample: Ensure OUTSIDE_SPEEX is defined when necessary"
Joshua Colp [Wed, 11 Sep 2019 11:19:26 +0000 (06:19 -0500)]
Merge "codec_resample: Ensure OUTSIDE_SPEEX is defined when necessary"

19 months agores_musiconhold: Added unregister realtime moh class
sungtae kim [Tue, 27 Aug 2019 22:44:33 +0000 (00:44 +0200)]
res_musiconhold: Added unregister realtime moh class

This fix allows a realtime moh class to be unregistered from the command
line. This is useful when the contents of a directory referenced by a
realtime moh class have changed.
The realtime moh class is then reloaded on the next request and uses the
new directory contents.


Change-Id: Ibc4c6834592257c4bb90601ee299682d15befbce

20 months agores_rtp: Add unit tests for RTCP stats.
Ben Ford [Wed, 28 Aug 2019 19:25:57 +0000 (14:25 -0500)]
res_rtp: Add unit tests for RTCP stats.

Added unit tests for RTCP video stats. These tests include NACK, REMB,
FIR/FUR/PLI, SR/RR/SDES, and packet loss statistics. The REMB and FIR
tests are currently disabled due to a bug. We expect to receive a
compound packet, but the code sends this out as a single packet, which
the browser accepts, but makes Asterisk upset.

While writing these tests, I noticed an issue with NACK as well. Where
it is handling a received NACK request, it was reading in only the first
8 bits of following packets that were also lost. This has been changed
to the correct value of 16 bits.

Also made a minor fix to the data buffer unit test.

Change-Id: I56107c7411003a247589bbb6086d25c54719901b

20 months agoChanIsAvail() generates a CDR when unanswered=yes in cdr.conf.
Frederic LE FOLL [Thu, 5 Sep 2019 16:09:28 +0000 (18:09 +0200)]
ChanIsAvail() generates a CDR when unanswered=yes in cdr.conf.

ChanIsAvail() creates a temporary channel with ast_request() to test
resource availability. It should not generate a CDR when it hangs up
this temporary channel.

This patch disables CDR generation for the temporary channel with


Change-Id: I7b0555c6909c7d322e452dde97c9ea5b111552d1

20 months agochan_dahdi: set CHANNEL(hangupsource) when a PRI channel hangs up
Frederic LE FOLL [Thu, 5 Sep 2019 15:52:13 +0000 (17:52 +0200)]
chan_dahdi: set CHANNEL(hangupsource) when a PRI channel hangs up

When the remote ISDN party ends an ISDN call on a PRI link
(DISCONNECT), CHANNEL(hangupsource) information is not available.

chan_dahdi already contains an ast_set_hangupsource() in
__dahdi_exception() function but it seems that ISDN message processing
does not use this part of code.

Two other channel modules associate ast_queue_hangup() and
ast_set_hangupsource() functions calls:
- chan_pjsip in chan_pjsip_session_end() function,
- chan_sip in sip_queue_hangup_cause() function.
chan_iax2 separates them, in iax2_queue_hangup()/iax2_destroy() and

Thus, I propose to add ast_set_hangupsource() beside
ast_queue_hangup() in sig_pri_queue_hangup(), like chan_pjsip and
chan_sip already do.


Change-Id: I0f588a4bcf15ccd0648fd69830d1b801c3f21b7c

20 months agoARI: External Media
George Joseph [Mon, 5 Aug 2019 11:59:59 +0000 (05:59 -0600)]
ARI: External Media

The Channel resource has a new sub-resource "externalMedia".
This allows an application to create a channel for the sole purpose
of exchanging media with an external server.  Once created, this
channel could be placed into a bridge with existing channels to
allow the external server to inject audio into the bridge or
receive audio from the bridge.
for more information.

Change-Id: I9618899198880b4c650354581b50c0401b58bc46

20 months agoMerge "chan_unistim: Fix clang warning: variable sized type not at end of a struct"
George Joseph [Tue, 10 Sep 2019 13:41:57 +0000 (08:41 -0500)]
Merge "chan_unistim: Fix clang warning: variable sized type not at end of a struct"

20 months agoMerge "test_utils.c: Skip test adsi_loaded_test if module not loaded."
Friendly Automation [Tue, 10 Sep 2019 13:28:21 +0000 (08:28 -0500)]
Merge "test_utils.c: Skip test adsi_loaded_test if module not loaded."

20 months agochan_sip: Update links referenced in deprecation notice
George Joseph [Tue, 10 Sep 2019 12:32:49 +0000 (06:32 -0600)]
chan_sip:  Update links referenced in deprecation notice

The links in the deprecation notice were the shortened
variety but it makes better sense to show the unshortened
links as they're more descriptive.

rather than

Change-Id: If2da5d5243e2d4a6f193b15691d23e7e5a7c57a9

20 months agocodec_resample: Ensure OUTSIDE_SPEEX is defined when necessary
Sean Bright [Sun, 8 Sep 2019 15:38:57 +0000 (11:38 -0400)]
codec_resample: Ensure OUTSIDE_SPEEX is defined when necessary


Change-Id: If0d58598ce14aad3c786a1c0127b5f7b200b737d

20 months agoMerge "AST-2019-005 - translate: Don't assume all frames will have a src."
George Joseph [Thu, 5 Sep 2019 12:52:33 +0000 (07:52 -0500)]
Merge "AST-2019-005 - translate: Don't assume all frames will have a src."

20 months agoAST-2019-005 - translate: Don't assume all frames will have a src.
Joshua Colp [Mon, 26 Aug 2019 12:53:27 +0000 (09:53 -0300)]
AST-2019-005 - translate: Don't assume all frames will have a src.

This change removes the assumption that a frame will always have
a src set on it. This assumption is incorrect.

Given a scenario where an RTP packet is received with no payload
the resulting audio frame will have no samples. If this frame goes
through a signed linear translation path an interpolated frame can
be created (if generic packet loss concealment is enabled) that has
minimal data on it, including no src. If this frame is given to a
translation path a crash will occur due to the lack of src.


Change-Id: I024d10dd98207eb8a6b35b59880bcdf1090538f8

20 months agoAST-2019-004 - res_pjsip_t38.c: Add NULL checks before using session media
Kevin Harwell [Tue, 20 Aug 2019 20:05:45 +0000 (15:05 -0500)]
AST-2019-004 - res_pjsip_t38.c: Add NULL checks before using session media

After receiving a 200 OK with a declined stream in response to a T.38
initiated re-invite Asterisk would crash when attempting to dereference
a NULL session media object.

This patch checks to make sure the session media object is not NULL before
attempting to use it.

  ast-2019-004.patch submitted by Alexei Gradinari (license 5691)

Change-Id: I168f45f4da29cfe739acf87e597baa2aae7aa572

20 months agotest_utils.c: Skip test adsi_loaded_test if module not loaded.
Chris-Savinovich [Wed, 4 Sep 2019 21:19:55 +0000 (16:19 -0500)]
test_utils.c: Skip test adsi_loaded_test if module not loaded.

Module is deprecated, therefore it does not load by default.
Module not loaded causes it to yield a FAIL when tested by tests/test_utils.c.
This fix checks if the corresponding module is loaded at the start of the test,
and if not, it passes the test and exits with a message.

This fix is applied to all versions where the module is marked deprecated.

Change-Id: I52be64c8f6af222e15148a856d1f10cb113e1e94

20 months agochan_unistim: Fix clang warning: variable sized type not at end of a struct
Igor Goncharovsky [Tue, 27 Aug 2019 11:10:56 +0000 (17:10 +0600)]
chan_unistim: Fix clang warning: variable sized type not at end of a struct

On reading information about initial client packet unistim use dirty
implementation of destination ip address retrieval. This fix uses
CMSG_*(..) to get ip address and make clang compile without warning.

ASTERISK-25592 #close
Reported-by: Alexander Traud

Change-Id: Ic1fd34c2c2bcc951da65bf62e3f7a8adff8351b1

20 months agoMerge "chan_unistim: Fix code, causing all incoming DTMF sent back to asterisk"
George Joseph [Tue, 3 Sep 2019 10:32:21 +0000 (05:32 -0500)]
Merge "chan_unistim: Fix code, causing all incoming DTMF sent back to asterisk"

20 months agoMerge "res_pjsip_mwi: add better handling of solicited vs unsolicited subscriptions"
Friendly Automation [Fri, 30 Aug 2019 14:56:36 +0000 (09:56 -0500)]
Merge "res_pjsip_mwi: add better handling of solicited vs unsolicited subscriptions"

20 months agoMerge "codec_resample: Upgrade speex_resample to fix up-sampling bug"
George Joseph [Fri, 30 Aug 2019 12:47:32 +0000 (07:47 -0500)]
Merge "codec_resample: Upgrade speex_resample to fix up-sampling bug"

20 months agores_pjsip_mwi: add better handling of solicited vs unsolicited subscriptions
Kevin Harwell [Fri, 23 Aug 2019 22:03:07 +0000 (17:03 -0500)]
res_pjsip_mwi: add better handling of solicited vs unsolicited subscriptions

res_pjsip_mwi allows both solicited and unsolicited MWI subscription types.
While both can be set in the configuration for a given endpoint/aor, only
one is allowed. Precedence is given to unsolicited. Meaning if an endpoint/aor
is configured to allow both types then the solicited subscription is rejected
when it comes in. However, there is a configuration option to override that


When set to "yes" then when a solicited subscription comes in instead of
rejecting it Asterisk is suppose to replace the unsolicited one if it exists.
Prior to this patch there was a bug in Asterisk that allowed the solicted one
to be added, but did not remove the unsolicited. As a matter of fact a new
unsolicited subscription got added everytime a SIP register was received.
Over time this eventually could "flood" a phone with SIP notifies.

This patch fixes that behavior to now make it work as expected. If configured
to do so a solicited subscription now properly replaces the unsolicited one.
As well when an unsubscribe is received the unsolicited subscription is
restored. Logic was also put in to handle reloads, and any configuration changes
that might result from that. For instance, if a solicited subscription had
previously replaced an unsolicited one, but after reload it was configured to
not allow that then the solicited one needs to be shutdown, and the unsolicited
one added.


Change-Id: Iec2ec12d9431097e97ed5f37119963aee41af7b1

20 months agochan_unistim: Fix code, causing all incoming DTMF sent back to asterisk
Igor Goncharovsky [Tue, 27 Aug 2019 05:49:46 +0000 (11:49 +0600)]
chan_unistim: Fix code, causing all incoming DTMF sent back to asterisk

Current implementation of ast_channel_tech send_digit_begin hook uses
same function for tone playback as key press handler. This cause every
incoming dtmf send back to asterisk. In case of two unistim phones
connected to each other, it'll cause indefinite DTMF loop. Fix add
separate function for dtmf tone phone play.

Change-Id: I5795db468df552f0c89c7576b6b3858b26c4eab4

20 months agochan_unistim: Fix RTP port byte order for big-endian arch
Igor Goncharovsky [Fri, 16 Aug 2019 11:01:21 +0000 (15:01 +0400)]
chan_unistim: Fix RTP port byte order for big-endian arch

This patch fixes one-way oudio that users expirienced on
big-endian architechtires. RTP port number bytes was stored
in improper order and phone sent RTP to wrong RTP port.

Reported-by: Andrey Ionov
Change-Id: I9a9ca7f26e31a67bbbceff12923baa10dfb8a3be

20 months agocodec_resample: Upgrade speex_resample to fix up-sampling bug
Sean Bright [Fri, 23 Aug 2019 20:14:36 +0000 (16:14 -0400)]
codec_resample: Upgrade speex_resample to fix up-sampling bug

ASTERISK-28511 #close

Change-Id: Idd07bf341e89ac999c7f5701d9b72b8a9cb11e82

20 months agoMerge "Fix misname 'res_external_mwi' to 'res_mwi_external' in comments."
Joshua Colp [Fri, 23 Aug 2019 12:57:58 +0000 (07:57 -0500)]
Merge "Fix misname 'res_external_mwi' to 'res_mwi_external' in comments."

20 months agoMerge "pjproject: Configurable setting for cnonce to include hyphens or not"
Friendly Automation [Fri, 23 Aug 2019 00:57:08 +0000 (19:57 -0500)]
Merge "pjproject: Configurable setting for cnonce to include hyphens or not"

20 months agoFix misname 'res_external_mwi' to 'res_mwi_external' in comments.
Alexei Gradinari [Thu, 22 Aug 2019 18:19:51 +0000 (14:19 -0400)]
Fix misname 'res_external_mwi' to 'res_mwi_external' in comments.

Change-Id: Ic784be8500e5cb75dcb34bae9f03cfd93b6b34fb

20 months agochan_rtp: Accept hostname as well as ip address as destination
George Joseph [Wed, 21 Aug 2019 18:29:57 +0000 (12:29 -0600)]
chan_rtp:  Accept hostname as well as ip address as destination

The UnicastRTP channel driver provided by chan_rtp now accepts
"<hostname>:<port>" as an alternative to "<ip_address>:<port>"
in the destination. The first AAAA (preferred) or A record resolved
will be used as the destination. The lookup is synchronous so beware
of possible dialplan delays if you specify a hostname.

Change-Id: Ie6f95b983a8792bf0dacc64c7953a41032dba677

20 months agodns_core: Create new API ast_dns_resolve_ipv6_and_ipv4
George Joseph [Wed, 21 Aug 2019 17:03:26 +0000 (11:03 -0600)]
dns_core:  Create new API ast_dns_resolve_ipv6_and_ipv4

The new function takes in a pointer to an ast_sockaddr structure,
a hostname and an optional port and then dispatches parallel
"AAAA" and "A" record queries.  If an "AAAA" record is returned,
it's parsed into the ast_sockaddr structure along with the port
if it was supplied.  If no "AAAA" record was returned, the
first "A" record returned (if any) is parsed instead.

This is a synchronous call.  If you need asynchronous lookups,
use ast_dns_query_set_resolve_async and roll your own.

Change-Id: I194b0b0e73da94b35cc35263a868ffac3a8d0a95

20 months agoMerge "res_pjsip: Channel variable SIPFROMDOMAIN"
George Joseph [Wed, 21 Aug 2019 23:41:20 +0000 (18:41 -0500)]
Merge "res_pjsip: Channel variable SIPFROMDOMAIN"

20 months agopjproject: Configurable setting for cnonce to include hyphens or not
Dan Cropp [Wed, 21 Aug 2019 15:58:00 +0000 (10:58 -0500)]
pjproject: Configurable setting for cnonce to include hyphens or not

NEC SIP Station interface with authenticated registration only supports cnonce
up to 32 characters.  In Linux, PJSIP would generate 36 character cnonce
which included hyphens.  Teluu developed this patch adding a compile time
setting to default to not include the hyphens.  They felt it best to still
generate the UUID and strip the hyphens.
They have indicated it will be part of PJSIP 2.10.

Reported-by: Dan Cropp

Change-Id: Ibdfcf845d4f8c0a14df09fd983b11f2d72c5f470

20 months agoMerge "res_ari.c: Prefer exact handler match over wildcard"
Friendly Automation [Wed, 21 Aug 2019 12:52:19 +0000 (07:52 -0500)]
Merge "res_ari.c:  Prefer exact handler match over wildcard"

20 months agores_ari.c: Prefer exact handler match over wildcard
George Joseph [Tue, 20 Aug 2019 18:04:56 +0000 (12:04 -0600)]
res_ari.c:  Prefer exact handler match over wildcard

Given the following request path and 2 handler paths...
Request: /channels/externalMedia
Handler: /channels/{channelId}      "wildcard"
Handler: /channels/externalmedia    "non-wildcard"

...if /channels/externalMedia was registered as a handler after
/channels/{channelId} as shown above, the request would automatically
match the wildcard handler and attempt to parse "externalMedia" into
the channelId variable which isn't what was intended.  It'd work
if the non-wildard entry was defined in rest-api/api-docs/channels.json
before the wildcard entry but that makes the json files
order-dependent which isn't a good thing.

To combat this issue, the search loop saves any wildcard match but
continues looking for exact matches at the same level.  If it finds
one, it's used.  If it hasn't found an exact match at the end of
the current level, the wildcard is used.  Regardless, after
searching the current level, the wildcard is cleared so it won't
accidentally match for a different object or a higher level.

BTW, it's currently not possible for more than 1 wildcard entry
to be defined for a level.  For instance, there couldn't be:
Handler: /channels/{channelId}
Handler: /channels/{channelName}
We wouldn't know which one to match.

Change-Id: I574aa3cbe4249c92c30f74b9b40e750e9002f925

20 months agoaudiohook.c: Substitute silence for unavailable audio frames
Sean Bright [Fri, 9 Aug 2019 20:53:03 +0000 (16:53 -0400)]
audiohook.c: Substitute silence for unavailable audio frames

There are 4 scenarios to consider when capturing audio from a channel
with an audiohook:

 1. There is no rx and no tx audio, so return nothing.
 2. There is rx but no tx audio, so return rx.
 3. There is tx but no rx audio, so return tx.
 4. There is rx and tx audio, so mix them and return.

The file passed as the primary argument to MixMonitor will be written to
in scenarios 2, 3, and 4. However, if you pass the r() and t() options
to MixMonitor, a frame will only be written to the r() file if there was
rx audio and a frame will only be written to the t() file if there was
tx audio.

If you subsequently take the r() and t() files and try to mix them, the
sides of the conversation will 'drift' and be non-representative of the
user experience.

This patch adds a new 'S' option to MixMonitor that injects a frame of
silence on either the r() side or the t() side of the channel so that
when later mixed, there is no such drift.

Change-Id: Ibf5ed73a811087727bd561a89a59f4447b4ee20e

20 months agores_pjsip: Channel variable SIPFROMDOMAIN
Stas Kobzar [Tue, 30 Jul 2019 17:08:27 +0000 (13:08 -0400)]
res_pjsip: Channel variable SIPFROMDOMAIN

In chan_sip, there was variable SIPFROMDOMAIN that allows to set
From header URI domain per channel. This patch introduces res_pjsip
variable SIPFROMDOMAIN for backward compatibility with chan_sip.


Change-Id: I715133e43172ce2a1e82093538dc39f9e99e5f2e

20 months agoapp_voicemail/IMAP: check mailstream not NULL in leave_voicemail
Alexei Gradinari [Wed, 14 Aug 2019 19:52:01 +0000 (15:52 -0400)]
app_voicemail/IMAP: check mailstream not NULL in leave_voicemail

The function leave_voicemail checks if expungeonhangup is set,
but does not check if IMAP stream is closed,
so it could call imap function with NULL stream.
This leads to segfault.

ASTERISK-28505 #close

Change-Id: Ib66c57c1f1ba97774e447b36349198e2626a8d7c

21 months agomenuselect: Fix curses build on Gentoo Linux
Sean Bright [Fri, 9 Aug 2019 10:51:28 +0000 (06:51 -0400)]
menuselect: Fix curses build on Gentoo Linux

Because keypad() is exported by libtinfo, it needs to be explicitly
added to the linker options.

ASTERISK-28487 #close

Change-Id: I6c2ad5b95f422c263d078b5c0e84c111807dffc6

21 months agoMerge "srtp: Fix possible race condition, and add NULL checks"
Friendly Automation [Fri, 9 Aug 2019 12:46:42 +0000 (07:46 -0500)]
Merge "srtp: Fix possible race condition, and add NULL checks"

21 months agoMerge "cdr / cel: Use event time at event creation instead of processing."
George Joseph [Thu, 8 Aug 2019 18:26:29 +0000 (13:26 -0500)]
Merge "cdr / cel: Use event time at event creation instead of processing."

21 months agoCI: Escape backslashes in printenv/sort/tr
George Joseph [Thu, 8 Aug 2019 17:10:11 +0000 (11:10 -0600)]
CI: Escape backslashes in printenv/sort/tr

Change-Id: I52be64c8f6af2bbe15148a856d1f10cb113e1e94
(cherry picked from commit c6558e09af3ac15b31377de735cc96d8df0275a7)

21 months agosrtp: Fix possible race condition, and add NULL checks
Kevin Harwell [Wed, 7 Aug 2019 22:54:34 +0000 (17:54 -0500)]
srtp: Fix possible race condition, and add NULL checks

Somehow it's possible for the srtp session object to be NULL even though the
Asterisk srtp object itself is valid. When this happened it would cause a
crash down in the srtp code when attempting to protect or unprotect data.

After looking at the code there is at least one spot that makes this situation
possible. If Asterisk fails to unprotect the data, and after several retries
it still can't then the srtp->session gets freed, and set to NULL while still
leaving the Asterisk srtp object around. However, according to the original
issue reporter this does not appear to be their situation since they found
no errors logged stating the above happened (which Asterisk does for that

An issue was found however, where a possible race condition could occur between
the pjsip incoming negotiation, and the receiving of RTP packets. Both places
could attempt to create/setup srtp for the same rtp instance at the same time.
This potentially could be the cause of the problem as well.

Given the above this patch adds locking around srtp setup for a given rtp, or
rtcp instance. NULL checks for the session have also been added within the
protect and unprotect functions as a precaution. These checks should at least
stop Asterisk from crashing if it gets in this situation again.

This patch also fixes one other issue noticed during investigation. When doing
a replace the old object was freed before creating the replacement. If the new
replacement object failed to create then the rtp/rtcp instance would now point
to freed srtp data which could potentially cause a crash as well when the next
attempt to reference it was made. This is now fixed so the old srtp object is
kept upon replacement failure.

Lastly, more logging has been added to help diagnose future issues.


Change-Id: I240e11cbb1e9ea8083d59d50db069891228fe5cc

21 months agoCI: Add "throttle" label and "skip_gate" capability
George Joseph [Thu, 8 Aug 2019 12:12:18 +0000 (06:12 -0600)]
CI:  Add "throttle" label and "skip_gate" capability

To make throttling by label fully active, the "throttle" option
has to be specified with a specific label.

You can now specify "skip_gate" in the Gerrit comments when you
do a +2 code review to tell Jenkins not to actually run the
gate.  You'd do this if you plan to manually merge the change.

Also updated the "printenv" debug output to better sort multi-line

Change-Id: I4c0b1085acec4805f2ca207eebac50aad81f27e2

21 months agoMerge "app_voicemail: Remove extra menuselect build options"
George Joseph [Thu, 8 Aug 2019 12:25:29 +0000 (07:25 -0500)]
Merge "app_voicemail: Remove extra menuselect build options"

21 months agoMerge "CI: Make node labels job-specific"
Friendly Automation [Wed, 7 Aug 2019 16:19:37 +0000 (11:19 -0500)]
Merge "CI:  Make node labels job-specific"

21 months agocdr / cel: Use event time at event creation instead of processing.
Joshua Colp [Mon, 5 Aug 2019 12:23:53 +0000 (09:23 -0300)]
cdr / cel: Use event time at event creation instead of processing.

When updating times on CDR or CEL records using the time at which
it is done can result in times being incorrect if the system is
heavily loaded and stasis message processing is delayed.

This change instead makes it so CDR and CEL use the time at which
the stasis messages that drive the systems are created. This allows
them to be backed up while still producing correct records.


Change-Id: I6829227e67aefa318efe5e183a94d4a1b4e8500a

21 months agoMerge "various modules: json integer overflow"
George Joseph [Tue, 6 Aug 2019 16:06:55 +0000 (11:06 -0500)]
Merge "various modules: json integer overflow"

21 months agoCI: Make node labels job-specific
George Joseph [Tue, 6 Aug 2019 15:40:54 +0000 (09:40 -0600)]
CI:  Make node labels job-specific

Originally, the eligible nodes for a job were labelled only by
"swdev-docker".  So basically any node could run any job.  We had
found that allowing a node to run more than 1 gate at a time was
problematic so we limited the nodes to processing 1 job at a time.
With the creation of the Asterisk 17 branches however, we now have
so many active branches that getting checks and gates through in
a timely manner is problematic when a node can run only 1 job
at a time.

Now the nodes are also labelled by the job type they can run.
For instance: "asterisk-check", "asterisk-gate", etc.  With the
"Throttle Concurrent Builds" plugin, we can now allow a node to
run more than 1 job BUT throttle by job type.  For instance:
  Allow 2 jobs but only 1 asterisk-gate at a time.
Now a node can run 2 checks or 1 check and 1 gate or 1 gate but
not 2 gates at a time.

Change-Id: I2032bf6afbcec5c341d9b852214c0c812d3d6db5

21 months agoMerge "res_musiconhold: Use a vector instead of custom array allocation"
Friendly Automation [Tue, 6 Aug 2019 15:27:16 +0000 (10:27 -0500)]
Merge "res_musiconhold: Use a vector instead of custom array allocation"

21 months agoMerge "main/udptl.c: correctly handle udptl sequence wrap around"
George Joseph [Tue, 6 Aug 2019 14:48:01 +0000 (09:48 -0500)]
Merge "main/udptl.c: correctly handle udptl sequence wrap around"

21 months agoapp_voicemail: Remove extra menuselect build options
Sean Bright [Tue, 6 Aug 2019 13:20:02 +0000 (09:20 -0400)]
app_voicemail: Remove extra menuselect build options

You now select voicemail backends like normal dialplan applications, so
there is no longer a need for their own menuselect category.

Reported by snuff-work in #asterisk-dev

Change-Id: Idfa4c9c8349726074318a9e6b68d24c374521005

21 months agovarious modules: json integer overflow
Kevin Harwell [Thu, 1 Aug 2019 21:22:01 +0000 (16:22 -0500)]
various modules: json integer overflow

There were still a few places in the code that could overflow when "packing"
a json object with a value outside the base type integer's range. For instance:

unsigned int value = INT_MAX + 1
ast_json_pack("{s: i}", value);

would result in a negative number being "packed". In those situations this patch
alters those values to a ast_json_int_t, which widens the value up to a long or
long long.


Change-Id: Ied530780d83e6f1772adba0e28d8938ef30c49a1

21 months agores_musiconhold: Use a vector instead of custom array allocation
Sean Bright [Mon, 29 Jul 2019 15:15:22 +0000 (11:15 -0400)]
res_musiconhold: Use a vector instead of custom array allocation

Change-Id: Ic476a56608b1820ca93dcf68d10cd76fc0b94141

21 months agores_pjsip: Fix multiple of the same contact in "pjsip show contacts".
Joshua Colp [Thu, 1 Aug 2019 10:07:45 +0000 (10:07 +0000)]
res_pjsip: Fix multiple of the same contact in "pjsip show contacts".

The code for gathering contacts could result in the same contact
being retrieved and added to the list multiple times. The container
which stores the contacts to display will now only allow a contact
to be added to it once instead of multiple times.


Change-Id: I805185cfcec03340f57d2b9e6cc43c49401812df

21 months agoMerge "res_musiconhold: Use ast_pipe_nonblock() wrapper"
Friendly Automation [Wed, 31 Jul 2019 13:09:29 +0000 (08:09 -0500)]
Merge "res_musiconhold: Use ast_pipe_nonblock() wrapper"

21 months agoMerge "manager: Send fewer packets"
Friendly Automation [Wed, 31 Jul 2019 12:29:00 +0000 (07:29 -0500)]
Merge "manager: Send fewer packets"

21 months agomain/udptl.c: correctly handle udptl sequence wrap around
Torrey Searle [Wed, 17 Jul 2019 12:35:50 +0000 (14:35 +0200)]
main/udptl.c: correctly handle udptl sequence wrap around

incorrect handling of UDPTL squence number wrap arounds causes
loss of packets every time the wrap around occurs

ASTERISK-28483 #close

Change-Id: I33caeb2bf13c574a1ebb81714b58907091d64234

21 months agoMerge "loader.c: Fix possible SEGV when a module fails to register"
Friendly Automation [Tue, 30 Jul 2019 12:53:23 +0000 (07:53 -0500)]
Merge "loader.c:  Fix possible SEGV when a module fails to register"

21 months agomanager: Send fewer packets
Sean Bright [Wed, 24 Jul 2019 20:12:49 +0000 (16:12 -0400)]
manager: Send fewer packets

The functions that build manager message headers do so in a way that
results in a single messages being split across multiple packets. While
this doesn't matter to the remote end, it makes network captures noisier
and harder to follow, and also means additional system calls.

With this patch, we build up more of the message content into the TLS
buffer before flushing to the network. This change is completely
internal to the manager code and does not affect any of the existing
API's consumers.

Change-Id: I50128b0769060ca5272dbbb5e60242d131eaddf9

21 months agoUpdate CHANGES and UPGRADE.txt for 17.0.0
Asterisk Development Team [Mon, 29 Jul 2019 16:38:30 +0000 (11:38 -0500)]
Update CHANGES and UPGRADE.txt for 17.0.0

21 months agoUpdate master for Asterisk 18
George Joseph [Fri, 26 Jul 2019 18:03:09 +0000 (12:03 -0600)]
Update master for Asterisk 18

Change-Id: I8b8ed97001446fab0c14d7c89391ee572fb29dd6

21 months agores_musiconhold: Use ast_pipe_nonblock() wrapper
Sean Bright [Mon, 29 Jul 2019 15:04:00 +0000 (11:04 -0400)]
res_musiconhold: Use ast_pipe_nonblock() wrapper

Change-Id: Ib0a4b41e5ececbe633079e2d8c2b66c031d2d1f2

21 months agoloader.c: Fix possible SEGV when a module fails to register
George Joseph [Mon, 29 Jul 2019 13:31:56 +0000 (07:31 -0600)]
loader.c:  Fix possible SEGV when a module fails to register

When a module fails to register itself (usually a coding error
in the module), dlerror() can return NULL.  We weren't checking
for that in load_dlopen() before trying to strdup the error message
so a SEGV was thrown.  dlerror() is now surrounded with an S_OR
so we don't SEGV.

Change-Id: Ie0fb9316f08a321434f3f85aecf3c7d2ede8b956

21 months agoMerge "contrib/scripts: Make Python 2.7+/3.3+ compatible"
George Joseph [Fri, 26 Jul 2019 17:03:04 +0000 (12:03 -0500)]
Merge "contrib/scripts: Make Python 2.7+/3.3+ compatible"

21 months agoMerge "CI: Don't enable non-core modules in Certified branches"
George Joseph [Fri, 26 Jul 2019 14:47:18 +0000 (09:47 -0500)]
Merge "CI:  Don't enable non-core modules in Certified branches"

21 months agoCI: Don't enable non-core modules in Certified branches
George Joseph [Wed, 24 Jul 2019 20:15:27 +0000 (14:15 -0600)]
CI:  Don't enable non-core modules in Certified branches

We don't support non-core modules for Certified releases but we
were enabling them for CI builds which was causing lots of test
failures.  Now we don't.

Change-Id: I0b3254c08a2479f3d39151690350cce5ce5ad766

21 months agores_config_sqlite3: Only join threads that we started
Sean Bright [Tue, 23 Jul 2019 17:58:31 +0000 (13:58 -0400)]
res_config_sqlite3: Only join threads that we started

ASTERISK-28477 #close
Reported by: Dennis

ASTERISK-28478 #close
Reported by: Dennis

Change-Id: I77347ad46a86dc5b35ed68270cee56acefb4f475

21 months agoMerge "openr2(6/6): Set hangup cause"
Friendly Automation [Wed, 24 Jul 2019 00:32:57 +0000 (19:32 -0500)]
Merge "openr2(6/6): Set hangup cause"

21 months agoMerge "openr2(5/6): added cli command -- mfcr2 destroy link <index>"
George Joseph [Tue, 23 Jul 2019 23:43:00 +0000 (18:43 -0500)]
Merge "openr2(5/6): added cli command -- mfcr2 destroy link <index>"

21 months agoMerge "openr2(4/6): added new cli command -- mfcr2 show links"
George Joseph [Tue, 23 Jul 2019 22:28:59 +0000 (17:28 -0500)]
Merge "openr2(4/6): added new cli command -- mfcr2 show links"

21 months agoMerge "openr2(3/6): Convert r2links to standard Asterisk AST_LIST*"
Friendly Automation [Tue, 23 Jul 2019 20:26:30 +0000 (15:26 -0500)]
Merge "openr2(3/6): Convert r2links to standard Asterisk AST_LIST*"

21 months agoMerge "openr2(2/6): Stop polling channels when DAHDI returns -ENODEV (e.g: plug-out)"
George Joseph [Tue, 23 Jul 2019 19:26:00 +0000 (14:26 -0500)]
Merge "openr2(2/6): Stop polling channels when DAHDI returns -ENODEV (e.g: plug-out)"

21 months agoMerge "openr2(1/6): bugfix in configuration saving"
George Joseph [Tue, 23 Jul 2019 18:02:42 +0000 (13:02 -0500)]
Merge "openr2(1/6): bugfix in configuration saving"

21 months agoMerge "chan_pjsip: Transmit REFER waits for the REFER result setting TRANSFERSTATUS"
George Joseph [Tue, 23 Jul 2019 14:18:42 +0000 (09:18 -0500)]
Merge "chan_pjsip:  Transmit REFER waits for the REFER result setting TRANSFERSTATUS"

21 months agoopenr2(6/6): Set hangup cause
Leonid Fainshtein [Sun, 12 May 2019 18:29:40 +0000 (21:29 +0300)]
openr2(6/6): Set hangup cause

Change-Id: I94dc38920e6e77cc73062648f62fdd613d0d1452
Signed-off-by: Oron Peled <>

21 months agoopenr2(5/6): added cli command -- mfcr2 destroy link <index>
Tzafrir Cohen [Mon, 22 Apr 2019 19:14:32 +0000 (22:14 +0300)]
openr2(5/6): added cli command -- mfcr2 destroy link <index>

Change-Id: I452d6a853bcd8c6e194455b19e5e017713e9c0fe
Signed-off-by: Oron Peled <>

21 months agoopenr2(4/6): added new cli command -- mfcr2 show links
Tzafrir Cohen [Mon, 22 Apr 2019 15:27:23 +0000 (18:27 +0300)]
openr2(4/6): added new cli command -- mfcr2 show links

* This command show the MFC/R2 links

Change-Id: I213822e1b7ef9c05bd89a2ba62df8e0856ce9f84
Signed-off-by: Oron Peled <>

21 months agoopenr2(3/6): Convert r2links to standard Asterisk AST_LIST*
Tzafrir Cohen [Mon, 22 Apr 2019 12:27:52 +0000 (15:27 +0300)]
openr2(3/6): Convert r2links to standard Asterisk AST_LIST*

Change-Id: Ibcb2401515a58782a1488c0b9efbed201c3f3a17
Signed-off-by: Oron Peled <>

21 months agoopenr2(2/6): Stop polling channels when DAHDI returns -ENODEV (e.g: plug-out)
Tzafrir Cohen [Mon, 22 Apr 2019 12:33:16 +0000 (15:33 +0300)]
openr2(2/6): Stop polling channels when DAHDI returns -ENODEV (e.g: plug-out)

Otherwise, OpenR2 threads go crazy and consume almost all CPU resources

Change-Id: I10a41f617613fe7399c5bdced5c64a2751173f28
Signed-off-by: Oron Peled <>

21 months agoopenr2(1/6): bugfix in configuration saving
Tzafrir Cohen [Mon, 22 Apr 2019 15:02:23 +0000 (18:02 +0300)]
openr2(1/6): bugfix in configuration saving

  - The memcpy() call copied part of "dahdi_conf" and not "dahdi_conf.mfcr2"
  - As a result, the memcmp() in dahdi_r2_get_link() always fails
  - This cause dahdi_r2_get_link() to create new link for every channel
    (instead of a new link for every ~30 channels)
  - With the fix, far less links are generated -- so we use far less threads

Change-Id: I7259dd6272f5e46e8a6c7f5bf3e8c2ec01b8c132
Signed-off-by: Oron Peled <>

21 months agocontrib/scripts: Make Python 2.7+/3.3+ compatible
Walter Doekes [Mon, 22 Jul 2019 15:43:48 +0000 (17:43 +0200)]
contrib/scripts: Make Python 2.7+/3.3+ compatible

Change-Id: Ica182a891743017ff3cda16de3d95335fffd9a91

21 months agoCI: Add cleanWs to cleanup steps in jenkinsfiles
George Joseph [Fri, 19 Jul 2019 16:20:38 +0000 (10:20 -0600)]
CI: Add cleanWs to cleanup steps in jenkinsfiles

We're at the point where there are enough Jenkins jobs for
Asterisk branches than even cleaned checkouts of Asterisk
will add up to more disk space than is available on the
in-memory workspace mount.  Since we archive all relevent
artifacts anyway, there's no need to keep the workspace
around after the job finishes, whether it succeeds or fails.

Change-Id: I1cd3b73ebb045a987df0f62526d152a510210c39

21 months agoMerge "CI: Add install-headers to the install make targets"
George Joseph [Fri, 19 Jul 2019 16:04:50 +0000 (11:04 -0500)]
Merge "CI:  Add install-headers to the install make targets"

21 months agoMerge " Update year"
George Joseph [Fri, 19 Jul 2019 14:48:27 +0000 (09:48 -0500)]
Merge " Update year"

21 months agoMerge "sched: Don't allow ast_sched_del to deadlock ast_sched_runq from same thread"
George Joseph [Fri, 19 Jul 2019 13:46:21 +0000 (08:46 -0500)]
Merge "sched: Don't allow ast_sched_del to deadlock ast_sched_runq from same thread"

21 months agoCI: Add install-headers to the install make targets
George Joseph [Fri, 19 Jul 2019 13:38:39 +0000 (07:38 -0600)]
CI:  Add install-headers to the install make targets

The testsuite actually needs the headers installed to run
it's self_test.

Change-Id: Ice41d331131b876ad4a9c056085fe6aac34b32b2

21 months agoMerge "Build: Separate header install/uninstall"
George Joseph [Fri, 19 Jul 2019 12:54:28 +0000 (07:54 -0500)]
Merge "Build: Separate header install/uninstall"