Commit graph

28810 commits

Author SHA1 Message Date
Joshua Colp
1067b9add3 Merge "Bundled pjproject: Fix finding SIP transactions." 2016-12-07 13:38:25 -06:00
Joshua Colp
18fe80e776 Merge "http: Send headers and body in one write." 2016-12-07 13:37:31 -06:00
Joshua Colp
119c41d001 Merge "Iostreams: Correct off-by-one error." 2016-12-07 13:37:20 -06:00
Richard Mudgett
76d52dc228 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
parameter.

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
2016-12-07 06:16:48 -06:00
Mark Michelson
503006123a 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
2016-12-07 05:10:32 -06:00
Mark Michelson
bf6423a336 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.

ASTERISK-26629
Reported by Joshua Colp

Change-Id: Ib3c5f41e96833d0415cf000656ac368168add639
2016-12-06 12:34:51 -06:00
George Joseph
fe9f070885 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 libasteriskpj.so.2 to libasteriskpj.so.  While I was
there, I fixed it for libasteriskssl as well.

Change-Id: I9e00873b1e9082d05b5549d974534b48a2142556
2016-12-06 12:21:12 -06:00
Joshua Colp
faf2194fab Merge "app_originate: Add option to execute gosub prior to dial" 2016-12-06 05:34:54 -06:00
zuul
8bd9dc568a Merge "res_pjsip_outbound_registration.c: Filter redundant statsd reporting." 2016-12-05 22:00:27 -06:00
Joshua Colp
2a415187c5 Merge "res_pjsip/chan_sip: Advertise 'ws' in the SIP URI transport parameter" 2016-12-02 12:27:52 -06:00
Richard Mudgett
4b3d3fc741 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
updates.

ASTERISK-26527

Change-Id: If851c7d514bb530d9226e4941ba97dcf52000646
2016-12-02 11:56:59 -06:00
Joshua Colp
cd5d9d1d69 Merge "tcptls: Use new certificate upon sip reload" 2016-12-02 07:15:08 -06:00
Joshua Colp
197e408395 Merge "PJPROJECT logging: Made easier to get available logging levels." 2016-12-02 05:37:38 -06:00
Joshua Colp
a2343aa200 Merge "pbx_lua: On configuration errors report module load failure instead of decline." 2016-12-02 05:36:27 -06:00
Joshua Colp
2679f80d3c Merge "res_rtp: Fix regression when IPv6 is not available." 2016-12-01 18:45:53 -06:00
Joshua Colp
29596f1538 Merge "res_calendar_caldav: Add support reading gmail calendar" 2016-12-01 15:27:48 -06:00
Joshua Colp
02588a1aab Merge "Frame deferral: Re-queue deferred frames one-at-a-time." 2016-12-01 13:22:17 -06:00
zuul
68fc035795 Merge "OpenSSL 1.1.0 support" 2016-11-30 23:26:46 -06:00
Tzafrir Cohen
26c8552fff OpenSSL 1.1.0 support
OpenSSL 1.1.0 includes some major changes in the interface. See
https://wiki.openssl.org/index.php/1.1_API_Changes .

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

Changes:
* 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
  needed.
* 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
2016-12-01 01:22:45 +00:00
Guido Falsi
75230f4c01 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
2016-11-30 14:18:05 -05:00
Richard Mudgett
1dfa11b65c 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
2016-11-30 13:11:48 -06:00
Mark Michelson
621d886ca7 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
possibility.

Change-Id: Ied5dacacda06d343dea751ed5814a03364fe5a7d
2016-11-30 13:02:04 -05:00
zuul
a0c0b1c9cb Merge "chan_pjsip: fix switching sending codec when asymmetric_rtp_codec=no" 2016-11-30 10:49:14 -06:00
Joshua Colp
bd20127e64 Merge "chan_sip: Fix segfault during module unload" 2016-11-30 09:21:34 -06:00
Alexei Gradinari
e5e887be53 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
2016-11-30 07:55:24 -05:00
David Kerr
ddc951060a 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
2016-11-29 19:40:02 -05:00
Eduardo S. Libardi
0e214c4932 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.

ASTERISK-26624
Reported by: Eduardo S. Libardi

Change-Id: Ia1eef10552ae616efb645d390f5ffe81260d7d4a
2016-11-29 13:35:26 -02:00
Joshua Colp
fdf4355bd0 Merge "res/res_pjsip: Fix documentation whitespace issues" 2016-11-28 19:00:32 -06:00
zuul
350a9a6bd4 Merge "build_tools: Fix download_externals to handle certified branches" 2016-11-28 16:07:20 -06:00
Matt Jordan
a3f48be0da res/res_pjsip: Fix documentation whitespace issues
Tabs > Spaces.

Change-Id: If1e43a71822615a898e958e0f8b2e882606f0bd0
2016-11-28 16:13:30 -05:00
Matt Jordan
0e15760795 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
2016-11-28 14:37:50 -05:00
Joshua Colp
606ab90c25 Merge "autoconf: more variants for OSARCH linux-gnu" 2016-11-28 11:33:47 -06:00
George Joseph
8a68289766 build_tools: Fix download_externals to handle certified branches
download_externals wasn't handling the "certified/13.x" version
correctly.

Change-Id: I124d195bb117ca36fd7bf1150c630f3b474a9d9a
2016-11-28 12:09:48 -05:00
Joshua Colp
acdae08cf7 Merge "codec_dahdi: Fix poll.h include." 2016-11-28 10:24:24 -06:00
Joshua Colp
c9cc64b911 Merge "ast_format: Adds an identifier for interleaved audio formats to the ast_format" 2016-11-28 08:57:44 -06:00
Joshua Colp
e3dae763ee 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
2016-11-28 13:36:54 +00:00
Michael Kuron
0b588778c0 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 776a14386a.

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 5d313f51b9.

ASTERISK-26586 #close

Change-Id: I76fd9d47d56e4264e2629bce8ec15fecba673e7b
2016-11-26 18:20:06 +01:00
Dennis Guse
ead773f801 pbx_lua: On configuration errors report module load failure instead of decline.
Switched from AST_MODULE_LOAD_DECLINE to AST_MODULE_LOAD_FAILURE.
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
2016-11-23 23:15:35 +01:00
gestoip2
d9b24cce0a 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
precisely.

* 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
2016-11-23 11:15:42 -05:00
Michael Kuron
635b0a0a55 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
2016-11-22 14:21:28 -05:00
Joshua Colp
038158bf7b Merge "addons/chan_mobile: do not use strerror_r" 2016-11-22 12:03:35 -06:00
Joshua Colp
b1f7cc4223 Merge "Add support for older name resolving version libraries like openBSD" 2016-11-22 11:54:35 -06:00
George Joseph
abae3dc36e 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
2016-11-21 11:48:05 -05:00
zuul
aa9d91c290 Merge "pjproject_bundled: Improve reliability of pjproject download" 2016-11-21 06:22:07 -06:00
Joshua Colp
84e508c999 Merge "main/app.c: Transmit Silence on ControlPlayback pause" 2016-11-21 04:46:37 -06:00
zuul
120a4999f0 Merge "Add support for building RADIUS with radcli" 2016-11-20 22:57:12 -06:00
snuffy
b546497fe0 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
2016-11-20 09:19:18 +11:00
Mark Michelson
7a8d6bc81b 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
ARI.

For discussion relating to this topice, see:
http://lists.digium.com/pipermail/asterisk-dev/2016-November/075964.html

Change-Id: I712ee0df177a8fe1252da2bc029705268b97b665
2016-11-18 10:56:31 -05:00
zuul
782985631e Merge "build: Various OpenBSD issues" 2016-11-18 08:31:46 -06:00
George Joseph
d3f070c7a2 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
2016-11-18 08:01:36 -05:00