4 years agopjproject_bundled: Retry download if previously saved tarball is bad
George Joseph [Fri, 9 Dec 2016 14:14:09 +0000 (07:14 -0700)]
pjproject_bundled:  Retry download if previously saved tarball is bad

If a tarball is corrupted during download, the makefile will attempt to
download it again. If the tarball somehow gets corrupted after it's
downloaded however, the makefile was just failing.  We now
retry the download.

ASTERISK-26653 #close

Change-Id: I1b24d454852d80186f60c5a65dc4624ea8a1c359

4 years agoMerge "Fix IO conversion bug"
Joshua Colp [Fri, 9 Dec 2016 11:34:02 +0000 (05:34 -0600)]
Merge "Fix IO conversion bug"

4 years agoMerge "res_pjsip: Fix 'A = B != C' kind."
Joshua Colp [Fri, 9 Dec 2016 11:33:26 +0000 (05:33 -0600)]
Merge "res_pjsip: Fix 'A = B != C' kind."

4 years agoMerge "Fix typo in chan_sip"
Joshua Colp [Fri, 9 Dec 2016 11:32:44 +0000 (05:32 -0600)]
Merge "Fix typo in chan_sip"

4 years agoMerge "chan_sip: Delete unneeded check"
Joshua Colp [Fri, 9 Dec 2016 11:31:46 +0000 (05:31 -0600)]
Merge "chan_sip: Delete unneeded check"

4 years agoMerge "Small code cleanup in chan_sip"
Joshua Colp [Fri, 9 Dec 2016 11:31:33 +0000 (05:31 -0600)]
Merge "Small code cleanup in chan_sip"

4 years agoMerge "res_pjsip_registrar: AMI Add RegistrationInboundContactStatuses command"
Joshua Colp [Fri, 9 Dec 2016 11:30:02 +0000 (05:30 -0600)]
Merge "res_pjsip_registrar: AMI Add RegistrationInboundContactStatuses command"

4 years agoFix typo in chan_sip
Badalyan Vyacheslav [Thu, 8 Dec 2016 18:43:23 +0000 (18:43 +0000)]
Fix typo in chan_sip

The conditional expressions of the 'if' operators
situated alongside each other are identical.

Change-Id: I652b6dcddb3be007e669a6aa8107edb31a1ddafb

4 years agores_pjsip: Fix 'A = B != C' kind.
Badalyan Vyacheslav [Thu, 8 Dec 2016 18:30:38 +0000 (18:30 +0000)]
res_pjsip: Fix 'A = B != C' kind.

Consider reviewing the expression of the 'A = B != C' kind.
The expression is calculated as following: 'A = (B != C)'

Change-Id: Ibaa637dfda47d51a20e26069d3103e05ce80003d

4 years agochan_sip: Delete unneeded check
Badalyan Vyacheslav [Thu, 8 Dec 2016 18:54:06 +0000 (18:54 +0000)]
chan_sip: Delete unneeded check

P is always true. We check it before

Change-Id: Iee61cda002a9f61aee26b9f66c5f9b59e3389efb

4 years agoSmall code cleanup in chan_sip
Badalyan Vyacheslav [Thu, 8 Dec 2016 18:58:19 +0000 (18:58 +0000)]
Small code cleanup in chan_sip

The conditional expressions of the 'if' operators situated
alongside each other are identical.

Change-Id: I2cf7c317b106ec14440c7f1b5dcfbf03639f748a

4 years agoFix IO conversion bug
Badalyan Vyacheslav [Thu, 8 Dec 2016 18:34:28 +0000 (18:34 +0000)]
Fix IO conversion bug

Expression 'rlen < 0' is always false.
Unsigned type value is never < 0.

Change-Id: Id9f393ff25b009a6c4a6e40b95f561a9369e4585

4 years agoMerge "res_format_attr_opus: Fix crash when fmtp contains spaces."
Kevin Harwell [Thu, 8 Dec 2016 17:06:24 +0000 (11:06 -0600)]
Merge "res_format_attr_opus: Fix crash when fmtp contains spaces."

4 years agochan_sip: Do not allow non-SP/HTAB between header key and colon.
Walter Doekes [Wed, 30 Nov 2016 15:31:39 +0000 (16:31 +0100)]
chan_sip: Do not allow non-SP/HTAB between header key and colon.

RFC says SIP headers look like:

    HCOLON  =  *( SP / HTAB ) ":" SWS
    SWS     =  [LWS]                    ; sep whitespace
    LWS     =  [*WSP CRLF] 1*WSP        ; linear whitespace
    WSP     =  SP / HTAB                ; from rfc2234

chan_sip implemented this:

    HCOLON  =  *( LOWCTL / SP ) ":" SWS
    LOWCTL  = %x00-1F                   ; CTL without DEL

This discrepancy meant that SIP proxies in front of Asterisk with
chan_sip could pass on unknown headers with \x00-\x1F in them, which
would be treated by Asterisk as a different (known) header.  For
example, the "To\x01:" header would gladly be forwarded by some proxies
as irrelevant, but chan_sip would treat it as the relevant "To:" header.

Those relying on a SIP proxy to scrub certain headers could mistakenly
get unexpected and unvalidated data fed to Asterisk.

This change fixes so chan_sip only considers SP/HTAB as valid tokens
before the colon, making it agree on the headers with other speakers of

ASTERISK-26433 #close

Change-Id: I78086fbc524ac733b8f7f78cb423c91075fd489b

4 years agoMerge "tests_dns: Make DNS tests older nameser.h compatible"
Joshua Colp [Thu, 8 Dec 2016 14:09:07 +0000 (08:09 -0600)]
Merge "tests_dns: Make DNS tests older nameser.h compatible"

4 years agores_format_attr_opus: Fix crash when fmtp contains spaces.
Joshua Colp [Tue, 15 Nov 2016 00:18:21 +0000 (00:18 +0000)]
res_format_attr_opus: Fix crash when fmtp contains spaces.

When an opus offer or answer was received that contained an
fmtp line with spaces between the attributes the module would
fail to properly parse it and crash due to recursion.

This change makes the module handle the space properly and
also removes the recursion requirement.


Change-Id: I01f53e5d9fa9f1925a7365f8d25071b5b3ac2dc3

4 years agores_pjsip_registrar: AMI Add RegistrationInboundContactStatuses command
George Joseph [Tue, 6 Dec 2016 20:54:25 +0000 (13:54 -0700)]
res_pjsip_registrar: AMI Add RegistrationInboundContactStatuses command

The PJSIPShowRegistrationsInbound AMI command was just dumping out
all AORs which was pretty useless and resource heavy since it had
to get all endpoints, then all aors for each endpoint, then all
contacts for each aor.

PJSIPShowRegistrationInboundContactStatuses sends ContactStatusDetail
events which meets the intended purpose of the other command and has
significantly less overhead.  Also, some additional fields that were
added to Contact since the original creation of the ContactStatusDetail
event have been added to the end of the event.

For compatibility purposes, PJSIPShowRegistrationsInbound is left

ASTERISK-26644 #close

Change-Id: I326f12c9ecb52bf37ba03f0748749de4da01490a

4 years agotests_dns: Make DNS tests older nameser.h compatible
snuffy [Wed, 7 Dec 2016 20:22:33 +0000 (07:22 +1100)]
tests_dns: Make DNS tests older nameser.h compatible

Fix the tests for DNS to use older style nameser.h as
in ASTERISK-26608.

Tested on: OpenBSD 6.0, Debian 8

ASTERISK-26647 #close

Change-Id: I285913c44202537c04b3ed09c015efa6e5f9052d

4 years agoMerge "Bundled pjproject: Fix finding SIP transactions."
Joshua Colp [Wed, 7 Dec 2016 19:38:25 +0000 (13:38 -0600)]
Merge "Bundled pjproject:  Fix finding SIP transactions."

4 years agoMerge "http: Send headers and body in one write."
Joshua Colp [Wed, 7 Dec 2016 19:37:31 +0000 (13:37 -0600)]
Merge "http: Send headers and body in one write."

4 years agoMerge "Iostreams: Correct off-by-one error."
Joshua Colp [Wed, 7 Dec 2016 19:37:20 +0000 (13:37 -0600)]
Merge "Iostreams: Correct off-by-one error."

4 years agoBundled pjproject: Fix finding SIP transactions.
Richard Mudgett [Tue, 6 Dec 2016 22:45:38 +0000 (16:45 -0600)]
Bundled pjproject:  Fix finding SIP transactions.

Occasionally SIP message transactions are not found when they should be.
In the particular case an incoming INVITE transaction is CANCELed but the
INVITE transaction cannot be found so a 481 response is returned for the
CANCEL.  The problematic calls have a '_' character in the Via branch

The problem is in the pjproject PJ_HASH_USE_OWN_TOLOWER feature's code.
The problem with the "own tolower" code is that it does not calculate the
same hash value as when the pj_tolower() function is used.  The "own
tolower" code will erroneously modify the ASCII characters '@', '[', '\\',
']', '^', and '_'.  Calls to pj_hash_calc_tolower() can use the
PJ_HASH_USE_OWN_TOLOWER substitute algorithm when enabled.  Calls to
pj_hash_get_lower(), pj_hash_set_lower(), and pj_hash_set_np_lower() call
find_entry() which never uses the PJ_HASH_USE_OWN_TOLOWER algorithm.  As a
result you may not be able to find a hash tabled entry because the
calculated hash values would differ.

* Simply disable PJ_HASH_USE_OWN_TOLOWER.

ASTERISK-26490 #close

Change-Id: If89bfdb5f301b8b685881a9a2a6e0c3c5af32253

4 years agohttp: Send headers and body in one write.
Mark Michelson [Thu, 1 Dec 2016 22:49:03 +0000 (16:49 -0600)]
http: Send headers and body in one write.

This is a semi-regression caused by the iostreams change. Prior to
iostreams, HTTP headers were written to a FILE handle using fprintf.
Then the body was written using a call to fwrite(). Because of internal
buffering, the result was that the HTTP headers and body would be sent
out in a single write to the socket.

With the change to iostreams, the HTTP headers are written using
ast_iostream_printf(), which under the hood calls write(). The HTTP body
calls ast_iostream_write(), which also calls write() under the hood.
This results in two separate writes to the socket.

Most HTTP client libraries out there will handle this change just fine.
However, a few of our testsuite tests started failing because of the
change. As a result, in order to reduce frustration for users, this
change alters the HTTP code to write the headers and body in a single
write operation.

ASTERISK-26629 #close
Reported by Joshua Colp

Change-Id: Idc2d2fb3d9b3db14b8631a1e302244fa18b0e518

4 years agoIostreams: Correct off-by-one error.
Mark Michelson [Tue, 6 Dec 2016 16:56:06 +0000 (10:56 -0600)]
Iostreams: Correct off-by-one error.

ast_iostream_printf() attempts first to use a fixed-size buffer to
perform its printf-like operation. If the fixed-size buffer is too
small, then a heap allocation is used instead. The heap allocation in
this case was exactly the length of the string to print. The issue here
is that the ensuing call to vsnprintf() will print a NULL byte in the
final space of the string. This meant that the final character was being
chopped off the string and replaced with a NULL byte. For HTTP in
particular, this caused problems because HTTP publishes the expected
Contact-Length. This meant HTTP was publishing a length one character
larger than what was actually present in the message.

This patch corrects the issue by adding one to the allocation length.

Reported by Joshua Colp

Change-Id: Ib3c5f41e96833d0415cf000656ac368168add639

4 years agopjproject_bundled: Fix missing inclusion of symbols
George Joseph [Tue, 6 Dec 2016 18:06:45 +0000 (11:06 -0700)]
pjproject_bundled:  Fix missing inclusion of symbols

Added back in a -g3, and an -O3 when DONT_OPTIMIZE is not set, to
the CFLAGS.  Not sure how they went missing.

Also fixed an uninstall problem where we weren't removing the
symlink from to  While I was
there, I fixed it for libasteriskssl as well.

Change-Id: I9e00873b1e9082d05b5549d974534b48a2142556

4 years agoMerge "app_originate: Add option to execute gosub prior to dial"
Joshua Colp [Tue, 6 Dec 2016 11:34:54 +0000 (05:34 -0600)]
Merge "app_originate: Add option to execute gosub prior to dial"

4 years agoMerge "res_pjsip_outbound_registration.c: Filter redundant statsd reporting."
zuul [Tue, 6 Dec 2016 04:00:27 +0000 (22:00 -0600)]
Merge "res_pjsip_outbound_registration.c: Filter redundant statsd reporting."

4 years agoMerge "res_pjsip/chan_sip: Advertise 'ws' in the SIP URI transport parameter"
Joshua Colp [Fri, 2 Dec 2016 18:27:52 +0000 (12:27 -0600)]
Merge "res_pjsip/chan_sip: Advertise 'ws' in the SIP URI transport parameter"

4 years agores_pjsip_outbound_registration.c: Filter redundant statsd reporting.
Richard Mudgett [Thu, 1 Dec 2016 00:25:11 +0000 (18:25 -0600)]
res_pjsip_outbound_registration.c: Filter redundant statsd reporting.

Increasing the testsuite shutdown timeout before forcibly killing
Asterisk allowed more events to be sent out.  Some tests failed as
a result.  The tests/channels/pjsip/statsd/registrations failed
because we now get the statsd events that a comment in the test
configuration stated couldn't be intercepted.  Unfortunately, we
get a variable number of events because of internal status state
transition races generating redundant statsd events.

We were reporting redundant statsd PJSIP.registrations.state changes
for internal state changes that equated to the same thing publicly.

* Made update_client_state_status() filter out redundant statsd


Change-Id: If851c7d514bb530d9226e4941ba97dcf52000646

4 years agoMerge "tcptls: Use new certificate upon sip reload"
Joshua Colp [Fri, 2 Dec 2016 13:15:07 +0000 (07:15 -0600)]
Merge "tcptls: Use new certificate upon sip reload"

4 years agoMerge "PJPROJECT logging: Made easier to get available logging levels."
Joshua Colp [Fri, 2 Dec 2016 11:37:38 +0000 (05:37 -0600)]
Merge "PJPROJECT logging: Made easier to get available logging levels."

4 years agoMerge "pbx_lua: On configuration errors report module load failure instead of decline."
Joshua Colp [Fri, 2 Dec 2016 11:36:27 +0000 (05:36 -0600)]
Merge "pbx_lua: On configuration errors report module load failure instead of decline."

4 years agoMerge "res_rtp: Fix regression when IPv6 is not available."
Joshua Colp [Fri, 2 Dec 2016 00:45:53 +0000 (18:45 -0600)]
Merge "res_rtp: Fix regression when IPv6 is not available."

4 years agoMerge "res_calendar_caldav: Add support reading gmail calendar"
Joshua Colp [Thu, 1 Dec 2016 21:27:48 +0000 (15:27 -0600)]
Merge "res_calendar_caldav: Add support reading gmail calendar"

4 years agoMerge "Frame deferral: Re-queue deferred frames one-at-a-time."
Joshua Colp [Thu, 1 Dec 2016 19:22:17 +0000 (13:22 -0600)]
Merge "Frame deferral: Re-queue deferred frames one-at-a-time."

4 years agoMerge "OpenSSL 1.1.0 support"
zuul [Thu, 1 Dec 2016 05:26:46 +0000 (23:26 -0600)]
Merge "OpenSSL 1.1.0 support"

4 years agoOpenSSL 1.1.0 support
Tzafrir Cohen [Tue, 28 Jun 2016 21:26:59 +0000 (23:26 +0200)]
OpenSSL 1.1.0 support

OpenSSL 1.1.0 includes some major changes in the interface. See .

Status: Right now there are still a few deprecation notes with OpenSSL
1.1.0. But it's a start.

* CRYPTO_LOCK is no longer available. Replace it with its value for now.
  I don't completely understand what it is used for there.
* Remove several functions from libasteriskssl that seem to no longer be
* Structures have become opaque and are accesses with accessors.
* ERR_remove_thread_state() no longer needed.
* SSLv2 code now could no longer be used in 1.1.

ASTERISK-26109 #close

Change-Id: I5e29d477d486ca29b6aae0dc2f5dff960c1cb82b

4 years agores_rtp: Fix regression when IPv6 is not available.
Guido Falsi [Tue, 22 Nov 2016 17:20:06 +0000 (18:20 +0100)]
res_rtp: Fix regression when IPv6 is not available.

The latest Release candidate fails to create RTP streams when IPv6
is not available. Due to the changes made in September the ast_sockaddr
structure passed around to create these streams is always of AF_INET6
type, causing failure when used for IPv4. This patch adds a utility
function to check for availability of IPv6 and applies such check
at startup to determine how to create the ast_sockaddr structures.

ASTERISK-26617 #close

Change-Id: I627a4e91795e821111e1cda523f083a40d0e0c3e

4 years agoPJPROJECT logging: Made easier to get available logging levels.
Richard Mudgett [Thu, 24 Nov 2016 00:27:54 +0000 (18:27 -0600)]
PJPROJECT logging: Made easier to get available logging levels.

Use of the new logging is as simple as issuing the new CLI command or
setting the new pjproject.conf option.

Other options that can affect the logging are how you have the pjproject
log levels mapped to Asterisk log types in pjproject.conf and if you have
configured Asterisk to log the DEBUG type messages.  Altering the
pjproject.conf level mapping shouldn't be necessary for most installations
as the default mapping is sensible.  Configuring Asterisk to log the DEBUG
message type is standard practice for collecting debug information.

* Added CLI "pjproject set log level" command to dynamically adjust the
maximum pjproject log message level.

* Added CLI "pjproject show log level" command to see the currently set
maximum pjproject log message level.

* Added pjproject.conf startup section "log_level" option to set the
initial maximum pjproject log message level so all messages could be
captured from initialization.

* Set PJ_LOG_MAX_LEVEL to 6 to compile in all defined logging levels into
bundled pjproject.  Pjproject will use the currently set run time log
level to determine if a log message is generated just like Asterisk
verbose and debug logging levels.

* In log_forwarder(), made always log enabled and mapped pjproject log
messages.  DEBUG mapped log messages are no longer gated by the current
Asterisk debug logging level.

* Removed RAII_VAR() from res_pjproject.c:get_log_level().

ASTERISK-26630 #close

Change-Id: I6dca12979f482ffb0450aaf58db0fe0f6d2e5389

4 years agoFrame deferral: Re-queue deferred frames one-at-a-time.
Mark Michelson [Wed, 30 Nov 2016 16:48:39 +0000 (10:48 -0600)]
Frame deferral: Re-queue deferred frames one-at-a-time.

The recent change that made frame deferral into an API had a behavior
change to it. When frame deferral was completed, we would take all of
the deferred frames and queue them all onto the channel in one call to
ast_queue_frame_head(). Before frame deferral was API-ized, places that
performed manual frame deferral would actually take each deferred frame
and queue them onto the channel.

This change in behavior caused the confbridge_recording test to start
failing consistently. Without going too crazily deep into the details,
a channel was getting "stuck" in an ast_safe_sleep(). An AMI redirect
was attempting to break it out of the sleep, but because there were more
frames in the channel read queue than expected, the channel ended up
being unable to break from its sleep loop.

By restoring the behavior of individual frame queuing after deferral,
the test starts passing again.

Note, this points to a potential underlying issue pointing to an
"unbalance" that can occur when queuing multiple frames at once,
and so a follow-up issue is being created to investigate that

Change-Id: Ied5dacacda06d343dea751ed5814a03364fe5a7d

4 years agoMerge "chan_pjsip: fix switching sending codec when asymmetric_rtp_codec=no"
zuul [Wed, 30 Nov 2016 16:49:14 +0000 (10:49 -0600)]
Merge "chan_pjsip: fix switching sending codec when asymmetric_rtp_codec=no"

4 years agoMerge "chan_sip: Fix segfault during module unload"
Joshua Colp [Wed, 30 Nov 2016 15:21:34 +0000 (09:21 -0600)]
Merge "chan_sip: Fix segfault during module unload"

4 years agochan_pjsip: fix switching sending codec when asymmetric_rtp_codec=no
Alexei Gradinari [Tue, 15 Nov 2016 21:01:27 +0000 (16:01 -0500)]
chan_pjsip: fix switching sending codec when asymmetric_rtp_codec=no

The sending codec is switched to the receiving codec and then
is switched back to the best native codec on EVERY receiving RTP packets.
This is because after call of ast_channel_set_rawwriteformat there is call
of ast_set_write_format which calls set_format which sets rawwriteformat
to the best native format.

This patch adds a new function ast_set_write_format_path which set
specific write path on channel and uses this function to switch
the sending codec.

ASTERISK-26603 #close

Change-Id: I5b7d098f8b254ce8f45546e6c36e5d324737f71d

4 years agoapp_originate: Add option to execute gosub prior to dial
David Kerr [Mon, 21 Nov 2016 21:43:47 +0000 (16:43 -0500)]
app_originate: Add option to execute gosub prior to dial

Issue/patch ASTERISK-26587 was inspired by issue ASTERISK-22992
that requested ability to add callerid into app_originate.
Comments in that issue suggested that it was better solved by
adding an option to gosub prior to originating the call.  The
attached patch implements this much like app_dial with two
options one to gosub on the originating channel and one to gosub
on the newly created channel and behaves just like app_dial.
I have tested this patch by adding callerid info to the new
channel and also SIPAddHeader (to e.g. add header to force auto
answer) and confirmed it works.  Have also tested both 'exten'
and 'app' versions of app_originate.

Opened by: dkerr
Patch by: dkerr

Change-Id: I36abc39b58567ffcab4a636ea196ef48be234c57

4 years agores_calendar_caldav: Add support reading gmail calendar
Eduardo S. Libardi [Tue, 29 Nov 2016 01:43:53 +0000 (23:43 -0200)]
res_calendar_caldav: Add support reading gmail calendar

The response from gmail calendar includes the string name
"caldav:calendar-data". res_calendar_caldav implements
the example included in RFC 4791: string "C:calendar-data".
When reading the calendar, res_calendar_caldav compare the
string and if does not match just discards the event.
This commit compares the response to both strings,
successfully loading gmail calendar events.
Writing to gmail calendar is working prior to this fix.

Reported by: Eduardo S. Libardi

Change-Id: Ia1eef10552ae616efb645d390f5ffe81260d7d4a

4 years agoMerge "res/res_pjsip: Fix documentation whitespace issues"
Joshua Colp [Tue, 29 Nov 2016 01:00:32 +0000 (19:00 -0600)]
Merge "res/res_pjsip: Fix documentation whitespace issues"

4 years agoMerge "build_tools: Fix download_externals to handle certified branches"
zuul [Mon, 28 Nov 2016 22:07:20 +0000 (16:07 -0600)]
Merge "build_tools:  Fix download_externals to handle certified branches"

4 years agores/res_pjsip: Fix documentation whitespace issues
Matt Jordan [Mon, 28 Nov 2016 21:12:08 +0000 (15:12 -0600)]
res/res_pjsip: Fix documentation whitespace issues

Tabs > Spaces.

Change-Id: If1e43a71822615a898e958e0f8b2e882606f0bd0

4 years agores_pjsip/chan_sip: Advertise 'ws' in the SIP URI transport parameter
Matt Jordan [Tue, 22 Nov 2016 16:27:46 +0000 (10:27 -0600)]
res_pjsip/chan_sip: Advertise 'ws' in the SIP URI transport parameter

Per RFC 7118 5.2, the SIP URI 'transport' parameter should advertise
'ws' when WebSockets are to be used as the transport. This applies to
both secure and insecure WebSockets.

There were two bugs in Asterisk with respect to this:

(1) The most egregious occurs in res_pjsip. There, we advertise 'ws' for
    insecure websockets and 'wss' for secure websockets. While this
    would seem to make sense - since 'WS' and 'WSS' are used for the Via
    Transport parameter - this is not the case for the SIP URI. This
    patch corrects that by registering the secure websockets with
    pjproject using the shorthand 'WS', and by returning 'ws' when asked
    for the transport parameter. Note that in pjproject, it is perfectly
    valid to have multiple transports use the same shorthand.

(2) In chan_sip, we return an upper-case version of the transport 'WS'
    instead of 'ws'. Since we should be strict in what we send and
    liberal in what we accept (within reason), this patch lower-cases
    the transport before appending it to the parameter.

ASTERISK-24330 #close
Reported by: cervajs, Inaki Baz Castillo

Change-Id: Iff77b645f8cc3b7cd35168a6676c26b147f22f42

4 years agoMerge "autoconf: more variants for OSARCH linux-gnu"
Joshua Colp [Mon, 28 Nov 2016 17:33:47 +0000 (11:33 -0600)]
Merge "autoconf: more variants for OSARCH linux-gnu"

4 years agobuild_tools: Fix download_externals to handle certified branches
George Joseph [Mon, 28 Nov 2016 17:03:23 +0000 (10:03 -0700)]
build_tools:  Fix download_externals to handle certified branches

download_externals wasn't handling the "certified/13.x" version

Change-Id: I124d195bb117ca36fd7bf1150c630f3b474a9d9a

4 years agoMerge "codec_dahdi: Fix poll.h include."
Joshua Colp [Mon, 28 Nov 2016 16:24:24 +0000 (10:24 -0600)]
Merge "codec_dahdi: Fix poll.h include."

4 years agoMerge "ast_format: Adds an identifier for interleaved audio formats to the ast_format"
Joshua Colp [Mon, 28 Nov 2016 14:57:44 +0000 (08:57 -0600)]
Merge "ast_format: Adds an identifier for interleaved audio formats to the ast_format"

4 years agoiostream: Move include of asterisk.h
Joshua Colp [Mon, 28 Nov 2016 13:36:18 +0000 (13:36 +0000)]
iostream: Move include of asterisk.h

The asterisk.h header file needs to be included first or else
some things go awry, such as:

implicit declaration of function 'vasprintf'

Change-Id: I981dc2a77a1ba791888e4f1726644d4656c0407c

4 years agochan_sip: Fix segfault during module unload
Michael Kuron [Sat, 26 Nov 2016 16:57:03 +0000 (17:57 +0100)]
chan_sip: Fix segfault during module unload

If a TCP/TLS connection was pending (not accepted and not timed out) during
unload of chan_sip, Asterisk would segfault when trying to send a signal to
a thread whose thread ID hadn't been recorded yet. This commit fixes that by
recording the thread ID before calling the blocking connect() syscall.
This was a regression introduced by 776a14386a55b5425c7e9617eff8af8b45427144.

The above wasn't enough to fix the segfault, which was now delayed to the
point where connect() timed out. Therefore, it was necessary to also remove
the SA_RESTART flag from the SIGURG sigaction so that pthread_kill() could be
used to interruput the connect() syscall.
This was a regression introduced by 5d313f51b982a18f7321adcf7c7a4e822d8b2714.

ASTERISK-26586 #close

Change-Id: I76fd9d47d56e4264e2629bce8ec15fecba673e7b

4 years agopbx_lua: On configuration errors report module load failure instead of decline.
Dennis Guse [Wed, 23 Nov 2016 20:52:29 +0000 (21:52 +0100)]
pbx_lua: On configuration errors report module load failure instead of decline.

Therefore, if pbx_lua fails to load and pbx_lua is marked as required,
Asterisk exits as expected.
If extensions.lua cannot be opened, AST_MODULE_LOAD_DECLINE is reported.

Change-Id: I8e5a0037e69b41743db60c568541ebb2f52a7a8f

4 years agores_rtp_asterisk: RTT miscalculation in RTCP
gestoip2 [Fri, 11 Nov 2016 14:16:50 +0000 (14:16 +0000)]
res_rtp_asterisk: RTT miscalculation in RTCP

When retrieving RTCP stats for PJSIP channels, RTT values are unreliable.
RTT calculation is correct, but the data representation isn't.  RTT is
represented by a 32-bit fixed-point number with the integer part in the
first 16 bits and the fractional part in the last 16 bits.  In order to
get the RTT value, the fractional part is miscalculated, there is an
unnecessary 16 bit shift that causes overflow.  Besides this there is
another mistake, when transforming the integer value to the fixed point
fractional part via bitwise operation, that loses precision.

* RTT fractional part is no longer shifted, avoiding overflow.

* RTT fractional part is transformed to its fixed-point value more

* Fixed timeval2ntp() and ntp2timeval() second fraction conversions.

* Fixed NTP timestamp report logging.  The usec was inexplicably
multiplied by 4096.

ASTERISK-26566 #close
Reported by Hector Royo Concepcion

Change-Id: Ie09bdabfee75afb3f1b8ddfd963e5219ada3b96f

4 years agotcptls: Use new certificate upon sip reload
Michael Kuron [Tue, 15 Nov 2016 19:44:13 +0000 (20:44 +0100)]
tcptls: Use new certificate upon sip reload

Previously, a TLS server socket would only be restarted upon sip reload if the
bind address had changed. This commit adds checking for changes to TLS
parameters like certificate, ciphers, etc. so they get picked up without
requiring a reload of the entire chan_sip module. This does not affect open
connections in any way, but new connections will use the new TLS parameters.
The changes also apply to HTTP and Manager.

ASTERISK-26604 #close

Change-Id: I169e86cefc6dcd627c915134015a6a1ab1aadbe6

4 years agoMerge "addons/chan_mobile: do not use strerror_r"
Joshua Colp [Tue, 22 Nov 2016 18:03:35 +0000 (12:03 -0600)]
Merge "addons/chan_mobile: do not use strerror_r"

4 years agoMerge "Add support for older name resolving version libraries like openBSD"
Joshua Colp [Tue, 22 Nov 2016 17:54:35 +0000 (11:54 -0600)]
Merge "Add support for older name resolving version libraries like openBSD"

4 years agopjproject_bundled: Use $(LIB_RT) for link of libasteriskpj
George Joseph [Mon, 21 Nov 2016 15:49:45 +0000 (08:49 -0700)]
pjproject_bundled:  Use $(LIB_RT) for link of libasteriskpj

libasteriskpj was hard coded to use -lrt but librt is linux specific
so we now use the LIB_RT variable which gets set by configure.

Change-Id: I41148884517e3031f7675a413d524c86e8614694

4 years agoMerge "pjproject_bundled: Improve reliability of pjproject download"
zuul [Mon, 21 Nov 2016 12:22:07 +0000 (06:22 -0600)]
Merge "pjproject_bundled:  Improve reliability of pjproject download"

4 years agoMerge "main/app.c: Transmit Silence on ControlPlayback pause"
Joshua Colp [Mon, 21 Nov 2016 10:46:37 +0000 (04:46 -0600)]
Merge "main/app.c: Transmit Silence on ControlPlayback pause"

4 years agoMerge "Add support for building RADIUS with radcli"
zuul [Mon, 21 Nov 2016 04:57:12 +0000 (22:57 -0600)]
Merge "Add support for building RADIUS with radcli"

4 years agoAdd support for older name resolving version libraries like openBSD
snuffy [Sat, 19 Nov 2016 22:19:18 +0000 (09:19 +1100)]
Add support for older name resolving version libraries like openBSD

Fix support of OS's like openBSD that use an older nameser.h,
this change reverts the defines to the older style which on other
systems is found in nameser_compat.h

Tested on openBSD 6.0, Debian 8

ASTERISK-26608 #close

Change-Id: Iffb36caab8c5aa9dece0ce2d009041f7b56cc86a

4 years agoBump ARI version to 2.0.0
Mark Michelson [Fri, 18 Nov 2016 15:46:48 +0000 (09:46 -0600)]
Bump ARI version to 2.0.0

In order to not have version number overlap between different versions
of Asterisk, each new major version of Asterisk will mean we also bump
the ARI major version number.

This particular change does NOT introduce any known breaking changes to

For discussion relating to this topice, see:

Change-Id: I712ee0df177a8fe1252da2bc029705268b97b665

4 years agoMerge "build: Various OpenBSD issues"
zuul [Fri, 18 Nov 2016 14:31:46 +0000 (08:31 -0600)]
Merge "build:  Various OpenBSD issues"

4 years agopjproject_bundled: Improve reliability of pjproject download
George Joseph [Wed, 16 Nov 2016 18:05:43 +0000 (11:05 -0700)]
pjproject_bundled:  Improve reliability of pjproject download

The download process now has a timeout which will cause wget to retry
if it stops retrieving data for 5 seconds and fetch and curl to timeout
if the whole retrieval take smore than 30 seconds.

If the tarball retrieval works, the MD5SUM file is retrieved from
the downloads site and the md5 checksum is verified.

If either the tarball retrieval or MD5SUM retrieval fails, or the
checksums don't match, the entire process is retried once.  If it
fails again, any incomplete tarball is deleted.

.DELETE_ON_ERROR: was also added to the Makefile.  Not only does
this delete the tarball on failure, it till also delete corrupted
library files from the pjproject source directory should they
fail to build correctly.

Tested all the way back to FreeBSD 9, CentOS 6, Debian 6 and
Ubuntu 14.

Change-Id: Iea7d33b96a31622ab1b6e54baebaf271959514e1

4 years agoMerge "manager: update minor version"
Joshua Colp [Fri, 18 Nov 2016 12:58:11 +0000 (06:58 -0600)]
Merge "manager: update minor version"

4 years agomain/app.c: Transmit Silence on ControlPlayback pause
misha [Fri, 11 Nov 2016 13:13:30 +0000 (14:13 +0100)]
main/app.c: Transmit Silence on ControlPlayback pause

ASTERISK-26562 #close

Change-Id: Ie6cb0ffc2b8c775639ce7784fe96f4ea00cfa2f8

4 years agoMerge "Implement internal abstraction for iostreams"
Joshua Colp [Thu, 17 Nov 2016 17:07:06 +0000 (11:07 -0600)]
Merge "Implement internal abstraction for iostreams"

4 years agomanager: update minor version
Mark Michelson [Thu, 17 Nov 2016 16:52:45 +0000 (10:52 -0600)]
manager: update minor version

Based on bridge video AMI event changes, bump the minor version of AMI.

Change-Id: Idf84507354170400813cda780906c94c9f1b60b4

4 years agocodec_dahdi: Fix poll.h include.
Timo Teräs [Thu, 17 Nov 2016 14:25:41 +0000 (16:25 +0200)]
codec_dahdi: Fix poll.h include.

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

Change-Id: Ib318c1c7142a737bcf3caa4d8d72560bebe39252

4 years agoMerge "res_pjsip_outbound_authenticator_digest.c: Fix memory pool leak."
Joshua Colp [Thu, 17 Nov 2016 10:56:34 +0000 (04:56 -0600)]
Merge "res_pjsip_outbound_authenticator_digest.c: Fix memory pool leak."

4 years agoMerge "codec_opus: Fix warning when Opus negotiated but codec_opus not loaded."
Joshua Colp [Thu, 17 Nov 2016 10:56:16 +0000 (04:56 -0600)]
Merge "codec_opus: Fix warning when Opus negotiated but codec_opus not loaded."

4 years agoMerge "res_format_attr_opus: Fix fmtp generation."
zuul [Thu, 17 Nov 2016 05:20:04 +0000 (23:20 -0600)]
Merge "res_format_attr_opus: Fix fmtp generation."

4 years agobuild: Various OpenBSD issues
George Joseph [Thu, 17 Nov 2016 02:24:08 +0000 (19:24 -0700)]
build:  Various OpenBSD issues

OpenBSD's 'find' doesn't take the -delete argument so you have to pipe
through 'xargs rm -rf'.

'echo -e' doesn't like \t starting a line. It just prints 't' which
causes the libasteriskpj.exports file to be garbage.  They were just
cosmetic so they were removed.

librt doesn't exist so the link of fails. It's not
actually needed for linux anyway so -lrt was removed from the link.

res_rtp_asterisk was failing to load because of an undefined
DTLS_method. '|| defined(LIBRESSL_VERSION_NUMBER)' was added to the #if
so DTLSv1_method is used instead.


Change-Id: I926ec95b0b69633231e3ad1d6e803b977272c49c

4 years agoMerge "channel: Fix issues in hangup scenarios caused by frame deferral"
George Joseph [Wed, 16 Nov 2016 23:45:16 +0000 (17:45 -0600)]
Merge "channel:  Fix issues in hangup scenarios caused by frame deferral"

4 years agoMerge "Revert "Revert "channel: Use frame deferral API for safe sleep."""
George Joseph [Wed, 16 Nov 2016 23:45:05 +0000 (17:45 -0600)]
Merge "Revert "Revert "channel: Use frame deferral API for safe sleep."""

4 years agoMerge "Revert "Revert "autoservice: Use frame deferral API"""
George Joseph [Wed, 16 Nov 2016 23:44:21 +0000 (17:44 -0600)]
Merge "Revert "Revert "autoservice: Use frame deferral API"""

4 years agoMerge "Revert "Revert "AGI: Only defer frames when in an interception routine."""
George Joseph [Wed, 16 Nov 2016 23:44:12 +0000 (17:44 -0600)]
Merge "Revert "Revert "AGI: Only defer frames when in an interception routine."""

4 years agoMerge "Revert "Revert "Add API for channel frame deferral."""
George Joseph [Wed, 16 Nov 2016 23:43:46 +0000 (17:43 -0600)]
Merge "Revert "Revert "Add API for channel frame deferral."""

4 years agoMerge "res/ari/resource_bridges: Add the ability to manipulate the video source"
zuul [Wed, 16 Nov 2016 22:48:09 +0000 (16:48 -0600)]
Merge "res/ari/resource_bridges: Add the ability to manipulate the video source"

4 years agores_format_attr_opus: Fix fmtp generation.
Mark Michelson [Wed, 16 Nov 2016 21:42:39 +0000 (15:42 -0600)]
res_format_attr_opus: Fix fmtp generation.

res_format_attr_opus assumed that the string being passed into it was
empty. It tried to determine if the only thing it had written was


And if it had, it would reset the string. Its calculation was off when
working with chan_sip, though. chan_sip passes the entire built SDP
rather than an empty string. This resulted in always putting an empty
fmtp line in the SDP.

ASTERISK-26520 #close
Reported by scgm11

Change-Id: Ib2e8712d26a47067e5f36d5973577added01dbb5

4 years agoMerge "apps/app_echo: Only relay a single video source change frame"
Joshua Colp [Wed, 16 Nov 2016 20:59:50 +0000 (14:59 -0600)]
Merge "apps/app_echo: Only relay a single video source change frame"

4 years agoMerge "file.c/__ast_file_read_dirs: Fix issues on filesystems without d_type"
George Joseph [Wed, 16 Nov 2016 20:17:34 +0000 (14:17 -0600)]
Merge "file.c/__ast_file_read_dirs:  Fix issues on filesystems without d_type"

4 years agocodec_opus: Fix warning when Opus negotiated but codec_opus not loaded.
Richard Mudgett [Tue, 15 Nov 2016 22:23:35 +0000 (16:23 -0600)]
codec_opus: Fix warning when Opus negotiated but codec_opus not loaded.

When Opus is negotiated but not loaded, the log is spammed with messages
because the system does not know how to calculate the number of samples in
a frame.

* Suppress the warning by supplying a function that assumes 20ms of
samples in the frame.  For pass through support it doesn't really seem to
matter what number of samples is returned anyway.

ASTERISK-26605 #close

Change-Id: Icf2273692f040dc2c45b01e72a790d11092f9e0f

4 years agoMerge "cli: Fix ast_el_read_char to work with libedit >= 3.1"
Joshua Colp [Wed, 16 Nov 2016 18:18:27 +0000 (12:18 -0600)]
Merge "cli:  Fix ast_el_read_char to work with libedit >= 3.1"

4 years agores_pjsip_outbound_authenticator_digest.c: Fix memory pool leak.
Richard Mudgett [Mon, 14 Nov 2016 20:36:52 +0000 (14:36 -0600)]
res_pjsip_outbound_authenticator_digest.c: Fix memory pool leak.

Responding to authentication challenges leaks PJSIP memory pools.

The leak was introduced with a pjproject 2.5.5 API change. changed the API usage of
pjsip_auth_clt_init() to require the new API pjsip_auth_clt_deinit() to
clean up cached authentication allocations that get allocated with

ASTERISK-26516 #close

Change-Id: I4473141b8c3961d0dc91c382beb3876b3efb45c8

4 years agoMerge "pjproject: Use a much higher limit for PJ_ICE_MAX_CHECKS"
Joshua Colp [Wed, 16 Nov 2016 11:33:42 +0000 (05:33 -0600)]
Merge "pjproject: Use a much higher limit for PJ_ICE_MAX_CHECKS"

4 years agofile.c/__ast_file_read_dirs: Fix issues on filesystems without d_type
George Joseph [Tue, 15 Nov 2016 18:01:04 +0000 (11:01 -0700)]
file.c/__ast_file_read_dirs:  Fix issues on filesystems without d_type

One of the code paths in __ast_file_read_dirs will only get executed if
the OS doesn't support dirent->d_type OR if the filesystem the
particular file is on doesn't support it.  So, while standard Linux
systems support the field, some filesystems like XFS do not.  In this
case, we need to call stat() to determine whether the directory entry
is a file or directory so we append the filename to the supplied
directory path and call stat.  We forgot to truncate path back to just
the directory afterwards though so we were passing a complete file name
to the callback in the dir_name parameter instead of just the directory

The logic has been re-written to only create a full_path if we need to
call stat() or if we need to descend into another directory.

Change-Id: I54e4228bd8355fad65200c6df3ec4c9c8a98dfba

4 years agoMerge "manager: Bump AMI version number."
Joshua Colp [Wed, 16 Nov 2016 01:23:08 +0000 (19:23 -0600)]
Merge "manager: Bump AMI version number."

4 years agoMerge "res_ari: Add support for channel variables in ARI events."
Joshua Colp [Tue, 15 Nov 2016 20:49:15 +0000 (14:49 -0600)]
Merge "res_ari: Add support for channel variables in ARI events."

4 years agoImplement internal abstraction for iostreams
Timo Teräs [Thu, 2 Jun 2016 19:10:06 +0000 (22:10 +0300)]
Implement internal abstraction for iostreams

fopencookie/funclose is a non-standard API and should not be used
in portable software. Additionally, the way FILE's fd is used in
non-blocking mode is undefined behaviour and cannot be relied on.

This introduces internal abstraction for io streams, that allows
implementing the desired virtualization of read/write operations
with necessary timeout handling.

ASTERISK-24515 #close
ASTERISK-24517 #close

Change-Id: Id916aef418b665ced6a7489aef74908b6e376e85

4 years agomanager: Bump AMI version number.
Joshua Colp [Tue, 15 Nov 2016 14:07:03 +0000 (14:07 +0000)]
manager: Bump AMI version number.

During the development of Asterisk 14 the behavior of
the Command AMI action was altered such that the result
was returned on lines with a prefix of "Output: ". While
this was documented in the UPGRADE.txt file it is also
reasonable that this should bump the AMI version number.


Change-Id: Idf1bf01608e53f7bfdf43ddb4d0683e53f74ee42

4 years agopjproject: Use a much higher limit for PJ_ICE_MAX_CHECKS
Matt Jordan [Mon, 14 Nov 2016 21:57:08 +0000 (15:57 -0600)]
pjproject: Use a much higher limit for PJ_ICE_MAX_CHECKS

The PJ_ICE_MAX_CHECKS constant is used by pjproject to determine how
many pairs of local/remote candidates will be made. If for some reason
we reach this upper bound, ICE will generally fail and no media will
flow between the browser and Asterisk.

This patch makes PJ_ICE_MAX_CHECKS set to the total possible number of
pairs of candidates we'd theoretically allow, which is
PJ_ICE_MAX_CAND^2. Prior to this patch, we simply multiplied
PJ_ICE_MAX_CAND by two; on systems with multiple interfaces (I blame
Docker), this is far too low to allow WebRTC calls to succeed.

Setting this to be PJ_ICE_MAX_CAND^2 allowed WebRTC calls to succeed
even when the system Asterisk was running on had quite a few virtual

Change-Id: Icd4f17de0ac9d3a83dddfc8bf1cb7616bc107d55

4 years agoapps/app_echo: Only relay a single video source change frame
Matt Jordan [Mon, 14 Nov 2016 21:32:14 +0000 (15:32 -0600)]
apps/app_echo: Only relay a single video source change frame

In 9785e8d0, app_echo was updated to relay video source updates to the
channel for the purposes of displaying video in WebRTC tests.
Unfortunately, this can cause a Kafkaesque nightmare if two or more
Local channels are in a bridge together where their ends are in
app_echo. When this situation occurs, a video update sent into app_echo
will cause the video update to be relayed to the other Local channels,
causing another round of video updates, etc. In not much time at all,
the channel length queues will be overwhelmed, channel alert pipes will
fail, and all hell will break loose as Asterisk merrily continues to
throw more video update requests onto the channels.

This patch updates app_echo to *only* relay a single video update. Once
a video update has been made, all further video updates are dropped.
This meets the intended purpose of the original patch: if we get a video
update and we're in app_echo, go ahead and ask the sender to update
themselves. However, once we've got that video stream sync'd up, don't
keep spamming the world.

Change-Id: I9210780b08d4c17ddb38599d1c64453adfc34f74

4 years agores/ari/resource_bridges: Add the ability to manipulate the video source
Matt Jordan [Tue, 8 Nov 2016 16:11:41 +0000 (10:11 -0600)]
res/ari/resource_bridges: Add the ability to manipulate the video source

In multi-party bridges, Asterisk currently supports two video modes:
 * Follow the talker, in which the speaker with the most energy is shown
   to all participants but the speaker, and the speaker sees the
   previous video source
 * Explicitly set video sources, in which all participants see a locked
   video source

Prior to this patch, ARI had no ability to manipulate the video source.
This isn't important for two-party bridges, in which Asterisk merely
relays the video between the participants. However, in a multi-party
bridge, it can be advantageous to allow an external application to
manipulate the video source.

This patch provides two new routes to accomplish this:
(1) setVideoSource: POST /bridges/{bridgeId}/videoSource/{channelId}
    Sets a video source to an explicit channel
(2) clearVideoSource: DELETE /bridges/{bridgeId}/videoSource
    Removes any explicit video source, and sets the video mode to talk

ASTERISK-26595 #close

Change-Id: I98e455d5bffc08ea5e8d6b84ccaf063c714e6621

4 years agochannel: Fix issues in hangup scenarios caused by frame deferral
George Joseph [Mon, 14 Nov 2016 20:03:46 +0000 (13:03 -0700)]
channel:  Fix issues in hangup scenarios caused by frame deferral


Change-Id: I06dbf7366e26028251964143454a77d017bb61c8
(cherry picked from commit 0be46aaf6b8b9eb5b0160ec591cdc2c6e1802a6d)

4 years agoRevert "Revert "channel: Use frame deferral API for safe sleep.""
George Joseph [Mon, 14 Nov 2016 19:55:45 +0000 (14:55 -0500)]
Revert "Revert "channel: Use frame deferral API for safe sleep.""

This reverts commit e5365dada5052b87275c048f6e29ac7d5e2b2415.

Change-Id: Icc40cf0c7687454760762912dd29e4ae79e8e9ee