Commit graph

6362 commits

Author SHA1 Message Date
George Joseph
df7277ac5d Merge "main: Update copyright notice with year 2018" 2018-04-02 10:14:15 -05:00
Jenkins2
c66fde8247 Merge "BuildSystem: With external editline, do not require libs for internal editline." 2018-04-02 08:36:01 -05:00
Jenkins2
0718964e32 Merge "core: Create main/options.c." 2018-04-02 08:31:08 -05:00
Kevin Harwell
48ef239a01 Merge "res_rtp_asterisk: Add support for raising additional RTCP messages." 2018-03-29 15:19:17 -05:00
Kevin Harwell
d8a2ced3ad Merge "main/indications: Use ast_cli_completion_add for all completions." 2018-03-29 15:06:45 -05:00
Jenkins2
7b744bac60 Merge "Add data buffer API to store packets." 2018-03-29 13:38:02 -05:00
Ben Ford
138e0eff4e Add data buffer API to store packets.
Adds a data buffer with a configurable size that can store different
kinds of packets (like RTP packets for retransmission). Given a number
it will store a data packet at that position relative to the others.
Given a number it will retrieve the given data packet if it is present.
This is purposely a storage of arbitrary things so it can be used not
just for RTP packets but also Asterisk frames in the future if needed.
The API does not internally use a lock, so it will be up to the user of
the API to properly protect the data buffer.

For more information, refer to the wiki page:
https://wiki.asterisk.org/wiki/display/AST/WebRTC+User+Experience+Improvements

Change-Id: Iff13c5d4795d52356959fe2a57360cd57dfade07
2018-03-28 14:25:21 -06:00
Joshua Colp
e14b0e960d res_rtp_asterisk: Add support for raising additional RTCP messages.
This change extends the existing AST_FRAME_RTCP frame type to be
able to contain additional RTCP message types, such as feedback
messages. The payload type is contained in the subclass which allows
knowing what is in the frame itself.

The RTCP feedback message type is now handled and REMB[1] messages
are raised with their containing information.

This also fixes a bug where all feedback messages were triggering
video updates instead of just FIR and FUR.

Finally RTCP frames are now passed up through the Asterisk core to
what is handling the channel, mapped appropriately in the case of
bridging, and written to an outgoing stream. Since RTCP frames are
on a per-stream basis this is only done on multistream capable
channels.

[1] https://tools.ietf.org/html/draft-alvestrand-rmcat-remb-03

ASTERISK-27758
ASTERISK-26366

Change-Id: I680da0ad8d5059d5e9655d896fb9d92e9da8491e
2018-03-27 08:39:00 -06:00
Florian Floimair
455cee99ae main: Update copyright notice with year 2018
Change-Id: I2d80bc5edf940fab914cba3d8a0fa0b5eb2a3148
2018-03-27 15:27:09 +02:00
Guido Falsi
48190c7f93 core: fix getopt(3) usage
Setting optind = 0 is forced to 1 in glibc implementation, but
causes option parsing to be flawed in other implementations, for
example on FreeBSD.

ASTERISK-27773 #close

Change-Id: Ia548e69f8302e9754dbbedb6bc451c0700c66f61
2018-03-26 06:50:54 -06:00
Corey Farrell
318bf45928 main/indications: Use ast_cli_completion_add for all completions.
Change-Id: I371be01f178fb542a9fbe8d97e7ae21aa4d82c36
2018-03-23 02:28:10 -04:00
Alexander Traud
d6fda173a4 BuildSystem: With external editline, do not require libs for internal editline.
ASTERISK-27761

Change-Id: Ib17a7415297a210cfcdbf149e4df9b6edadbfab6
2018-03-22 11:43:18 +01:00
Corey Farrell
a6d58c518a core: Create main/options.c.
This creates a separate source to 'own' symbols related to options.h and
paths.h.  This significantly reduces the number of exports created by
main/asterisk.o.  This change is required to eventually be able to
link unmodified Asterisk sources to utilities and/or stand-alone tests.

ASTERISK~26245

Change-Id: I5cf184f4757f9363b80c9e678bdc35c477122380
2018-03-22 00:33:12 -04:00
Jenkins2
fa892d8dfd Merge "core: Stop using AST_INLINE_API for allocator functions." 2018-03-21 10:46:30 -05:00
Joshua Colp
f03b984724 Merge "core: Remove additional symbols." 2018-03-20 11:44:06 -05:00
Jenkins2
60a06fbd1d Merge "core: Remove dead symbols from asterisk.exports.in." 2018-03-20 11:40:39 -05:00
Jenkins2
f863f1f91b Merge "channel.c: Allow generic plc then channel formats are equal" 2018-03-20 11:16:52 -05:00
Jenkins2
fcad222d7f Merge "BuildSystem: Instead of $PJPROJECT_LIBS with s, use $PJPROJECT_LIB everywhere." 2018-03-20 10:24:11 -05:00
Jenkins2
b68dae189d Merge "main/sounds: Use ast_cli_completion_add." 2018-03-20 10:09:26 -05:00
Joshua Colp
dc2ce3ce32 Merge "named_acl: Use ast_cli_completion_add." 2018-03-20 09:51:41 -05:00
Joshua Colp
1a2f12e288 Merge "manager: Use ast_cli_completion_add for completion generators." 2018-03-20 09:36:56 -05:00
Joshua Colp
e3a5874c12 Merge "main/test: Use ast_cli_completion_add." 2018-03-20 09:18:57 -05:00
Jenkins2
c1344d3f77 Merge "core: Minor cleanup of ast_el_read_char." 2018-03-20 08:47:15 -05:00
Joshua Colp
06424ebde1 Merge "aco: Use ast_cli_completion_add for 'config show help'." 2018-03-20 08:31:49 -05:00
Jenkins2
716e2d46e7 Merge "main/config: Use ast_cli_completion_add for reload completion." 2018-03-20 08:20:54 -05:00
Jenkins2
bf9631ea0b Merge "main/translate: Use ast_cli_completion_add." 2018-03-20 07:58:00 -05:00
Joshua Colp
650f561bbb Merge "main/taskprocessor: Use ast_cli_completion_add." 2018-03-20 07:38:03 -05:00
Jenkins2
5f5bb31f74 Merge "main/bridge: Use ast_cli_completion_add." 2018-03-20 07:29:24 -05:00
Jenkins2
ffc20301fa Merge "stringfields: Remove MALLOC_DEBUG fields from struct ast_string_field_mgr." 2018-03-20 06:58:56 -05:00
Corey Farrell
040bb21771 core: Remove additional symbols.
Remove symbols that are depreacated and replaced:
* ast_channel_datastore_alloc
* ast_channel_datastore_free
* ast_channel_cmpwhentohangup
* ast_channel_setwhentohangup
* config_text_file_save
* devstate2str
* ast_device_state_changed
* ast_device_state_changed_literal
* ast_verbose_get_by_module

Remove unused symbols:
* channelreloadreason2txt (last used in Asterisk 12).

Remove unused ast_options flags:
* AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN / ast_opt_end_cdr_before_h_exten
* AST_OPT_FLAG_VERBOSE_MODULE / ast_opt_verb_module
* AST_OPT_FLAG_INITIATED_SECONDS

Change-Id: I841255995d195f8efc1ed47af9c7a2f131c08645
2018-03-19 18:00:20 -04:00
Corey Farrell
de77cf8698 core: Remove dead symbols from asterisk.exports.in.
* dahdi_chan_name
* dahdi_chan_name_len
* dahdi_chan_mode
* __manager_event
* dialed_interface_info

Added comment about __progname and environ being needed for FreeBSD to
prevent accidental removal in the future.

Change-Id: I3ae026bc541cd9cb572be2ffa95fc359547642b5
2018-03-19 17:59:59 -04:00
Corey Farrell
201762f161 named_acl: Use ast_cli_completion_add.
Change-Id: I317a82de976bbdbfe4352c243e32a7bb8f66c377
2018-03-19 17:49:00 -04:00
Corey Farrell
645203a422 main/sounds: Use ast_cli_completion_add.
Change-Id: I140e1137906bbfcdb61c0c6304159be459ad873e
2018-03-19 17:45:09 -04:00
George Joseph
5d097f8236 channel.c: Allow generic plc then channel formats are equal
If the two formats on a channel are equal, we don't transcode and since
the generic plc needs slin to work, it doesn't get invoked.

* A new configuration option "genericplc_on_equal_codecs" was added
  to the "plc" section of codecs.conf to allow generic packet loss
  concealment even if no transcoding was originally needed.
  Transcoding via SLIN is forced in this case.

ASTERISK-27743

Change-Id: I0577026a179dea34232e63123254b4e0508378f4
2018-03-19 15:36:09 -06:00
Corey Farrell
8d01ec572d manager: Use ast_cli_completion_add for completion generators.
Change-Id: I658141c6ec490a3e866b02d2afea757928ceaabf
2018-03-19 16:26:56 -04:00
Corey Farrell
2c1ad2f510 main/test: Use ast_cli_completion_add.
Change-Id: I5133ff2ba4e030f9733fb3d050c863d72a22ae6b
2018-03-19 15:41:45 -04:00
Jenkins2
5843a19797 Merge "loader: Convert reload_classes to built-in modules." 2018-03-19 12:53:12 -05:00
Jenkins2
19196a98d0 Merge "main/cdr: Use ast_cli_completion_add for CDR channel completion." 2018-03-19 06:17:42 -05:00
Corey Farrell
8c25a72d57 main/bridge: Use ast_cli_completion_add.
Change-Id: I3775a696d6a57139fdf09651ecb786bcf1774509
2018-03-17 19:48:54 -04:00
Corey Farrell
5b40441197 core: Minor cleanup of ast_el_read_char.
* Define CHAR_T_LIBEDIT and CHAR_TO_LIBEDIT based on
  HAVE_LIBEDIT_IS_UNICODE.  This avoids needing to repeatedly use
  conditional blocks, eliminates having multiple function prototypes.
* Remove parenthesis from return values.
* Add missing code block brackets {}.
* Reduce use of 'else' conditional statements where possible.

Change-Id: I4315328ebea2f62641faf6881de2ac20a9f9d08e
2018-03-17 18:32:40 -04:00
Corey Farrell
1136a22a1e main/translate: Use ast_cli_completion_add.
Change-Id: I0e2402660e54d91f74ab0804c62a5b1925577413
2018-03-17 03:25:17 -04:00
Corey Farrell
91ac95993e main/taskprocessor: Use ast_cli_completion_add.
Change-Id: Ie5f812a988ed811fd11967151932de62bc131b48
2018-03-17 03:00:45 -04:00
Corey Farrell
3ad56aa929 main/config: Use ast_cli_completion_add for reload completion.
Change-Id: Ia3fa4c03f2285a1ec8814bbe7f4624ead9111ad1
2018-03-17 01:55:53 -04:00
Corey Farrell
9e335f22e7 aco: Use ast_cli_completion_add for 'config show help'.
In addition this removes:
* RAII_VAR usage
* Duplicate check of pos
* Unneeded arguments.

Change-Id: I2da8eac2670d1d8d6474c04037129804f55ebf39
2018-03-17 01:55:16 -04:00
Corey Farrell
4d1c9d8711 core: Stop using AST_INLINE_API for allocator functions.
This replaces AST_INLINE_API allocators in utils.h with real functions
implemented in astmm.c.  Associated macro's are also moved from utils.h
to astmm.h.

Remove menuselect conflicts between MALLOC_DEBUG and DEBUG_CHAOS as they
can now be combined.

This has multiple benefits:
* Simplifies asterisk/utils.h by removing inline functions and use of
  the logger.
* Removal of these inline functions decreases size of Asterisk and
  module binaries by 1% or more.
* Puts memory management functions together with and without
  MALLOC_DEBUG enabled, simplifying management of the code.
* Enables DEBUG_CHAOS for ASTMM_REDIRECT and bundled pjproject.

Change-Id: If9df4377f74bdbb627461b27a473123e05525887
2018-03-17 01:06:33 -04:00
Joshua Colp
d5bfba60d2 Merge "astobj2_container: Use ast_cli_completion_add for container names." 2018-03-16 19:09:48 -05:00
Jenkins2
6df575541b Merge "main/ccss: Use ast_cli_completion_add for core id." 2018-03-16 19:07:58 -05:00
Jenkins2
6c4719fc2a Merge "main/channel: Use ast_cli_completion_add for channeltypes." 2018-03-16 10:51:38 -05:00
Corey Farrell
ebe957c5e9 main/cdr: Use ast_cli_completion_add for CDR channel completion.
Change-Id: Ie81830647a23aad61c1162583b6d50adbe6e7822
2018-03-15 10:32:37 -04:00
Corey Farrell
89ba4d4e3d main/ccss: Use ast_cli_completion_add for core id.
Change-Id: I44b25d6d24c7d9bc1bb38a50774b38883162f98f
2018-03-15 09:19:58 -04:00
Corey Farrell
aa0d95c730 astobj2_container: Use ast_cli_completion_add for container names.
Change-Id: I4f0fc09e820eb8d8da2354a177dbcf503c56ddd1
2018-03-15 08:29:50 -04:00
Corey Farrell
b929a7fb8d main/channel: Use ast_cli_completion_add for channeltypes.
Change-Id: Ia845fae6a84801cc7d9996767b99efb2753cbb48
2018-03-15 08:11:23 -04:00
Corey Farrell
b45bb476bb cli: Enable ast_cli_completion_add on public completion generators.
* ast_cli_complete
* ast_complete_channels
* ast_complete_applications

These generators will now use ast_cli_completion_add if state == -1.

Change-Id: I7ff311f0873099be0e43a3dc5415c0cd06d15756
2018-03-15 07:25:28 -04:00
Jenkins2
1a9ed413a1 Merge "core: Remove incorrect usage of attribute_malloc." 2018-03-14 20:56:34 -05:00
Jenkins2
15bf51af73 Merge "core: Remove non-critical cleanup from startup aborts." 2018-03-14 07:00:57 -05:00
Corey Farrell
572a508ef2 loader: Convert reload_classes to built-in modules.
* acl (named_acl.c)
* cdr
* cel
* ccss
* dnsmgr
* dsp
* enum
* extconfig (config.c)
* features
* http
* indications
* logger
* manager
* plc
* sounds
* udptl

These modules are now loaded at appropriate time by the module loader.
Unlike loadable modules these use AST_MODULE_LOAD_FAILURE on error so
the module loader will abort startup on failure of these modules.

Some of these modules are still initialized or shutdown from outside the
module loader.  logger.c is initialized very early and shutdown very
late, manager.c is initialized by the module loader but is shutdown by
the Asterisk core (too much uses it without holding references).

Change-Id: I371a9a45064f20026c492623ea8062d02a1ab97f
2018-03-14 05:20:12 -04:00
Corey Farrell
9e488dd482 core: Remove incorrect usage of attribute_malloc.
GCC documentation states that when __attribute__((malloc)) is used it
should not return storage which contains any valid pointers.  It
specifically mentions that realloc functions should not have the malloc
attribute, but this also means that complex initializers which could
contain initialized pointers should not use this attribute.

Change-Id: If507f33ffb3ca3b83b702196eb0e8215d27fc7d2
2018-03-13 17:39:48 -04:00
Corey Farrell
ea9768ff07 stringfields: Remove MALLOC_DEBUG fields from struct ast_string_field_mgr.
This causes MALLOC_DEBUG reporting to be slightly different, calls which
cause additional memory pools to be allocated now report the callers
location rather than the location which originally allocated the
string field structure.  This reduces storage needed by string fields
and allows MALLOC_DEBUG to identify the source of additional allocations
rather than obscuring it by reporting the original allocation caller.

Change-Id: Idd18e6639a87ab862079b580c114d90361412289
2018-03-13 16:24:06 -04:00
Jenkins2
4b7872c9db Merge "core: Remove ABI effects of MALLOC_DEBUG." 2018-03-13 13:54:19 -05:00
Corey Farrell
fee929c8ac core: Remove non-critical cleanup from startup aborts.
When built-in components of Asterisk fail to start they cause the
Asterisk startup to abort.  In these cases only the most critical
cleanup should be performed - closing databases and terminating
proceses.  These cleanups are registered using ast_register_atexit, all
other cleanups should not be run during startup abort.

The main reason for this change is that these cleanup procedures are
untestable from the partially initialized states, if they fail it could
prevent us from ever running the critical cleanup with ast_run_atexits.

Create separate initialization for dns_core.c to be run unconditionally
during startup instead of being initialized by the first dns resolver to
be registered. This ensures that 'sched' is initialized before it can be
potentially used.

Replace ast_register_atexit with ast_register_cleanup in media_cache.c.
There is no reason for this cleanup to happen unconditionally.

Change-Id: Iecc2df98008b21509925ff16740bd5fa29527db3
2018-03-13 13:46:08 -04:00
Jenkins2
1485719531 Merge "Replace direct checks of option_debug with DEBUG_ATLEAST macro." 2018-03-12 10:44:46 -05:00
Alexander Traud
fc64a0e2b3 BuildSystem: Instead of $PJPROJECT_LIBS with s, use $PJPROJECT_LIB everywhere.
In the script ./configure,
xyz_LIB  is set by AST_PKG_CONFIG_CHECK and
xyz_LIBS is set by PKG_CHECK_MODULES within
AST_PKG_CONFIG_CHECK. Both are the same. In Asterisk normally the former and
only three times the latter was used. Let us use xyz_LIB without s, for
consistency with AST_EXT_LIB_CHECK. That eases understanding because now readers
do not have to know that xyz_LIB equals xyz_LIBS.

Change-Id: I7359860a5d730cdc784c2c48e501a082196434d3
2018-03-08 12:28:37 +01:00
Corey Farrell
c8a521b6c8 Replace direct checks of option_debug with DEBUG_ATLEAST macro.
Checking option_debug directly is incorrect as it ignores file/module
specific debug settings.  This system-wide change replaces nearly all
direct checks for option_debug with the DEBUG_ATLEAST macro.

Change-Id: Ic342d4799a945dbc40ac085ac142681094a4ebf0
2018-03-07 16:03:01 -06:00
Alexander Traud
58f44f225a utils: In Solaris, avoid a warning about an unused variable.
When HAVE_GETHOSTBYNAME_R_5 was set by the script ./configure, GCC 7.3.0 found
an unused variable. Actually, the variable was used (set to a dummy value) but
the compiler optimization might have removed that. Instead, this change ensures
that the variable 'res' is only used when it is really required.

Change-Id: Ic3ea23ccf84ac4bc2d501b514985b989030abab5
2018-03-07 16:32:05 +01:00
Jenkins2
91a8c7a281 Merge "BuildSystem: Cast any intptr_t explicitly to its proposed type." 2018-03-06 13:17:54 -06:00
Jenkins2
e21f168477 Merge "BuildSystem: Detect whether uselocale(.) is available." 2018-03-05 11:49:11 -06:00
Jenkins2
3afc2c52af Merge "core: Fix handling of maximum length lines in config files." 2018-03-05 08:32:35 -06:00
Alexander Traud
5d19762b5f BuildSystem: Cast any intptr_t explicitly to its proposed type.
ASTERISK-27713

Change-Id: I90c769e3c7f8c26de8a3af11335862cec15a1b22
2018-03-03 15:30:47 +01:00
Alexander Traud
9749524520 BuildSystem: Detect whether uselocale(.) is available.
ASTERISK-27712
Reported by: Joerg Sonnenberger, D'Arcy Cain

Change-Id: Idf1c9d43617a3e13028b95b313415903d80ef807
2018-03-03 13:56:03 +01:00
Richard Mudgett
c711e4076a core: Remove ABI effects of MALLOC_DEBUG.
This allows asterisk to be compiled with MALLOC_DEBUG to load modules
built without MALLOC_DEBUG.  Now pre-compiled third-party modules will
still work regardless of MALLOC_DEBUG being enabled or not.

Change-Id: Ic07ad80b2c2df894db984cf27b16a69383ce0e10
2018-03-01 13:13:55 -06:00
Richard Mudgett
1a36a452bd pjproject: Add cache_pools debugging option.
The pool cache gets in the way of finding use after free errors of memory
pool contents.  Tools like valgrind and MALLOC_DEBUG don't know when a
pool is released because it gets put into the cache instead of being
freed.

* Added the "cache_pools" option to pjproject.conf.  Disabling the option
helps track down pool content mismanagement when using valgrind or
MALLOC_DEBUG.  The cache gets in the way of determining if the pool
contents are used after free and who freed it.

To disable the pool caching simply disable the cache_pools option in
pjproject.conf and restart Asterisk.

Sample pjproject.conf setting:
[startup]
cache_pools=no

* Made current users of the caching pool factory initialization and
destruction calls call common routines to create and destroy cached pools.

ASTERISK-27704

Change-Id: I64d5befbaeed2532f93aa027a51eb52347d2b828
2018-02-28 11:41:30 -06:00
Corey Farrell
a7927471ad core: Fix handling of maximum length lines in config files.
When a line is the maximum length "\n" is found at sizeof(buf) - 2 since
the last character is actually the null terminator.  In addition if a
line was exactly 8190 plus a multiple of 8192 characters long the config
parser would skip the following line.

Additionally fix comment in voicemail.conf sample config.  It previously
stated that emailbody can only contain up to 512 characters which is
always wrong.  The buffer is normally 8192 characters unless LOW_MEMORY
is enabled then it is 512 characters.  The updated comment states that
the line can be up to 8190 or 510 characters since the line feed and
NULL terminator each use a character.

ASTERISK-26688 #close

Change-Id: I80864a0d40d2e2d8cd79d72af52a8f0a3a99c015
2018-02-23 12:12:04 -05:00
Richard Mudgett
f083edc43c manager.c: Fix lseek() parameter order.
ASTERISK-27659

Change-Id: I04a2705d2cb7df250769967bc59e2b397a49b797
2018-02-21 12:56:41 -06:00
Joshua Colp
e70c4ec84d AST-2018-001: rtp / channel: Don't allow an unnegotiated format to be passed up.
When an RTP packet is received by an RTP engine it has to map the
payload into the Asterisk format. The code was incorrectly checking
our own static list for ALL payloads if it couldn't find a negotiated one.
This included dynamic payloads. If the payload mapped to a format
of a different type (for example receiving a video packet on an audio
RTP instance) then the core stream code could cause a crash if a legacy
channel driver was in use as no stream would be present.

To provide further protection the core stream code will no longer assume
that a video or audio frame will always have a stream for legacy channel
drivers. If no stream is present the frame is dropped.

ASTERISK-27488

Change-Id: I022556f524ad8379ee73f14037040af17ea3316a
2018-02-21 08:27:51 -06:00
Richard Mudgett
e2f98fbd63 channel.c: Fix typo.
Change-Id: I4eeedf89085697e81c354eb92d546686c67b0b5b
2018-02-20 13:30:23 -06:00
Jenkins2
3c5784315d Merge "core: Rename sounds_index.c to sounds.c." 2018-02-20 07:05:55 -06:00
Jenkins2
fd353237f0 Merge "config: Fix locking for extconfig reload." 2018-02-20 06:14:08 -06:00
Jenkins2
ff4351952b Merge "optional_api: Refactor to use vector's and standard allocators." 2018-02-19 20:40:20 -06:00
Jenkins2
fbe2f1fe01 Merge "rtp_engine: Load format name / mime type in uppercase again." 2018-02-19 20:00:24 -06:00
Jenkins2
15886d5833 Merge "manager: Add AMI event Load/Unload" 2018-02-19 06:43:27 -06:00
Corey Farrell
97c21e9cb3 core: Rename sounds_index.c to sounds.c.
This will make the source filename match the 'module reload sounds'
command.  This will allow conversion to a built-in module in Asterisk 16
without needing to redefine AST_MODULE.

Change-Id: Ifb8e489575b27eb33d8c0b6a531f266670557f6e
2018-02-19 04:21:23 -06:00
Corey Farrell
e03f0f9572 config: Fix locking for extconfig reload.
Expand locking to include full reload process for extconfig to ensure
nothing can read the config mappings between clearing and reloading.

Change-Id: I378316bad04f1b599ea82d0fef62b8978a644b92
2018-02-19 03:09:02 -06:00
Alexander Traud
a70c92121d rtp_engine: Load format name / mime type in uppercase again.
This reverts a previous change partly.

ASTERISK-27689

Change-Id: Ia3d2f282db6995be8c1c253b5d52f6038761e8af
2018-02-17 15:49:15 +01:00
Sean Bright
af2dd3a678 bridge_roles: Use a non-locking linked list where appropriate
Also explicitly initialize with the AST_LIST_HEAD_NOLOCK_INIT macro for
clarity.

Change-Id: I4bc39ec33bc3ff77e1a971a01ace87deb965be3f
2018-02-15 14:31:32 -06:00
Jenkins2
d6147aa6a3 Merge "main/asterisk.c: Remove silly usage of RAII_VAR." 2018-02-14 12:55:18 -06:00
Jenkins2
41a05aacc9 Merge "core: Remove embedded editline." 2018-02-13 08:22:28 -06:00
Joshua Colp
d494cc1c88 Merge "json: Add conditionals to avoid locking if Jansson is thread safe." 2018-02-13 07:30:35 -06:00
Corey Farrell
9e45d3f893 main/asterisk.c: Remove silly usage of RAII_VAR.
Change-Id: I7e2996397fbd3c3a6a69dd805c38448ddfc34ae9
2018-02-12 22:15:34 -06:00
Corey Farrell
02ee296f81 optional_api: Refactor to use vector's and standard allocators.
* Replace ad-hoc array management with macro's from vector.h.
* Remove redundent logger messages.
* Use normal Asterisk allocators instead of directly using libc
  allocators.
* Free memory when an API has no implementation or users.

Change-Id: Ic6ecb31798d4a78e7df39ece86a68b60eac05bf5
2018-02-12 22:53:35 -05:00
Jenkins2
0461286123 Merge "cdr.c: Fix runtime leak of CDR records." 2018-02-12 16:03:46 -06:00
Sungtae Kim
cb4cfb8c43 manager: Add AMI event Load/Unload
Add an AMI events Load and Unload for notify when the
module has been loaded and unloaded.

ASTERISK-27661

Change-Id: Ib916c41eddd63651952998f2f49c57c42ef87a64
2018-02-12 21:34:09 +01:00
Corey Farrell
04490fb1d8 json: Add conditionals to avoid locking if Jansson is thread safe.
Jansson is thread safe for all read-only functions and reference
counting starting v2.11.  This allows simplification of our code and
removal of locking around reference counting and dumping.

Change-Id: Id985cb3ffa6681f9ac765642e20fcd187bd4aeee
2018-02-12 13:27:08 -05:00
Corey Farrell
9fddc8b4dc core: Remove embedded editline.
This removes the embedded copy of editline from the Asterisk source
tree, making a system copy of libedit mandatory in Asterisk 16+.

ASTERISK-27634 #close

Change-Id: Iedb64ad92acb78419f3caefedaa2bb7cd2a1a33f
2018-02-12 04:44:26 -05:00
Alexander Traud
32e610d9e6 backtrace: Avoid potential spurious output.
clang 4.0 found this via -Wlogical-not-parentheses.

ASTERISK-27642

Change-Id: I9ec3e144d425a976c02811bd23cd0c533d2eca4e
2018-02-10 14:55:42 +01:00
Richard Mudgett
b2fcb30d38 cdr.c: Fix runtime leak of CDR records.
Need to remove all CDR's listed by a CDR object from the active_cdrs_all
container including the root/master record.

ASTERISK-27656

Change-Id: I48b4970663fea98baa262593d2204ef304aaf80e
2018-02-09 14:26:46 -06:00
Jenkins2
2d90b1efd9 Merge "manager.c: Fixed "(null):" header in AMI AsyncAGIEnd event" 2018-02-05 12:23:19 -06:00
Jenkins2
5c524e3287 Merge "manager_channels.c: Reordered ast_manager_build_channel_state_string_prefix()" 2018-02-03 10:26:55 -06:00
Sungtae Kim
7e32adf044 manager.c: Fixed "(null):" header in AMI AsyncAGIEnd event
* Changed to create ami_event string only when the given blob is not
json_null().
* Fixed bad expression.

ASTERISK-27621

Change-Id: Ice58c16361f9d9e8648261c9ed5d6c8245fb0d8f
2018-02-01 17:24:14 -06:00
Richard Mudgett
3419a048b9 manager.c: Fix potential memory leak and corruption.
ast_str_append_event_header() could potentially leak and corrupt memory if
the ast_str needed to expand to add the AMI event header.

* Fixed to return error if the ast_str_append() failed.

Change-Id: I92f36b855540743b208d76e274152ee2d758176d
2018-02-01 13:51:27 -06:00
Richard Mudgett
bcfe172f8d manager_channels.c: Reordered ast_manager_build_channel_state_string_prefix()
* Made not allocate memory if the channel snapshot is an internal channel.

* Free memory earlier when no longer needed.

Change-Id: Ia06e0c065f1bd095781aa3f4a626d58fa4d28b38
2018-02-01 12:28:32 -06:00
Richard Mudgett
b9024197ab app_confbridge: Update dsp_silence_threshold and dsp_talking_threshold docs.
The dsp_talking_threshold does not represent time in milliseconds.  It
represents the average magnitude per sample in the audio packets.  This is
what the DSP uses to determine if a packet is silence or talking/noise.

Change-Id: If6f939c100eb92a5ac6c21236559018eeaf58443
2018-01-31 13:13:27 -06:00
Jenkins2
093484d137 Merge "loader: Use ast_cli_completion_add for 'module load' completion." 2018-01-31 07:48:21 -06:00
Jenkins2
8f6978d7b8 Merge "pbx_variables.c: Misc fixes in variable substitution." 2018-01-31 06:52:24 -06:00
Jenkins2
da4ddb1faa Merge "Build System: Require __sync or __atomic functions." 2018-01-30 06:56:08 -06:00
Jenkins2
21bcd85bba Merge "core: Fix unused variable error in handle_show_sysinfo." 2018-01-29 11:45:27 -06:00
Jenkins2
1e44d50893 Merge "core: Tweak startup order." 2018-01-29 10:49:58 -06:00
Jenkins2
7c77365549 Merge "editline: Avoid shifting a negative signed value." 2018-01-29 10:44:44 -06:00
Corey Farrell
84a6365164 loader: Use ast_cli_completion_add for 'module load' completion.
This addresses all performance issues with 'module load' completion.  In
addition to using ast_cli_completion_add we stop using libedit's
filename_completion_function, instead using ast_file_read_dir.  This
ensures all results are produced from a single call to opendir.

Change-Id: I8bf51ffaa7ef1606f3bd1b5bb13f1905d72c6134
2018-01-27 15:18:45 -05:00
Alexander Traud
d9e42f27b9 core: Fix unused variable error in handle_show_sysinfo.
The previous fix broke the case
HAVE_SYSINFO = no
HAVE_SYSCTL = yes
HAVE_SWAPCTL = no
which occurs on FreeBSD 11.1 for example.

ASTERISK-26563

Change-Id: If77c39bc75f0b83a6c8a24ecb2fa69be8846160a
2018-01-27 16:44:21 +01:00
Alexander Traud
3c26eec043 editline: Avoid shifting a negative signed value.
clang 4.0 warned about this.

ASTERISK-27630

Change-Id: Ie2725048c661c1792d8b1d498575144350b6e9ba
2018-01-27 15:54:24 +01:00
Corey Farrell
39fcecad59 core: Tweak startup order.
Move initialization of units which do not require configuration to occur
before preload modules.  This leaves only units which load config between
module preload and regular load stages.

Change-Id: I1d15384acad16a22c3498124421af474fa517478
2018-01-25 20:23:31 -05:00
Corey Farrell
23381d2c5e Build System: Require __sync or __atomic functions.
This change causes the configure script to throw an error if neither
__sync nor __atomic builtin functions are available.

ASTERISK-27619

Change-Id: Ie01a281e0f5c41dfeeb5f250c1ccea8752f56ef9
2018-01-25 10:38:45 -05:00
Corey Farrell
a164b7ccfb loader: Correct overly strict startup checks.
The code which handled loading modules had too many situations which
would result in halting Asterisk startup.  Treat most errors as declines
instead of failures.  The exception is when the module load function
returns AST_MODULE_LOAD_FAILURE or an invalid code.

Clear the missingdeps vector when appropriate to ensure the next loop
starts clean.

ASTERISK-27620

Change-Id: I45547d9641fd45bd86d80250224417625631ad84
2018-01-25 00:04:51 -05:00
Jenkins2
d4e9f7c940 Merge "loader: Add support for built-in modules." 2018-01-22 16:35:09 -06:00
Jenkins2
cec16d8e4f Merge "loader: Rework load_resource_list." 2018-01-22 16:31:29 -06:00
Richard Mudgett
2f78dc2bfa pbx_variables.c: Misc fixes in variable substitution.
* Copy more than one character at a time when there is nothing to
substitute.

* Fix off by one error if a '}' or ']' is missing.

* Eliminated the requirement that the "used" parameter had to point to a
variable.  The current callers were always declaring a variable to meet
the requirement and discarding the value put into that variable.  Now it
can be NULL.

* In ast_str_substitute_variables_full() fixed using the bogus channel to
evaluate a function.  We were not using the bogus channel we just created
to help evaluate a subexpression.

Change-Id: Ia83d99f4f16abe47f329eb39b6ff2013ae7c9854
2018-01-22 12:38:13 -06:00
Joshua Colp
908e39f186 Merge "loader: Remove global symbol only startup phase." 2018-01-22 10:33:18 -06:00
Jenkins2
2c27205e4e Merge "loader: Process module dependencies." 2018-01-22 10:16:29 -06:00
Jenkins2
fd32ca51e8 Merge "pbx: Reduce verbosity while loading extensions" 2018-01-22 09:39:22 -06:00
krells
77f2814d01 pbx: Reduce verbosity while loading extensions
Each time the dial plan is reloaded, a lot of logs like these are generated:
"Added extension 'XXXXX' priority 1 to YYYYYYYYYYY"
This patch changes the log level for those logs.

ASTERISK-27084

Change-Id: I5662902161c50890997ddc56835d4cafb456c529
2018-01-18 20:36:14 -06:00
Corey Farrell
25cb1ab05b loader: Add support for built-in modules.
* Add SRC_EMBEDDED variable to main/Makefile.  Built-in module sources
  must be listed in this variable to ensure they get the correct CFLAGS.

Change-Id: I920852bc17513a9c2627061a4ad40511e3a20499
2018-01-17 19:25:00 -05:00
Corey Farrell
e6142a1282 loader: Rework load_resource_list.
Use a single loop in a loop to scan the resource list attempting to
dlopen each module.  The inner loop is repeated until it doesn't do any
work, then it is run one more time to allow printing of error messages.

Change-Id: I60c15cd57ff9680b62e2a94c7519401fa4a38e45
2018-01-17 19:19:14 -05:00
Corey Farrell
a80cbb046e loader: Remove global symbol only startup phase.
Dependency loader is now in place so we no longer need a separate loader
phase for global symbols only.  This simplifies the loader and allows us
to minimize calls to dlopen.

Change-Id: I33e3174d67f3b4552d3d536326dcaf0ebabb097d
2018-01-17 17:57:18 -05:00
Corey Farrell
3b73ed28c5 loader: Process module dependencies.
* Add string vectors for requires, optional_apis and enhances.
* Add reffed_deps module vector for holding references to dependencies.
* Initialize string vectors after final dlopen of each module.
* Free string vectors and clear references from reffed_deps in
  module_destroy.
* Create functions necessary to process module dependencies and enforce
  load order.

Module dependencies result in automatic references being managed by the
module loader.  This enforces unload order.

Change-Id: I9be08d1dd331aceadc1dcba00b804d71360b2fbb
2018-01-17 17:56:59 -05:00
Corey Farrell
4fd303b630 loader: Miscellaneous fixes.
* Remove comment about lazy load.
* Improve message about module already being loaded and running.
* Handle allocation error in add_to_load_order.
* Dead code elimination from modules_shutdown.

Change-Id: I22261599c46d0f416e568910ec9502f45143197f
2018-01-17 11:02:43 -06:00
Richard Mudgett
7ed7d525fb taskprocessor.c: Increase the number of tps_singletons container buckets.
Since v12 the number of taskprocessors in the system has increased a lot.
Small systems can easily have over a hundred and larger systems can have
thousands.

Most uses of the tps_singletons container deal with creating and
destroying the taskprocessors.  However, the pjsip distributor looks up
taskprocessors/serializers by name frequently.  It needs to find the
serializer for incoming SIP responses to distribute them to the
appropriate serializer.

Change-Id: Ice0603606614ba49f7c0c316c524735c064e7e43
2018-01-16 12:42:06 -06:00
Corey Farrell
35ae99c712 vector: Additional string vector definitions.
ast_vector_string_split:
This function will add items to an ast_vector_string by splitting values
of a string buffer.  Items are appended to the vector in the order they
are found.

ast_vector_const_string:
A vector of 'const char *'.

Change-Id: I1bf02a1efeb2baeea11c59c557d39dd1197494d7
2018-01-15 13:25:45 -05:00
Jenkins2
8a6febd980 Merge "stasis_message_router: Remove silly usage of RAII_VAR." 2018-01-11 08:46:34 -06:00
Jenkins2
f94c56d388 Merge "stasis_endpoints: Remove silly usage of RAII_VAR." 2018-01-11 07:58:08 -06:00
Jenkins2
a13578e789 Merge "stasis_system: Remove silly usage of RAII_VAR." 2018-01-11 07:25:51 -06:00
Jenkins2
4534f32fca Merge "stasis: Remove silly usage of RAII_VAR." 2018-01-11 06:58:10 -06:00
Jenkins2
ae723f85ee Merge "stasis_bridges: Remove silly usage of RAII_VAR." 2018-01-11 06:43:33 -06:00
Jenkins2
19523cd5a1 Merge "stasis_cache: Remove silly usage of RAII_VAR." 2018-01-11 06:16:07 -06:00
Corey Farrell
f0eb00d1e7 stasis: Remove silly usage of RAII_VAR.
Change-Id: Ib11193531e797bcb16bba560a408eab155f706d1
2018-01-10 16:09:50 -06:00
Corey Farrell
a383e1ddb1 stasis_cache_pattern: Remove silly usage of RAII_VAR.
Change-Id: Ic98a51f555062cd863b6db3f8d76065943a9dea3
2018-01-10 16:01:17 -06:00
Corey Farrell
0de004dd85 stasis_bridges: Remove silly usage of RAII_VAR.
Change-Id: I0fa7ab05454f183dc4ff10e26d18776d2b0fcf1f
2018-01-09 21:20:02 -06:00
Corey Farrell
01127e1664 stasis_cache: Remove silly usage of RAII_VAR.
Change-Id: Ifa95e5801c949df296c7e4376347730fb0ed52ef
2018-01-09 20:43:17 -06:00
Corey Farrell
175a9ef873 stasis_endpoints: Remove silly usage of RAII_VAR.
Change-Id: Ic099dc552f36c353c89783a4bcfd09f010432733
2018-01-09 20:36:52 -06:00
Corey Farrell
4b655184b0 stasis_message_router: Remove silly usage of RAII_VAR.
Change-Id: I50d6ae230920e0b878ed9cc8f79eef746e06701d
2018-01-09 18:55:46 -06:00
Corey Farrell
3074c4165c stasis_system: Remove silly usage of RAII_VAR.
Change-Id: Iedbe5656cee68cd3a96a953558764aa02d4a0c3b
2018-01-09 18:55:06 -06:00
Alexander Traud
3a7d917256 translate: Avoid absolute value on unsigned substraction.
ast_format_get_sample_rate(.) returns an unsigned type. The difference of a
substraction between two unsigned types does not get implicitly converted to a
signed type. Therefore, using abs(.) did not make sense.

ASTERISK-27549

Change-Id: Ib904d9ee0d46b6fdd1476fbc464fbbf813304017
2018-01-09 11:37:08 -05:00
Jenkins2
4b326eb289 Merge "editline: Avoid comparison between pointer and zero character constant." 2018-01-08 06:13:32 -06:00
Alexander Traud
ad3252ccef editline: Avoid comparison between pointer and zero character constant.
gcc 7.2 warned about this.

ASTERISK-27559

Change-Id: I48960dda9cf0a11b6a9426f775e632363f8caa74
2018-01-06 13:45:28 +01:00
Corey Farrell
cfb88f3ac1 pbx: Prevent execution of NULL pointer.
pbx_extension_helper has a check for q->swo.exec == NULL but it doesn't
actually return so we would still run the function.  Fix the return.
Move the 'int res' variable into the only scope which uses it.

Also fix a copy-paste error in ast_pbx_init which could result in a
crash on allocation failure (we exit with a normal error instead).

Change-Id: I0693af921fdc7f56b6a72a21fb816ed08b960a69
2018-01-04 16:50:04 -05:00
Jenkins2
4eccf697e1 Merge "rtp_engine: Add missing unlock." 2018-01-04 15:02:15 -06:00
Joshua Colp
5cab877093 Merge "translators: Don't use ast_module_running_ref." 2018-01-04 14:49:06 -06:00
Corey Farrell
82cf585fb5 translators: Don't use ast_module_running_ref.
Translators are run during module load before the module is actually
running, so it cannot use ast_module_running_ref.

ASTERISK-20346

Change-Id: Iaa0e75da99c696e38000f1a41e340abbd7a88f56
2018-01-04 12:01:56 -05:00
Corey Farrell
da365affbd rtp_engine: Add missing unlock.
Change-Id: I380c31a255e060309f4916da11176e0d00813215
2018-01-04 10:39:59 -05:00
Corey Farrell
aaed0b8b3a aco: Fix NULL dereference in error path.
Change-Id: Id505167cf0f9414a3c144fa2c1e181a2cf288694
2018-01-04 10:27:44 -05:00
Joshua Colp
2fac32a37a Merge "loader: Create ast_module_running_ref." 2018-01-04 07:12:43 -06:00
Joshua Colp
307abc4cad Merge "datastore: Add automatic module references." 2018-01-04 06:53:28 -06:00
Corey Farrell
55f1d69c43 loader: Create ast_module_running_ref.
This function returns NULL if the module in question is not running.  I
did not change ast_module_ref as most callers do not check the result
and they always call ast_module_unref.

Make use of this function when running registered items from:
* app_stack API's
* bridge technologies
* CLI commands
* File formats
* Manager Actions
* RTP engines
* Sorcery Wizards
* Timing Interfaces
* Translators
* AGI Commands
* Fax Technologies

ASTERISK-20346 #close

Change-Id: Ia16fd28e188b2fc0b9d18b8a5d9cacc31df73fcc
2018-01-03 17:23:36 -05:00
Jenkins2
84d0871380 Merge "core: Use macros to generate ao2_container callbacks where possible." 2018-01-03 07:50:36 -06:00
Joshua Colp
f77ca95418 Merge "aco: Add missing aco_option_type_string for OPT_TIMELEN_T." 2018-01-03 07:09:38 -06:00
Jenkins2
5a1525345e Merge "cdr: submit: fix logic of test for batch mode" 2018-01-03 06:43:47 -06:00
Jenkins2
6480777005 Merge "stasis_channels.c: Misc cleanup." 2018-01-02 07:38:44 -06:00
Tzafrir Cohen
9b5d1454b4 cdr: submit: fix logic of test for batch mode
ASTERISK-27539 #close

Change-Id: I33cdf329d2bb4486dcae975c450f6aae94c515f7
2018-01-02 15:36:04 +02:00
Corey Farrell
f298178583 aco: Add missing aco_option_type_string for OPT_TIMELEN_T.
ASTERISK-27117

Change-Id: I8f6c34bb30830be9f7a40823723eb4dcaaa91c61
2018-01-02 01:26:10 -05:00
Sean Bright
15f8b9b8bf ice: Increase foundation buffer size
Per RFC 5245, the foundation specified with an ICE candidate can be up
to 32 characters but we are only allowing for 31.

ASTERISK-27498 #close
Reported by: Michele Prà

Change-Id: I05ce7a5952721a76a2b4c90366168022558dc7cf
2017-12-31 11:34:41 -05:00
Corey Farrell
bc73337e07 core: Use macros to generate ao2_container callbacks where possible.
This uses AO2_STRING_FIELD_HASH_FN and AO2_STRING_FIELD_CMP_FN where
possible in the Asterisk core.

This removes CMP_STOP from the result of CMP_FN callbacks for the
following structure types:
* ast_bucket_metadata
* ast_bucket_scheme
* generic_monitor_instance_list (ccss.c)
* ast_bucket_file (media_cache.c)
* named_acl

Change-Id: Ide4c1449a894bce70dea1fef664dade9b57578f1
2017-12-30 13:20:16 -05:00
Corey Farrell
0fe7df641a datastore: Add automatic module references.
Add a reference to the calling module when it is active to protect
access to datastore->info.  Remove module references done by
func_periodic_hook as the datastore now handles it.

ASTERISK-25128 #close

Change-Id: I8357a3711e77591d0d1dd8ab4211a7eedd782c89
2017-12-29 16:16:11 -05:00
Richard Mudgett
2dde5bef47 stasis_channels.c: Misc cleanup.
* Use current OBJ_SEARCH_xxx defines instead of the deprecated versions.

* Fix hash_cb and cmp_cb container functions to correctly use the
OBJ_SEARCH_xxx values.

* Remove incorrect usage of CMP_STOP.  Most uses in the system have no
effect.  This allows the collapse of channel_role_single_cmp_cb() and
channel_role_multi_cmp_cb() into channel_role_cmp_cb().

* Remove unnecessary usage of RAII_VAR().

Change-Id: I02c405518cab22aa2a082b61e2353bf7cd629a70
2017-12-28 13:53:27 -06:00
Jenkins2
0d9968e001 Merge "manager.c: Update AMI Status event documentation" 2017-12-28 13:46:22 -06:00
Jenkins2
50cf373be5 Merge "cdr: Missing NULL check and unlock." 2017-12-28 10:42:17 -06:00
Richard Mudgett
d69b7c6c6d manager.c: Update AMI Status event documentation
The AMI Status event had linkedid listed twice and was missing the
effective connected line name and number headers.

NOTE: The linkedid and other standard channel snapshot fields in the XML
documentation are part of the <channel_snapshot/> XML template defined in
doc/appdocsxml.xslt.

Change-Id: I004c4c4f9e7b40ef55035c831702721bec82496c
2017-12-28 09:21:36 -06:00
Corey Farrell
94eb12ca56 cdr: Missing NULL check and unlock.
* handle_dial_message: Missing a check for NULL peer.
* cdr_generic_register: Missing unlock on allocation failure.

cdr_generic_register is fixed by reordering so the new structure is
allocated and initialized before locking the list.

Change-Id: I5799b99270d1a7a716a555c31ac85f4b00ce8686
2017-12-25 21:34:32 -05:00
Corey Farrell
23aa20bf20 loader: Add volatile to resource_being_loaded.
Some compiler optimizers seem to assume that dlopen will not use
__attribute__((constructor)) functions to call back to the program.
This was causing resource_being_loaded to be optimized away completely.

ASTERISK-27531 #close
Tested By: abelbeck

Change-Id: If17a3b889e06811a0e7119f0539d052494d6ece9
2017-12-23 23:44:12 -06:00
Sean Bright
fd0ca1c3f9 Remove as much trailing whitespace as possible.
Change-Id: I873c1c6d00f447269bd841494459efccdd2c19c0
2017-12-22 09:23:22 -05:00
Jenkins2
0100c9267e Merge "Fix Common Typo's." 2017-12-21 08:40:22 -06:00
Joshua Colp
c7a0ad8b99 Merge "bridge: Old channel video source not set to NULL after unref." 2017-12-21 06:15:44 -06:00
Corey Farrell
1b80ffa495 Fix Common Typo's.
Fix instances of:
* Retreive
* Recieve
* other then
* different then
* Repeated words ("the the", "an an", "and and", etc).
* othterwise, teh

ASTERISK-24198 #close

Change-Id: I3809a9c113b92fd9d0d9f9bac98e9c66dc8b2d31
2017-12-20 12:40:01 -05:00
Corey Farrell
aaa3884d4a bridge: Old channel video source not set to NULL after unref.
The bridge holds onto the old channel video source after it's been
released.  This can lead to use after free errors.

ASTERISK-27229 #close

Change-Id: Ib2dab61677dd8a21f7ad53cdc9b8ca93297838b3
2017-12-20 11:23:08 -05:00
Corey Farrell
c2850bfebc core: Fix unused variable error in handle_show_sysinfo.
Apparently in OSX it's possible for OSX to HAVE_SYSCTL but not
HAVE_SYSINFO or HAVE_SWAPCTL.  In this case freeswap caused an unused
variable error.

ASTERISK-26563 #close

Change-Id: I8ec5b1897b786cc1abaf62264aa75039eea05510
2017-12-20 11:13:13 -05:00
Jenkins2
4815be9aeb Merge "CLI: Address multiple issues." 2017-12-20 08:54:58 -06:00
Jenkins2
0b9396720a Merge "bridge: Stop music on hold on adding an arbitrary channel to a bridge" 2017-12-20 08:34:51 -06:00
Jenkins2
a711ac25f1 Merge "dns_core: Protect against array index violation." 2017-12-20 08:00:29 -06:00
Jenkins2
262eda7801 Merge "Remove constant conditionals (dead-code)." 2017-12-19 19:17:25 -06:00
Corey Farrell
d51837a1b9 CLI: Address multiple issues.
* listen uses the variable `s` for the result from ast_poll() then
  overwrites it with the result of accept().  Create a separate variable
  poll_result to avoid confusion since ast_poll does not return a file
  descriptor.
* Resolve fd leak that would occur if setsockopt failed in listen.
* Reserve an extra byte while processing completion results from remote
  daemon.  This fixes a bug where completion processing used strstr() on
  a string that was not '\0' terminated.  This was no risk to the Asterisk
  daemon, the bug was only reachable the remote console process.
* Resolve leak in handle_showchan when the channel is not found.
* Multiple leaks and a deadlock in pbx_config CLI completion.
* Fix leaks in "manager show command".

Change-Id: I8f633ceb1714867ae30ef4e421858f77c14485a9
2017-12-19 16:43:49 -05:00
Jenkins2
204dd027dd Merge "core: Fix multiple trivial issues in the core." 2017-12-19 14:46:02 -06:00
George Joseph
88f7f4ebb6 Merge "main/app: Fix leaks." 2017-12-19 14:19:42 -06:00
Corey Farrell
b8f54f742f dns_core: Protect against array index violation.
Add a check to allocate_dns_record to prevent calling a pointer
retrieved from beyond dns_alloc_table.

ASTERISK-27495 #close

Change-Id: Ie2f6e4991cea46baa12e837bd64cc22b44d322bb
2017-12-19 14:50:11 -05:00
Ivan Poddubny
3b99a0332c bridge: Stop music on hold on adding an arbitrary channel to a bridge
When a channel that is on hold gets added to a bridge by
the Bridge AMI action or the dialplan application of the same name,
music continues to play, causing "robotic sound".

This commit adds a call to ast_moh_stop to stop the music.
Also, it makes the AMI Park action use the right MOH class when the
channel gets parked.

Reported by: Zane Conkle

ASTERISK-25079 #close

Change-Id: I4b129c5a20c15e63968842460ac5a1a85903cf9f
2017-12-19 18:17:52 +01:00
Jenkins2
6bd25cad86 Merge "rtp_engine.c: Eliminate rtcp_report_to_json() RAII_VAR usage." 2017-12-19 10:51:07 -06:00
Corey Farrell
b3e839debd Remove constant conditionals (dead-code).
Some variables are set and never changed, making them constant.  This
means that code in the 'false' block of the conditional is unreachable.

In chan_skinny and res_config_ldap I used preprocessor directive `#if 0`
as I'm unsure if the unreachable code could be enabled in the future.

Change-Id: I62e2aac353d739fb3c983cf768933120f5fba059
2017-12-19 09:42:19 -05:00
Corey Farrell
bf33a09c37 core: Fix multiple trivial issues in the core.
* Fix small leaks in from error conditions in sdp.c and translate.c.
* Check new file descriptor is less than 0, not less than or equal.

Change-Id: Id7782775486175c739e0c4bf3ea5e17e3f452a99
2017-12-19 00:36:24 -05:00
Corey Farrell
8dfc973d64 main/app: Fix leaks.
* ast_linear_stream would leak a file descriptor if it failed to allocate
  lin.
* ast_control_tone leaked zone and ts if ast_playtones_start failed.

Additionally added whitespace to ast_linear_stream, pulled assignments
out of conditionals for improved readability.

Change-Id: I6d1a10cf9161b1529d939b9b2d63ea36d395b657
2017-12-18 21:04:31 -05:00
Richard Mudgett
f6393b59af ast_json_pack(): Use safer json ref mechanism.
Change-Id: I49204db2e57ae96eee43909c18ed007c09ac817e
2017-12-18 18:05:29 -06:00
Richard Mudgett
7054fb8756 rtp_engine.c: Eliminate rtcp_report_to_json() RAII_VAR usage.
Change-Id: I58a22c2ca82e91d7537409b7b3af2d735827a54d
2017-12-18 18:02:09 -06:00
Jenkins2
11a1e07ad2 Merge "netsock: Remove from Asterisk core." 2017-12-18 17:40:22 -06:00
Jenkins2
7b127e2d20 Merge "CLI: Fix 'core set debug channel' completion bug." 2017-12-18 16:01:11 -06:00
George Joseph
08440fd1d9 Merge "CLI: Remove special handling of 'core set verbose' from rasterisk." 2017-12-18 14:42:39 -06:00
Joshua Colp
5224fd3ab4 Merge changes from topic 'faster-aco'
* changes:
  aco: Minimize use of regex.
  aco: Create ways to minimize use of regex.
2017-12-18 14:41:41 -06:00
Corey Farrell
064c74e4af netsock: Remove from Asterisk core.
This moves netsock.c / netsock.h to the chan_iax2 module.  netsock.h has
been marked deprecated since 13.0.0, chan_iax2 is the only remaining
user.

Change-Id: I28c6578043bac18de5ea608e136acec4f83d5dd3
2017-12-18 15:00:35 -05:00
Corey Farrell
731a23fba7 CLI: Fix 'core set debug channel' completion bug.
The completion generator is missing a return so typing "core set debug
all off <tab>" causes the command to actually execute.

Change-Id: Ibf6462088a74eee66967732b50445783ebefc20b
2017-12-18 13:23:46 -05:00
George Joseph
c56c4312ad Merge changes from topic 'loader-work'
* changes:
  loader: Use vector to build apha sorted module lists.
  loader: Replace priority heap with vector.
2017-12-18 10:24:28 -06:00
Jenkins2
5346c290e0 Merge "cdr: Minor optimizations." 2017-12-18 08:54:28 -06:00
Jenkins2
7ffe5aba24 Merge "loader: Rework of load_dynamic_module." 2017-12-18 08:29:08 -06:00
Jenkins2
c9bcd888a2 Merge "res_rtp_asterisk.c: Disable packet flood detection for video streams." 2017-12-15 12:15:42 -06:00
Joshua Colp
b223f0e108 Merge "loader: Minor fix to module registration." 2017-12-15 10:48:02 -06:00
Corey Farrell
e6768c0f81 cdr: Minor optimizations.
* bridge_candidate_process: remove SCOPED_AO2LOCK and return value.
* handle_standard_bridge_enter_message: replace recursive call with goto
  statement.

ASTERISK-24297

Change-Id: Id2eaa0822fb8dc799f63422bb3aa89de9d4ee2a2
2017-12-15 10:30:36 -06:00
Jenkins2
dff0415b1e Merge "pjsip_options: wrongly applied "UNKNOWN" status" 2017-12-15 09:49:50 -06:00
Corey Farrell
bf2d35931d aco: Minimize use of regex.
Remove nearly all use of regex from ACO users.  Still remaining:
* app_confbridge has a legitamate use of option name regex.
* ast_sorcery_object_fields_register is implemented with regex, all
  callers use simple prefix based regex.  I haven't decided the best
  way to fix this in both 13/15 and master.

Change-Id: Ib5ed478218d8a661ace4d2eaaea98b59a897974b
2017-12-15 10:14:31 -05:00
Corey Farrell
a455e18320 aco: Create ways to minimize use of regex.
ACO uses regex in many situations where it is completely unneeded.  In
some cases this doubles the total processing performed by
aco_process_config.

* Create ACO_IGNORE category type for use in place of skip_category
  regex source string.
* Create additional aco_category_op values to allow specifying category
  filter using either a single plain string or a NULL terminated array
  of plain strings.
* Create ACO_PREFIX to allow matching option names to case insensitive
  prefixes.

Change-Id: I66a920dcd8e2b0301f73f968016440a985e72821
2017-12-15 10:14:20 -05:00
Corey Farrell
9d5797616c loader: Use vector to build apha sorted module lists.
Change-Id: I9c519f4dec3cda98b2f34d314255a31d49a6a467
2017-12-14 21:24:19 -05:00
Corey Farrell
7b54903313 loader: Replace priority heap with vector.
This is needed for future changes which will require being able to
process the load priority out of order.

Change-Id: Ia23421197f09789940510b03ebbbf3bf24d51bea
2017-12-14 20:53:25 -05:00
Corey Farrell
3505cc88e8 loader: Rework of load_dynamic_module.
* Split off load_dlopen to perform actual dlopen, check results and log
  warnings when needed.
* Always use RTLD_NOW.
* Use flags which minimize number of calls to dlopen required.  First
  attempt always uses RTLD_GLOBAL when global_symbols_only is enabled,
  RTLD_LOCAL when it is not.

This patch significantly reduces the number of dlopen's performed.  With
299 modules my system ran dlopen 857 times before this patch, 655 times
after this patch.

Change-Id: Ib2c9903cfddcc01aed3e01c1e7fe4a3fb9af0f8b
2017-12-14 18:49:51 -05:00
Corey Farrell
80bf0ee99a loader: Minor fix to module registration.
This protects the module loader itself against crashing if dlopen is
called on a module from outside loader.c.

* Expand scope of lock inside ast_module_register to include reading of
  resource_being_loaded.
* NULL check resource_being_loaded.
* Set resource_being_loaded NULL as soon as dlopen returns.  This fixes
  some error paths where it was not NULL'ed.
* Create module_destroy function to deduplicate code from
  ast_module_unregister and modules_shutdown.
* Resolve leak that occured if a module did not successfully register.
* Simplify checking for successful registration.

Change-Id: I40f07a315e55b92df4fc7faf525ed6d4f396e7d2
2017-12-14 18:44:48 -05:00
Richard Mudgett
98f7e9251f res_rtp_asterisk.c: Disable packet flood detection for video streams.
We should not do flood detection on video RTP streams.  Video RTP streams
are very bursty by nature.  They send out a burst of packets to update the
video frame then wait for the next video frame update.  Really only audio
streams can be checked for flooding.  The others are either bursty or
don't have a set rate.

* Added code to selectively disable packet flood detection for video RTP
streams.

ASTERISK-27440

Change-Id: I78031491a6e75c2d4b1e9c2462dc498fe9880a70
2017-12-14 14:40:34 -06:00
George Joseph
afb6e85980 Merge "CLI: Fix 'core show sysinfo' function ordering." 2017-12-13 13:12:27 -06:00
Corey Farrell
5f6a3c4399 CLI: Remove special handling of 'core set verbose' from rasterisk.
rasterisk does not need to handle setting verbose levels locally, it
should just tell the daemon what it wants and print what it is given.
Just max out the verbose level on the local client so all filtering
happens on the daemon.

ASTERISK-20281 #close

Change-Id: Ia305f75f1fc424a9169bfa30ef70d626ace2c8a8
2017-12-13 11:10:37 -06:00
Corey Farrell
c01ba7437e CLI: Fix 'core show sysinfo' function ordering.
Handle CLI initialization before any processing occurs.

Change-Id: I598b911d2e409214bbdfd0ba0882be1d602d221c
2017-12-11 20:21:16 -05:00
Kevin Harwell
b088cddc03 pjsip_options: wrongly applied "UNKNOWN" status
A couple of places were setting the status to "UNKNOWN" when qualifies were
being disabled. Instead this should be set to the "CREATED" status that
represents when a contact is given (uri available), but the qualify frequency
is set to zero so we don't know the status.

This patch updates the relevant places with "CREATED". It also updates the
"CREATED" status description (value shown in CLI/AMI/ARI output) to a value
of "NonQualified"/"NonQual" as this description is hopefully less confusing.

ASTERISK-27467

Change-Id: Id67509d25df92a72eb3683720ad2a95a27b50c89
2017-12-11 15:27:29 -06:00
Richard Mudgett
c2ec82bf36 stasis_channels.c: Don't set channel snapshot caller_dnid twice.
Change-Id: Ib8d45bbdfbda81e65045f6dff874d189b74e5471
2017-12-11 14:14:57 -06:00
Jenkins2
b7e79d7baf Merge "astdb: Improve prefix searches in astdb" 2017-12-11 12:12:58 -06:00
Jenkins2
f81a884033 Merge "loader: Refactor resource_name_match." 2017-12-11 11:44:34 -06:00
Sean Bright
9a9edc6c9e astdb: Improve prefix searches in astdb
Using the LIKE operator requires a full table scan of 'astdb', whereas a
comparison operation is able to use the primary key index.

This patch adds a new function to the AstDB API for quick prefix matches
and updates res_sorcery_astdb to utilize it. This showed substantial
performance improvement in my test environment.

Related to ASTERISK~26806, but does not completely resolve it.

Change-Id: I7d37f9ba2aea139dabf2ca72d31fbe34bd9b2fa1
2017-12-10 12:51:16 -06:00
Corey Farrell
d2e87b8e14 loader: Refactor resource_name_match.
Optimize resource_name_match.  This change eliminates use of
ast_strdupa, instead verifying that both basename's are the same length,
then using strncasecmp.

Change-Id: I477275c0e954c99d74be5abfc8bb6545b04e5a3d
2017-12-08 19:51:09 -05:00
Sean Bright
2ffe52a116 utils: Add convenience function for setting fd flags
There are many places in the code base where we ignore the return value
of fcntl() when getting/setting file descriptior flags. This patch
introduces a convenience function that allows setting or clearing file
descriptor flags and will also log an error on failure for later
analysis.

Change-Id: I8b81901e1b1bd537ca632567cdb408931c6eded7
2017-12-08 13:28:04 -06:00
Jenkins2
b0b28446c1 Merge "translate: Skip matrix_rebuild during shutdown." 2017-12-07 14:33:47 -06:00
George Joseph
d7f3f8c283 Merge "sounds_index: Avoid repeatedly reindexing." 2017-12-07 13:26:22 -06:00
George Joseph
5cef8b2f3e Merge "media_index: Improve startup." 2017-12-07 13:26:06 -06:00
Corey Farrell
c2c9995830 translate: Skip matrix_rebuild during shutdown.
Change-Id: I1e5eef4029cba56e33d786c5a5ade8091e531a1e
2017-12-07 00:35:14 -05:00
Corey Farrell
ab191e9782 sounds_index: Avoid repeatedly reindexing.
The sounds index is rebuilt each time a format is registered or
unregistered.  This causes the index to be repeatedly rebuilt during
startup and shutdown.

This patch significantly reduces the work done by delaying sound index
initialization until after modules are loaded.  This way a reindex only
occurs if a format module is loaded after startup.  We also skip
reindexing when format modules are unloaded during shutdown.

Change-Id: I585fd6ee04200612ab1490dc804f76805f89cf0a
2017-12-06 18:47:28 -05:00
Corey Farrell
2af59ebb3a media_index: Improve startup.
This eliminates some wasteful operations in media_index startup.

* Replace statically set string-fields with char[0].
* Eliminate pointless RAII_VAR's.
* alloc_variant: Avoid pointless ao2_find on new info->variant.
* Stop trying find_variant before alloc_variant.
* process_media_file: replace ast_str with ast_asprintf.  This avoids
  reallocation of file_id_str.

Overall sounds_index.c is about 27% of Asterisk startup time when using
sample configs.  This patch reduces it to 20%.  This is a half-fix.  The
real problem is that the media_index is regenerated repeatedly - 68
times in my test.

Change-Id: Ia50b752f8efb356f852b05c4be495a6631af8652
2017-12-06 14:34:32 -05:00
Richard Mudgett
e97e41552e bridge_basic.c: Update transfer diagnostic messages addendum.
* Added start DTMF transfer verbose messages.
* Made associated transfer messages use a similar message format.
* Adjusted message verbose level as requested by initial reporter.

ASTERISK-27449

Change-Id: I2045714586414b3c5ef1f3cc56c1c4af4b31f551
2017-12-06 07:51:24 -06:00
Niklas Larsson
9d00583164 bridge_basic.c: Update transfer diagnostic messages.
* Add the channel name to diagnostic messages so you will know which
channel failed to transfer.

* Promoted some debug messages to verbose 4 messages.

ASTERISK-27449 #close

Change-Id: Idac66b7628c99379cc9269158377fd87dc97a880
2017-12-05 15:39:19 -06:00
Joshua Colp
93c2cd1383 Merge "config: Speed up config template lookup" 2017-12-04 08:51:11 -06:00
Sean Bright
d9fdeae6a4 config: Speed up config template lookup
ast_category_get() has an (undocumented) implementation detail where it
tries to match the category name first by an explicit pointer comparison
and if that fails falls back to a normal match.

When initially building an ast_config during ast_config_load, this
pointer comparison can never succeed, but we will end up iterating all
categories twice. As the number of categories using a template
increases, this dual looping becomes quite expensive. So we pass a flag
to category_get_sep() indicating if a pointer match is even possible
before trying to do so, saving us a full pass over the list of current
categories.

In my tests, loading a file with 3 template categories and 12000
additional categories that use those 3 templates (this file configures
4000 PJSIP endpoints with AOR & Auth) takes 1.2 seconds. After this
change, that drops to 22ms.

Change-Id: I59b95f288e11eb6bb34f31ce4cc772136b275e4a
2017-12-01 11:14:04 -06:00
Sean Bright
1ad0fbc80e config: Speed up ACO & sorcery initialization
When starting Asterisk in the foreground, there is a perceptible delay
when loading modules that use the ACO and sorcery config frameworks.
For example, a lightly configured res_pjsip took 853ms to load on my
VM.

I tracked down the slowness to the XPath queries used to associate the
relevant documentation with the config options. One improvement was
adding a call to xmlXPathOrderDocElems after loading an XML document.
From the libxml2 docs:

  Call this routine to speed up XPath computation on static documents.

The second change was to remove recursive descent and wildcard
operators from the XPath queries. After these changes, res_pjsip takes
85ms to load on my VM and there is no longer a perceptible delay when
starting Asterisk in the foreground.

Change-Id: I45d457f1580e26bf5a2b0dab16e8e9ae46dcbd82
2017-12-01 08:41:02 -06:00
Jenkins2
5de9754313 Merge "translate: Transcode siren14, speex32, silk24, and silk12 via slin16." 2017-11-30 10:16:17 -06:00
Jenkins2
f98dad52d2 Merge "CLI: Remove compatibility code." 2017-11-28 12:50:28 -06:00
Joshua Colp
c7aa6e41c1 Merge "translate: Show sample rate for silk, speex, and slin in translation table." 2017-11-28 12:37:51 -06:00
Corey Farrell
d12a2ab400 CLI: Remove compatibility code.
Previous commits maintained compatibility with older remote console
clients as well as maintaining all API's.

Remove the following compatibility code:
* ast_cli_generatornummatches.
* Remote command "_command nummatches".
* Sorting / duplicate removal by remote console.

Change-Id: I59e6ce94fa57ae564888442049695f7e46746437
2017-11-27 16:23:06 -06:00
Jenkins2
ae342a824f Merge "CLI: Finish conversion of completion handling to vectors." 2017-11-27 15:13:19 -06:00
George Joseph
b4119a4c31 Merge "CLI: Refactor cli_complete." 2017-11-27 14:39:06 -06:00
Joshua Colp
a06bca48e7 Merge "CLI: Rewrite ast_el_strtoarr to use vector's internally." 2017-11-27 14:17:20 -06:00
George Joseph
708189ce02 Merge "CLI: Create ast_cli_completion_add function." 2017-11-27 13:26:43 -06:00
Jenkins2
b69bfc637f Merge "CLI: Refactor ast_cli_display_match_list." 2017-11-27 13:23:52 -06:00
George Joseph
93dba6f396 Merge "CLI: Remove calls to ast_cli_generator." 2017-11-27 12:11:18 -06:00
Alexander Traud
58115e9c21 translate: Transcode siren14, speex32, silk24, and silk12 via slin16.
When a format has no pre-recorded sound files, Asterisk has to transcode between
formats. For this, Asterisk has a fixed translation table. If the pre-recorded
sound files are not available in the same sample rate, Asterisk has not only to
transcode but also to resample.

Asterisk has pre-recorded files for SLN (8000 kHz) and SLN16 (16000 kHz).
However before this change, Asterisk did not take the sample rate into account,
because the translation paths to SLN and SLN16 got the same score/weight in the
table. Consequently, you might have got narrow-band audio with siren14, speex32,
silk24, and silk12 although those are (ultra) wide-band audio codecs.

With this change, the distance in sample-rates is taken into account. Now on the
Command-Line interface (CLI) 'core show channels', you should see:
(slin@16000)->(slin@32000)->(speex@32000).

ASTERISK-23735
Reported by: Richard Kenner

Change-Id: I9448295c1978be26f8633b6066395e7bbbe2e213
2017-11-26 18:47:17 +01:00
Alexander Traud
74e7005a74 translate: Show sample rate for silk, speex, and slin in translation table.
ASTERISK-24662

Change-Id: I3822956984292c99c48bca8e97807e498ccc0e88
2017-11-25 11:09:08 +01:00
Joshua Colp
ac6b029fe4 Merge "aoc: Remove silly usage of RAII_VAR." 2017-11-21 11:46:49 -06:00
Joshua Colp
0434f6a255 Merge "abstract_jb: Remove silly usage of RAII_VAR." 2017-11-21 11:04:47 -06:00
Joshua Colp
11cb4f2715 Merge "app: Remove silly usage of RAII_VAR." 2017-11-21 09:42:11 -06:00
Joshua Colp
40c3114013 Merge "ccss: Remove silly usage of RAII_VAR." 2017-11-21 09:27:20 -06:00
Corey Farrell
b79d04f8f8 CLI: Finish conversion of completion handling to vectors.
Change-Id: Ib81318f4ee52a5e73b003316e13fe9be1dd897a1
2017-11-21 09:48:36 -05:00
Corey Farrell
fbb8c0d3e4 CLI: Refactor cli_complete.
* Stop using "_COMMAND NUMMATCHES" on remote consoles.  Using this
  command had doubled the amount of work needed from the Asterisk
  daemon for each completion request.
* Fix code formatting.
* Remove static buffer used to send the command, use the same buffer
  that will receive the results.
* Move sort from ast_cli_display_match_list.

Change-Id: Ie2211b519a3d4bec45bf46e0095bdd01d384cb69
2017-11-21 09:48:36 -05:00
Corey Farrell
1cd24cd726 CLI: Rewrite ast_el_strtoarr to use vector's internally.
This rewrites ast_el_strtoarr to use vector's internally, but still
return the original NULL terminated array of strings.

Change-Id: Ibfe776cbe14f750effa9ca360930acaccc02e957
2017-11-21 09:48:36 -05:00
Corey Farrell
9c0a2110f0 CLI: Refactor ast_cli_display_match_list.
* Stop estimating line count, just print until we run out of matches.
* Stop freeing entries, the caller does that anyways.
* Stop calculating / returning numoutput, it was ignored.

Change-Id: I7f92afa8bea92241a95227587367424c8c32a5cb
2017-11-21 09:48:36 -05:00
Corey Farrell
9587a61f4c CLI: Create ast_cli_completion_add function.
Some completion generators are very inefficent due to the way CLI
requests matches one at a time.  ast_cli_completion_add can be called
multiple times during one invokation of a CLI generator to add all
results without having to reinitialize the search state for each match.

Change-Id: I73d26d270bbbe1e3e6390799cfc1b639e39cceec
2017-11-21 09:39:19 -05:00