asterisk/asterisk.git
2 years agodebug_utilities: Create the ast_coredumper utility
George Joseph [Wed, 11 Jan 2017 00:10:39 +0000 (17:10 -0700)]
debug_utilities:  Create the ast_coredumper utility

This utility allows easy manipulation of asterisk coredumps.

* Configurable search paths and patterns for existing coredumps
* Can generate a consistent coredump from the running instance
* Can dump the lock_infos table from a coredump
* Dumps backtraces to separate files...
  - thread apply 1 bt full -> <coredump>.thread1.txt
  - thread apply all bt -> <coredump>.brief.txt
  - thread apply all bt full -> <coredump>.full.txt
  - lock_infos table -> <coredump>.locks.txt
* Can tarball corefiles and optionally delete them after processing
* Can tarball results files and optionally delete them after processing
* Converts ':' in coredump and results file names '-' to facilitate
  uploading.  Jira for instance, won't accept file names with colons
  in them.

Tested on Fedora24+, Ubuntu14+, Debian6+, CentOS6+ and FreeBSD9+[1].

[1] For *BSDs, the "devel/gdb" package might have to be installed to
get a recent gdb.  The utility will check all instances of gdb
it finds in $PATH and if one isn't found that can run python, it
prints a friendly error.

Change-Id: I935d37ab9db85ef923f32b05579897f0893d33cd
(cherry picked from commit cb47b4556053cd50d9102eef913671ad0306062d)

2 years agoMerge "app_queue: add new Service Level calculation"
zuul [Tue, 10 Jan 2017 20:01:34 +0000 (14:01 -0600)]
Merge "app_queue: add new Service Level calculation"

2 years agoMerge "res_pjsip_endpoint_identifier_ip: Add support for SRV lookups."
zuul [Mon, 9 Jan 2017 18:44:58 +0000 (12:44 -0600)]
Merge "res_pjsip_endpoint_identifier_ip: Add support for SRV lookups."

2 years agoMerge "chan_sip: Remember SDP negotiation on SIP_CODEC_INBOUND."
zuul [Mon, 9 Jan 2017 14:38:46 +0000 (08:38 -0600)]
Merge "chan_sip: Remember SDP negotiation on SIP_CODEC_INBOUND."

2 years agoMerge "res_pjsip: Fix known compact header issues"
Joshua Colp [Mon, 9 Jan 2017 13:23:17 +0000 (07:23 -0600)]
Merge "res_pjsip: Fix known compact header issues"

2 years agoMerge changes from topic 'ASTERISK-26672'
Joshua Colp [Mon, 9 Jan 2017 13:22:42 +0000 (07:22 -0600)]
Merge changes from topic 'ASTERISK-26672'

* changes:
  res_rtp_asterisk.c: Fix uninitialized memory crash.
  chan_rtp.c: Fix uninitialized memory crash.
  res_rtp_asterisk.c: Initialize ourip passed to ast_find_ourip().

2 years agopjproject_bundled: Fix compilation with MALLOC_DEBUG
George Joseph [Sun, 8 Jan 2017 16:29:01 +0000 (09:29 -0700)]
pjproject_bundled:  Fix compilation with MALLOC_DEBUG

When MALLOC_DEBUG was specified, make was failing.  Immediately
remaking would work.  The issues was in the ordering of the make
dependencies.

Change-Id: If6030b54fc693f3179f32bfd20c6b5d5f1b3f7cd

2 years agores_pjsip_endpoint_identifier_ip: Add support for SRV lookups.
Joshua Colp [Thu, 5 Jan 2017 12:11:43 +0000 (12:11 +0000)]
res_pjsip_endpoint_identifier_ip: Add support for SRV lookups.

This change implements SRV support for the IP based endpoint
identifier module. All possible addresses through SRV are looked
up and added as matches. If no SRV records are available a
fallback to normal host resolution is done. If an IP address
is provided then no SRV lookup occurs.

This is configured using the "srv_lookups" option on the
identify section and defaults to "yes".

ASTERISK-26693

Change-Id: I6b641e275bf96629320efa8b479737062aed82ac

2 years agoMerge "core/pbx: dialplan show - display filename/line#"
zuul [Thu, 5 Jan 2017 16:30:32 +0000 (10:30 -0600)]
Merge "core/pbx: dialplan show - display filename/line#"

2 years agoMerge "res_pjsip_session: Access SIPDOMAIN via Dialplan."
Joshua Colp [Thu, 5 Jan 2017 14:25:22 +0000 (08:25 -0600)]
Merge "res_pjsip_session: Access SIPDOMAIN via Dialplan."

2 years agoMerge "acl.c: Improve ast_ouraddrfor() diagnostic messages."
George Joseph [Thu, 5 Jan 2017 04:09:22 +0000 (22:09 -0600)]
Merge "acl.c: Improve ast_ouraddrfor() diagnostic messages."

2 years agoMerge "chan_pjsip: Use session for retrieving CHANNEL() information."
George Joseph [Wed, 4 Jan 2017 22:26:35 +0000 (16:26 -0600)]
Merge "chan_pjsip: Use session for retrieving CHANNEL() information."

2 years agoapp_queue: add new Service Level calculation
Sebastian Gutierrez [Sun, 6 Nov 2016 12:37:46 +0000 (09:37 -0300)]
app_queue: add new Service Level calculation

Adds a new formula for SL2 and documentation

ASTERISK-26559

Change-Id: I0970c620460507cd9d45b0d43600779c8915e770

2 years agocore/pbx: dialplan show - display filename/line#
Jonathan R. Rose [Mon, 19 Dec 2016 21:03:52 +0000 (15:03 -0600)]
core/pbx: dialplan show - display filename/line#

Adds the ability for extensions to be registered to include filename and
line number so that dialplan show output can show the filename and line
number of a config file responsible for generating a given extension.

This only affects config modules that are written to use the new extension
registering functions. In this patch, that only includes pbx_config, so
extensions registered in extensions.conf and any included extension will
be shown in this manner. Extensions registered in this manner will show
the filename and line number *instead* of the registrar.

ASTERISK-26658 #close
Reported by: Jonathan R. Rose

Change-Id: Ieccc6abccdff34ed5c7da3511fd24972b8f2dd30

2 years agores_pjsip_session: Access SIPDOMAIN via Dialplan.
Alexander Traud [Thu, 22 Dec 2016 15:13:46 +0000 (16:13 +0100)]
res_pjsip_session: Access SIPDOMAIN via Dialplan.

This feature was available in the SIP channel driver chan_sip. For example,
Asterisk is the outbound proxy and has to handle all SIP-URIs, even domains not
local to Asterisk. In that case, SIPDOMAIN is used in the Dialplan, to detect
and dial remote SIP-URIs. This change here sets the SIP destination domain of
an inbound call (SIPDOMAIN) in the SIP channel driver res_pjsip as well.

ASTERISK-26670 #close

Change-Id: I27c880dc404a3c1c6792e1ba3545475339577243

2 years agochan_sip: Remember SDP negotiation on SIP_CODEC_INBOUND.
Alexander Traud [Wed, 4 Jan 2017 11:50:11 +0000 (12:50 +0100)]
chan_sip: Remember SDP negotiation on SIP_CODEC_INBOUND.

After a SIP_CODEC_INBOUND in the dialplan, do not continue with cached formats
but remember the joint format. Cached formats contain default parameters,
often create an empty fmtp line. However, a joint format might have passed
format_get_joint(.) in a res_format_attr_* module (like Opus Codec) and
contain the resulting format parameters from a SDP negotiation.

ASTERISK-26691 #close

Change-Id: I35712d98a793d4c3efdd156cec57deab9014b1dc

2 years agopjproject_bundled: Compile pjsua with max log level = 2
George Joseph [Tue, 3 Jan 2017 21:14:09 +0000 (14:14 -0700)]
pjproject_bundled:  Compile pjsua with max log level = 2

A while back, we changed config_site.h to set PJ_LOG_MAX_LEVEL = 6.
This allowed us to control the log level better from inside Asterisk.
An unfortunate side effect of this was that the pjsua binary and
python bindings were also compiled with log level set to 6 so whenever
a testsuite test that uses pjsua runs, it spits out 6795 lines of
debug in an instant even before the test starts.  I believe this
overruns the Jenkins capture buffer and prevents the test from
properly terminating.  In turn, this results in the testsuite just
hanging until the job is killed.  It's more frequent on the higher
end agents because they can spit out the messages faster.

Unfortunately, the messages are all spit out before we have control
of the python pj.Lib instance where we can set logging levels so the
only alternative was to actually compile pjsua and _pjsua.so with an
overridden PJ_LOG_MAX_LEVEL.  Although defining a lower max level was
done in the Makefile, the define in config_site.h had to be wrapped
with "#ifndef" so the change would take effect.

Change-Id: I2af9e7d48dde1927279c586c9c725d868fe6f3ff

2 years agoMerge "bridge_native_rtp.c: Minor code cleanups."
Joshua Colp [Tue, 3 Jan 2017 14:39:27 +0000 (08:39 -0600)]
Merge "bridge_native_rtp.c: Minor code cleanups."

2 years agoMerge "bridge_native_rtp.c: Fix native rtp bridge data race."
Joshua Colp [Tue, 3 Jan 2017 14:39:07 +0000 (08:39 -0600)]
Merge "bridge_native_rtp.c: Fix native rtp bridge data race."

2 years agochan_pjsip: Use session for retrieving CHANNEL() information.
Joshua Colp [Thu, 22 Dec 2016 22:00:58 +0000 (22:00 +0000)]
chan_pjsip: Use session for retrieving CHANNEL() information.

The CHANNEL() dialplan function implementation for PJSIP allows
querying of PJSIP specific information. This used the channel
passed in to get the PJSIP session and associated information.
It is possible for this channel to be masqueraded and end
up as a different channel type by the time the information
request is actually acted upon.

This change retrieves the PJSIP session safely and accesses
data from it (including channel). This provides a guarantee
that the session and channel will not be altered when the
request is being acted upon.

ASTERISK-26673

Change-Id: I335e12b89e1820cafdd92b3e7526b8ba649eb7e6

2 years agores_pjsip: Fix known compact header issues
Joshua Elson [Sun, 1 Jan 2017 01:56:09 +0000 (18:56 -0700)]
res_pjsip: Fix known compact header issues

ASTERISK-26684 #close

Change-Id: Ifd7e401c45015119dd5e8421dbfe3afa6381744a

2 years agores_pjsip_refer: Handle compact Refer-To header.
George Joseph [Fri, 30 Dec 2016 15:10:09 +0000 (08:10 -0700)]
res_pjsip_refer:  Handle compact Refer-To header.

refer_incoming_refer_request needed to look for the "r" header as well
as the "Refer-To" header.

ASTERISK-26655 #close
patches:
refer_compact_fix.diff submitted by JoshE (license 6075)

Change-Id: I610410a99b02427ea5db887aeb454d5f12c2259f

2 years agobridge_native_rtp.c: Minor code cleanups.
Richard Mudgett [Fri, 23 Dec 2016 18:11:02 +0000 (12:11 -0600)]
bridge_native_rtp.c: Minor code cleanups.

In native_rtp_bridge_compatible_check()

* Made one variable declaration per line.

* Extracted if test assignment to make the test easier to see.

* Made long if tests easier to see the combinatorial logic.

* Added bridge id to a couple debug messages.

Change-Id: I65bc5732aa7c9a2537f062f106fbea711cf2daad

2 years agobridge_native_rtp.c: Fix native rtp bridge data race.
Richard Mudgett [Fri, 23 Dec 2016 18:10:40 +0000 (12:10 -0600)]
bridge_native_rtp.c: Fix native rtp bridge data race.

native_rtp_bridge_compatible() didn't lock the bridge channels before
checking the channels for native bridging ability.  As a result, one of
the channel's native format capabilities structure got replaced out from
under the native bridge check.  Use of a stale pointer to freed memory
causes bad things to happen.

MALLOC_DEBUG, DO_CRASH, and the
tests/channels/pjsip/transfers/blind_transfer/caller_direct_media
testsuite test caught this.

* Add missing channel locking in native_rtp_bridge_compatible().

Change-Id: If25fdb3ac8e85563c4857fb8216b3d9dc3d0fa53

2 years agores_rtp_asterisk.c: Fix uninitialized memory crash.
Richard Mudgett [Wed, 21 Dec 2016 22:28:00 +0000 (16:28 -0600)]
res_rtp_asterisk.c: Fix uninitialized memory crash.

ast_rtp_remote_address_set() could pass an uninitialized 'us' parameter to
ast_ouraddrfor().  If ast_ouraddrfor() returns an error then the 'us'
parameter may not get initialized.  Thus when the code tries to save the
'us' parameter to the local address we could try to copy a ridiculous
sized memory buffer and segfault.

* Made pass an initialized 'us' parameter to ast_ouraddrfor().

* Optimized out the 'us' struct variable.

ASTERISK-26672 #close

Change-Id: I4acea5dcdf0813da2c7d3e11c2d6067d160d17dc

2 years agoacl.c: Improve ast_ouraddrfor() diagnostic messages.
Richard Mudgett [Wed, 21 Dec 2016 22:25:00 +0000 (16:25 -0600)]
acl.c: Improve ast_ouraddrfor() diagnostic messages.

* Made not generate strings unless they will actually be used.

ASTERISK-26672

Change-Id: I155fbe7fdff5ce47dfe5326f3baf5446849702c3

2 years agochan_rtp.c: Fix uninitialized memory crash.
Richard Mudgett [Wed, 21 Dec 2016 23:54:42 +0000 (17:54 -0600)]
chan_rtp.c: Fix uninitialized memory crash.

unicast_rtp_request() could pass an uninitialized 'us' parameter to
ast_ouraddrfor().  If ast_ouraddrfor() returns an error then the 'us'
parameter may not get initialized.  Thus when the code tries to save the
'us' parameter to the local address we could try to copy a ridiculous
sized memory buffer and segfault.

* Made pass an initialized 'us' parameter to ast_ouraddrfor() and abort
the UnicastRTP channel request if it fails.

ASTERISK-26672

Change-Id: I1ef7a7c09f4da4f15dcb6de660d2bcac5f2a95c0

2 years agores_rtp_asterisk.c: Initialize ourip passed to ast_find_ourip().
Richard Mudgett [Wed, 21 Dec 2016 23:55:48 +0000 (17:55 -0600)]
res_rtp_asterisk.c: Initialize ourip passed to ast_find_ourip().

We access uninitialized memory when the 'ourip' parameter does not
have an initial guess to our IP address.

ASTERISK-26672

Change-Id: I35507ea1ad7455d2be188f6ccdd4add7bd150e15

2 years agoMerge "Fixes to various issues reported by pyflakes"
Joshua Colp [Thu, 22 Dec 2016 00:36:52 +0000 (18:36 -0600)]
Merge "Fixes to various issues reported by pyflakes"

2 years agores_rtp_asterisk.c: Fix off nominal memory leak.
Richard Mudgett [Wed, 7 Dec 2016 21:23:02 +0000 (15:23 -0600)]
res_rtp_asterisk.c: Fix off nominal memory leak.

Change-Id: I95b1088d11244a2edae6607c12fbf33b38658a75

2 years agoFixes to various issues reported by pyflakes
Tzafrir Cohen [Wed, 14 Dec 2016 08:21:25 +0000 (10:21 +0200)]
Fixes to various issues reported by pyflakes

Pyflake is a python (2) source checker. This patch fixes various
(mostly trivial) errors and warnings it reports.

Change-Id: Ia35c5ac61751b927814cf693994c632c412386ea

2 years agoMerge "pjproject_bundled: Make build single threaded"
Joshua Colp [Tue, 20 Dec 2016 11:31:04 +0000 (05:31 -0600)]
Merge "pjproject_bundled:  Make build single threaded"

2 years agoMerge "res_pjsip: Add/update ERROR msg if invalid URI."
Joshua Colp [Tue, 20 Dec 2016 11:29:56 +0000 (05:29 -0600)]
Merge "res_pjsip: Add/update ERROR msg if invalid URI."

2 years agoMerge "MESSAGE: Flush Message/ast_msg_queue channel alert pipe."
Joshua Colp [Tue, 20 Dec 2016 11:29:35 +0000 (05:29 -0600)]
Merge "MESSAGE: Flush Message/ast_msg_queue channel alert pipe."

2 years agoMerge "chan_dahdi.c: Fix bounds check regression."
Joshua Colp [Tue, 20 Dec 2016 01:48:31 +0000 (19:48 -0600)]
Merge "chan_dahdi.c: Fix bounds check regression."

2 years agoMerge "chan_sip: Reorder unload_module to deal with stuck TCP threads."
Joshua Colp [Mon, 19 Dec 2016 22:11:37 +0000 (16:11 -0600)]
Merge "chan_sip: Reorder unload_module to deal with stuck TCP threads."

2 years agoMerge "autosupport: Add 'pjproject show buildopts'"
Joshua Colp [Mon, 19 Dec 2016 21:22:47 +0000 (15:22 -0600)]
Merge "autosupport: Add 'pjproject show buildopts'"

2 years agoapp_queue: Ensure member is removed from pending when hanging up.
Martin Tomec [Fri, 9 Dec 2016 18:23:37 +0000 (19:23 +0100)]
app_queue: Ensure member is removed from pending when hanging up.

In some cases member is added to pending_members, and the channel
is hung up before any extension state change. So the member would
stay in pending_members forever. So when we call do_hang, we
should also remove member from pending.

ASTERISK-26621 #close

Change-Id: Iae476b5c06481db18ebe0fa594b3e80fdc9a7d54

2 years agopjproject_bundled: Make build single threaded
George Joseph [Sun, 18 Dec 2016 21:23:17 +0000 (14:23 -0700)]
pjproject_bundled:  Make build single threaded

There were just too many issues in various environments with
multi threaded building of pjproject.  It doesn't really speed
things up anyway since asterisk is already being compiled in
parallel.

Change-Id: Ie5648fb91bb89b4224b6bf43a0daa1af793c4ce1

2 years agochan_sip: Reorder unload_module to deal with stuck TCP threads.
Corey Farrell [Fri, 9 Dec 2016 02:00:02 +0000 (21:00 -0500)]
chan_sip: Reorder unload_module to deal with stuck TCP threads.

In some situations TCP threads may become frozen.  This creates the
possibility that Asterisk could segfault if they become unfrozen after
chan_sip has been dlclose'd.  This reorders the unload_module process to
allow abort if threads do not exit within 5 seconds.

High level order as follows:
1) Unregister from the core to stop new requests.
2) Signal threads to stop
3) Clear config based tables (but do not free the table itself).
4) Verify that threads have shutdown, cancel unload if not.
5) Clean all remaining resources.

ASTERISK-26586

Change-Id: Ie23692041d838fbd35ece61868f4c640960ff882

2 years agoconfigure: fix with-pjproject-bundled
David M. Lee [Fri, 16 Dec 2016 07:32:57 +0000 (01:32 -0600)]
configure: fix with-pjproject-bundled

The AC_ARG_WITH macro's shell variable is withval; not enableval. Purely
coincidentally, the option would work when --enable-dev-mode is given.

Also fixed a portability problem with bootstrap.sh, since -printf is not
a portable option for find.

Change-Id: I0f0e5b1a934b5af5737713834361e9c95b96b376

2 years agoautosupport: Add 'pjproject show buildopts'
Richard Mudgett [Thu, 15 Dec 2016 19:25:50 +0000 (13:25 -0600)]
autosupport: Add 'pjproject show buildopts'

Change-Id: I8aa55a7c3fb175235ddc7f85e9457d5102d06fa7

2 years agochan_dahdi.c: Fix bounds check regression.
Richard Mudgett [Wed, 14 Dec 2016 20:21:47 +0000 (14:21 -0600)]
chan_dahdi.c: Fix bounds check regression.

Caused by ASTERISK-25494

Change-Id: I1fc408c1a083745ff59da5c4113041bbfce54bcb

2 years agores_pjsip: Add/update ERROR msg if invalid URI.
Richard Mudgett [Tue, 13 Dec 2016 20:34:54 +0000 (14:34 -0600)]
res_pjsip: Add/update ERROR msg if invalid URI.

ASTERISK-24499

Change-Id: Ie305153e47e922233b2ff24715e0e326e5fa3a6c

2 years agoMESSAGE: Flush Message/ast_msg_queue channel alert pipe.
Richard Mudgett [Tue, 13 Dec 2016 00:38:42 +0000 (18:38 -0600)]
MESSAGE: Flush Message/ast_msg_queue channel alert pipe.

ASTERISK-25083

Change-Id: Id54baa57a8dbca84e29f28bcd2ffc0a5ac12d8b2

2 years agores_sorcery_memory_cache: Change an error to a debug message
George Joseph [Tue, 13 Dec 2016 20:06:34 +0000 (13:06 -0700)]
res_sorcery_memory_cache:  Change an error to a debug message

When a sorcery user calls ast_sorcery_delete on an object that
may have already expired from the cache, res_sorcery_memory_cache
spits out an ERROR.  Since this can happen frequently and validly when
an inbound registration expires after the cache entry expired, the
errors are unnecessary and misleading.  Changed to a debug/1.

Change-Id: Idf3a67038c16e3da814cf612ff4d6d18ad29ecd7

2 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

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

2 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."

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

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

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

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

2 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

2 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

2 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

2 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

2 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

2 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."

2 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
SIP.

ASTERISK-26433 #close
AST-2016-009

Change-Id: I78086fbc524ac733b8f7f78cb423c91075fd489b

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

2 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.

ASTERISK-26579

Change-Id: I01f53e5d9fa9f1925a7365f8d25071b5b3ac2dc3

2 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
intact.

ASTERISK-26644 #close

Change-Id: I326f12c9ecb52bf37ba03f0748749de4da01490a

2 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

2 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."

2 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."

2 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."

2 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
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

2 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

2 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.

ASTERISK-26629
Reported by Joshua Colp

Change-Id: Ib3c5f41e96833d0415cf000656ac368168add639

2 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 libasteriskpj.so.2 to libasteriskpj.so.  While I was
there, I fixed it for libasteriskssl as well.

Change-Id: I9e00873b1e9082d05b5549d974534b48a2142556

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

2 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."

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

2 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
updates.

ASTERISK-26527

Change-Id: If851c7d514bb530d9226e4941ba97dcf52000646

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

2 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."

2 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."

2 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."

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

2 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."

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

2 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
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

2 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

2 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

2 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
possibility.

Change-Id: Ied5dacacda06d343dea751ed5814a03364fe5a7d

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

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

2 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

2 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

2 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.

ASTERISK-26624
Reported by: Eduardo S. Libardi

Change-Id: Ia1eef10552ae616efb645d390f5ffe81260d7d4a

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

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

2 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

2 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

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

2 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
correctly.

Change-Id: I124d195bb117ca36fd7bf1150c630f3b474a9d9a

2 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."

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

2 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