Commit Graph

914 Commits

Author SHA1 Message Date
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
Alexander Traud 162fc4fba6 BuildSystem: Depend not implicitly but explicitly on external libraries.
ASTERISK-27722

Change-Id: Ie7b8c30d86cb00a54d6ac4e09e6f28f42d2bd52c
2018-03-06 14:33:14 +01:00
Sean Bright 50d9af101e func_audiohookinherit: Remove deprecated module.
Change-Id: Id52f719078a65c4b2eee7ab99d761eba6b6aed94
2018-02-22 11:54:33 -05:00
Corey Farrell 527cf5a570 Remove redundant module checks and references.
This removes references that are no longer needed due to automatic
references created by module dependencies.

In addition this removes most calls to ast_module_check as they were
checking modules which are listed as dependencies.

Change-Id: I332a6e8383d4c72c8e89d988a184ab8320c4872e
2018-01-24 13:37:29 -05:00
Corey Farrell 9cfdb81e91 loader: Add dependency fields to module structures.
* Declare 'requires' and 'enhances' text fields on module info structure.
* Rename 'nonoptreq' to 'optional_modules'.
* Update doxygen comments.

Still need to investigate dependencies among modules I cannot compile.

Change-Id: I3ad9547a0a6442409ff4e352a6d897bef2cc04bf
2018-01-15 13:25:51 -05:00
Jenkins2 8187bde9bf Merge "func_odbc: Add missing unlock's to acf_odbc_read." 2018-01-04 13:53:20 -06:00
Corey Farrell e3c9314a2e func_odbc: Add missing unlock's to acf_odbc_read.
Change-Id: I828329ecbd252ae8f27a369a046d2b03102b07c6
2018-01-03 20:31:40 -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 1d3dc9aea2 func_channel.c: Update MASTER_CHANNEL documentation
Be more explicit in what is meant by the master channel to eliminate
misunderstanding.

ASTERISK-23133

Change-Id: I453bcaf4b99404a5a3e345dbf093ac6c1afcfc72
2017-12-27 21:15:16 -06:00
Sean Bright fd0ca1c3f9 Remove as much trailing whitespace as possible.
Change-Id: I873c1c6d00f447269bd841494459efccdd2c19c0
2017-12-22 09:23:22 -05:00
Corey Farrell a790ced2e8 func_callerid: Initialize app argument structures.
This module uses AST_DEFINE_APP_ARGS_TYPE to define struct's instead of
directly using AST_DECLARE_APP_ARGS.  Initialize the variables declared
in this way.

Change-Id: If97fbdd8d63a204e2efd498a192effc14e90fb31
2017-12-18 20:35:12 -05:00
Richard Mudgett 3078b7adc2 CDR: Fix deadlock setting some CDR values.
Setting channel variables with the AMI Originate action caused a deadlock
when you set CDR(amaflags) or CDR(accountcode).  This path has the channel
locked when the CDR function is called.  The CDR function then
synchronously passes the job to a stasis thread.  The stasis handling
function then attempts to lock the channel.  Deadlock results.

* Avoid deadlock by making the CDR function handle setting amaflags and
accountcode directly on the channel rather than passing it off to the CDR
processing code under a stasis thread to do it.

* Made the CHANNEL function and the CDR function process amaflags the same
way.

* Fixed referencing the wrong message type in cdr_prop_write().

ASTERISK-27460

Change-Id: I5eacb47586bc0b8f8ff76a19bd92d1dc38b75e8f
2017-12-06 15:59:59 -06:00
Joshua Colp 68b6ebd836 Merge "Prevent unload of modules which implement an Optional API." 2017-11-06 10:11:51 -06:00
Corey Farrell 606ae3484a Add missing menuselect dependencies.
This adds menuselect dependencies for modules that use symbols of other
modules.

ASTERISK-27390

Change-Id: Ia2d2849f5b87a72af7324a82edc3f283eafb5385
2017-11-02 02:57:52 -04:00
Corey Farrell 79f111e1f3 Prevent unload of modules which implement an Optional API.
Once an Optional API module is loaded it should stay loaded.  Unloading
an optional API module runs the risk of a crash if something else is
using it.  This patch causes all optional API providers to tell the
module loader not to unload except at shutdown.

ASTERISK-27389

Change-Id: Ia07786fe655681aec49cc8d3d96e06483b11f5e6
2017-11-01 20:46:11 -04:00
Joshua Colp f2985e3106 bridge: Change participant SFU streams when source streams change.
Some endpoints do not like a stream being reused for a new
media stream. The frame/jitterbuffer can rely on underlying
attributes of the media stream in order to order the packets.
When a new stream takes its place without any notice the
buffer can get confused and the media ends up getting dropped.

This change uses the SSRC change to determine that a new source
is reusing an existing stream and then bridge_softmix renegotiates
each participant such that they see a new media stream. This
causes the frame/jitterbuffer to start fresh and work as expected.

ASTERISK-27277

Change-Id: I30ccbdba16ca073d7f31e0e59ab778c153afae07
2017-09-21 12:20:02 -05:00
Jacek Konieczny 525f84bb35 func_cdr: honour 'u' flag on dummy channel
Fixes ${CDR(...,u)} when used in cdr_custom.conf

ASTERISK-27165 #close

Change-Id: Ia4e0b6ba93e03d27886354c279737790e2cd6a83
2017-09-07 04:37:19 -05:00
Corey Farrell 1bf3dfffd7 AST-2017-006: Fix app_minivm application MinivmNotify command injection
An admin can configure app_minivm with an externnotify program to be run
when a voicemail is received.  The app_minivm application MinivmNotify
uses ast_safe_system() for this purpose which is vulnerable to command
injection since the Caller-ID name and number values given to externnotify
can come from an external untrusted source.

* Add ast_safe_execvp() function.  This gives modules the ability to run
external commands with greater safety compared to ast_safe_system().
Specifically when some parameters are filled by untrusted sources the new
function does not allow malicious input to break argument encoding.  This
may be of particular concern where CALLERID(name) or CALLERID(num) may be
used as a parameter to a script run by ast_safe_system() which could
potentially allow arbitrary command execution.

* Changed app_minivm.c:run_externnotify() to use the new ast_safe_execvp()
instead of ast_safe_system() to avoid command injection.

* Document code injection potential from untrusted data sources for other
shell commands that are under user control.

ASTERISK-27103

Change-Id: I7552472247a84cde24e1358aaf64af160107aef1
2017-08-30 18:43:38 +00:00
Joshua Colp 4146facfec func_cdr: Allow empty value for CDR dialplan function.
A regression was introduced in 12 where passing an empty value
to the CDR dialplan function was not longer allowed. This
change returns to the behavior of 11 where it is permitted.

ASTERISK-26173

Change-Id: I3f148203b54ec088007e29e30005a5de122e51c5
2017-05-05 08:59:02 -05:00
George Joseph 747beb1ed1 modules: change module LOAD_FAILUREs to LOAD_DECLINES
In all non-pbx modules, AST_MODULE_LOAD_FAILURE has been changed
to AST_MODULE_LOAD_DECLINE.  This prevents asterisk from exiting
if a module can't be loaded.  If the user wishes to retain the
FAILURE behavior for a specific module, they can use the "require"
or "preload-require" keyword in modules.conf.

A new API was added to logger: ast_is_logger_initialized().  This
allows asterisk.c/check_init() to print to the error log once the
logger subsystem is ready instead of just to stdout.  If something
does fail before the logger is initialized, we now print to stderr
instead of stdout.

Change-Id: I5f4b50623d9b5a6cb7c5624a8c5c1274c13b2b25
2017-04-12 15:57:21 -06:00
Richard Mudgett 8cb4f9cea1 CHANNEL(callid): Give dialplan access to the callid.
* Added CHANNEL(callid) to retrieve the call identifier log tag associated
with the channel.  Dialplan now has access to the call log search key
associated with the channel so it can be saved in case there is a problem
with the call.

ASTERISK-26878

Change-Id: I2c97ebd928b6f3c5bc80c5729e4d3c07f453049f
2017-03-17 09:52:00 -06:00
zuul bcc9a07db2 Merge "funcs/func_devstate: Remove new line in Device field of during module load" 2017-03-15 20:13:17 -05:00
Matt Jordan 0ded269bfa funcs/func_devstate: Remove new line in Device field of during module load
During module loading of func_devstate, Asterisk emits the current
device state of all Custom device states currently stored in the AstDB.
This was erroneously including a new line character ('\n') to the end of
the device state, causing two new lines to be emitted in
DeviceStateChange AMI events.

Note that this only happened for those device state changes that
occurred during startup. Regular device state changes for Custom device
states are handled elsewhere, and did not have the newline.

ASTERISK-26643 #close
Reported by: Roman Bedros
Tested by: Matt Jordan
patches:
  ami_devstate.diff uploaded by Roman Bedros (License 6842)

Change-Id: I1f4c02fc79c448d43bf725f5039c83d9611d7d93
2017-03-14 09:05:19 -06:00
Joshua Colp 3ed05badb9 core: Add stream topology changing primitives with tests.
This change adds a few things to facilitate stream topology changing:

1. Control frame types have been added for use by the channel driver
to notify the application that the channel wants to change the stream
topology or that a stream topology change has been accepted. They are
also used by the indicate interface to the channel that the application
uses to indicate it wants to do the same.

2. Legacy behavior has been adopted in ast_read() such that if a
channel requests a stream topology change it is denied automatically
and the current stream topology is preserved if the application is
not capable of handling streams.

Tests have also been written which confirm the multistream and
non-multistream behavior.

ASTERISK-26839

Change-Id: Ia68ef22bca8e8457265ca4f0f9de600cbcc10bc9
2017-03-07 12:08:51 +00:00
Sean Bright 3f94373778 cli: Fix various CLI documentation and completion issues
* app_minivm: Use built-in completion facilities to complete optional
arguments.

* app_voicemail: Use built-in completion facilities to complete
optional arguments.

* app_confbridge: Add missing colons after 'Usage' text.

* chan_alsa: Use built-in completion facilities to complete optional
arguments.

* chan_sip: Use built-in completion facilities to complete optional
arguments. Add completions for 'load' for 'sip show user', 'sip show
peer', and 'sip qualify peer.'

* chan_skinny: Correct and extend completions for 'skinny reset' and
'skinny show line.'

* func_odbc: Correct completions for 'odbc read' and 'odbc write'

* main/astmm: Use built-in completion facilities to complete arguments
for 'memory' commands.

* main/bridge: Correct completions for 'bridge kick.'

* main/ccss: Use built-in completion facilities to complete arguments
for 'cc cancel' command.

* main/cli: Add 'all' completion for 'channel request hangup.' Correct
completions for 'core set debug channel.' Correct completions for 'core
show calls.'

* main/pbx_app: Remove redundant completions for 'core show
applications.'

* main/pbx_hangup_handler: Remove unused completions for 'core show
hanguphandlers all.'

* res_sorcery_memory_cache: Add completion for 'reload' argument of
'sorcery memory cache stale' and properly implement.

Change-Id: Iee58c7392f6fec34ad9d596109117af87697bbca
2017-02-13 11:33:15 -05:00
Sean Bright 0910773077 manager: Restore Originate failure behavior from Asterisk 11
In Asterisk 11, if the 'Originate' AMI command failed to connect the provided
Channel while in extension mode, a 'failed' extension would be looked up and
run. This was, I believe, unintentionally removed in 51b6c49. This patch
restores that behavior.

This also adds an enum for the various 'synchronous' modes in an attempt to
make them meaningful.

ASTERISK-26115 #close
Reported by: Nasir Iqbal

Change-Id: I8afbd06725e99610e02adb529137d4800c05345d
2017-02-10 18:04:41 -05:00
George Joseph 6f645a6d4e Merge "media: Add experimental support for RTCP feedback." 2017-01-27 07:04:52 -06:00
Lorenzo Miniero 1061539b75 media: Add experimental support for RTCP feedback.
This change adds experimental support for providing RTCP
feedback information to codec modules so they can dynamically
change themselves based on conditions.

ASTERISK-26584

Change-Id: Ifd6aa77fb4a7ff546c6025900fc2baf332c31857
2017-01-23 13:25:31 +01:00
Richard Mudgett cfe72c39cf LISTFILTER: Remove outdated ERROR message.
Feeding LISTFILTER an empty variable results in an invalid ERROR message.
Earlier changes made the message useless because we can no longer tell if
the variable is empty or does not exist.  It is valid to try to remove a
value from an empty list just as it is valid to try to remove a value that
is not in a non-empty list.

* Removed the outdated ERROR message.

* Added more test cases to the LISTFILTER unit test.

Change-Id: Ided9040e6359c44a335ef54e02ef5950a1863134
2017-01-22 17:56:15 -06:00
Corey Farrell a6e5bae3ef Remove ASTERISK_REGISTER_FILE.
ASTERISK_REGISTER_FILE no longer has any purpose so this commit removes
all traces of it.

Previously exported symbols removed:
* __ast_register_file
* __ast_unregister_file
* ast_complete_source_filename

This also removes the mtx_prof static variable that was declared when
MTX_PROFILE was enabled.  This variable was only used in lock.c so it
is now initialized in that file only.

ASTERISK-26480 #close

Change-Id: I1074af07d71f9e159c48ef36631aa432c86f9966
2016-10-27 09:53:55 -04:00
Corey Farrell 824a4e84d1 Refactor usage pattern of xmldoc info tag.
This updates func_channel.c and main/message.c to use a generic xpointer
include instead of including info from each channel driver.  Now the
name attribute of info is CHANNEL or CHANNEL_EXAMPLES to be included in
documentation for func_channel.  Setting the name attribute of info to
MessageToInfo or MessageFromInfo causes it to be included in the
MessageSend application and AMI action.

Change-Id: I89fd8276a3250824241a618009714267d3a8d1ea
2016-08-16 10:42:46 -05:00
Matt Jordan ddab42e296 func_channel: Reorganize documentation
* Following the example of the PJSIP channel driver, the channel
  technology specific documentation has been moved to the respective
  channel drivers that provide that functionality. This has the benefit
  of locating the documentation of items with those modules that provide
  it.

* Examples of using the CHANNEL function for both standard items as well
  as for PJSIP have been added.

* The 'max_forwards' standard item has been documented.

Change-Id: Ifaa79a232c8ac99cf8da6ef6cc7815d398b1b79b
2016-08-15 07:39:19 -05:00
David M. Lee feb1a43412 Portably sscanf tv_usec
In a timeval, tv_usec is defined as a suseconds_t, which could be
different underlying types on different platforms. Instead of trying to
scanf directly into the timeval, scanf into a long int, then copy that
into the timeval.

Change-Id: I29f22d049d3f7746b6c0cc23fbf4293bdaa5eb95
2016-07-27 13:09:01 -05:00
Corey Farrell cf1188a1be Unit tests: Use AST_TEST_DEFINE in conditional code only.
If AST_TEST_DEFINE is not conditional to TEST_FRAMEWORK it produces dead
code.  This places all existing unit tests into a conditional block if
they weren't already.

ASTERISK-26211 #close

Change-Id: I8ef83ee11cbc991b07b7a37ecb41433e8c734686
2016-07-18 19:40:22 -04:00
Joshua Colp 4ad333bb0e func_odbc: Fix connection deadlock.
The func_odbc module was modified to ensure that the
previous behavior of using a single database connection
was maintained. This was done by getting a single database
connection and holding on to it. With the new multiple
connection support in res_odbc this will actually starve
every other thread from getting access to the database as
it also maintains the previous behavior of having only
a single database connection.

This change disables the func_odbc specific behavior if
the res_odbc module is running with only a single database
connection active. The connection is only kept for the
duration of the request.

ASTERISK-26177 #close

Change-Id: I9bdbd8a300fb3233877735ad3fd07bce38115b7f
2016-07-12 05:00:16 -05:00
George Joseph 651290a809 BuildSystem: Fix a few issues hightlighted by gcc 6.x
gcc 6.1.1 caught a few more issues.
Made sure the unit tests still pass for the func_env and stdtime
issues.

ASTERISK-26157 #close

Change-Id: I6664d8f34a45bc1481d2a854481c7878b0c1cf8e
2016-06-28 12:40:49 -05:00
Alexei Gradinari c378b00a83 func_odbc: single database connection should be optional
func_odbc was changed in Asterisk 13.9.0
to make func_odbc use a single database connection per DSN
because of reported bug ASTERISK-25938
with MySQL/MariaDB LAST_INSERT_ID().

This is drawback in performance when func_odbc is used
very often in dialplan.

Single database connection should be optional.

ASTERISK-26010

Change-Id: I7091783a7150252de8eeb455115bd00514dfe843
2016-05-20 13:46:03 -04:00
Mark Michelson 2b150f0b80 func_odbc: Check connection status before executing queries.
A recent change to func_odbc made it so that a single connection was
maintained per DSN. The problem was that the code was optimistic about
the health of the connection after initially opening it and did nothing
to re-connect in case the connection had died.

This change adds a check before executing a query to ensure that the
connection to the database is still up and running.

ASTERISK-25963 #close
Reported by Ross Beer

Change-Id: Id33c86eb04ff48ca088bb2e3086c27b3b683491d
2016-04-27 13:33:40 -05:00
Mark Michelson 924738e950 func_odbc: Use one connection per DSN.
res_odbc was changed in Asterisk 13.8.0 to remove connection management,
opting instead to let unixodbc maintain open connections and return
those to Asterisk as requested.

This was a boon for realtime, since it meant that multiple threads could
potentially run parallel queries since they could each be using their
own database connections.

However, on the user-facing side, func_odbc, there were some inherent
behaviors being relied on that no longer hold true after the change.
One such reported behavior was that MySQL's LAST_INSERTED_ID() works
per-connection. This means that if Asterisk uses separate connections
for every database operation, whereas before it used one connection for
everything, we have broken expectations and functionality.

The fix provided in this patch is to make func_odbc use a single
database connection per DSN. This way, user-facing database usage will
have the same behavior as it did pre-13.8.0. However, realtime, which is
the real workhorse of database interaction, will continue to let
unixodbc manage connections.

ASTERISK-25938 #close
Reported by Edwin Vandamme

Change-Id: Iac961fe79154c6211569afcdfec843c0c24c46dc
2016-04-22 14:31:54 -05:00
Matthew Jordan 6bbcfb34bd funcs/func_curl: Add the ability for CURL to download and store files
This patch adds a write option to the CURL dialplan function, allowing it to
CURL files and store them locally. The value 'written' to the CURL URL
specifies the location on disk to store the file. As an example:

same => n,Set(CURL(http://1.1.1.1/foo.wav)=/tmp/foo.wav)

Would retrieve the file foo.wav from the remote server and store it in the
/tmp directory.

Due to the potentially dangerous nature of this function call, APIs are
forbidden from using the write functionality unless live_dangerously is set
to True in asterisk.conf.

ASTERISK-25652 #close

Change-Id: I44f4ad823d7d20f04ceaad3698c5c7f653c41b0d
2016-03-23 11:46:32 -03:00
Gianluca Merlo 8f94f947f5 func_aes: fix misuse of strlen on binary data
The encryption code for AES_ENCRYPT evaluates the length of the data to
be encoded in base64 using strlen. The data is binary, thus the length
of it can be underestimated at the first NULL character.
Reuse the write pointer offset to evaluate it, instead.

ASTERISK-25857 #close

Change-Id: If686b5d570473eb926693c73461177b35b13b186
2016-03-18 22:04:18 -05:00
Richard Mudgett 0bdbf0d882 func_callerid.c: Update REDIRECTING reason documentation.
Change-Id: I6e8d39b0711110a4bceafa652e58b30465e28386
2016-03-01 20:22:06 -06:00
Sean Bright e5fd972d24 func_iconv: Ensure output strings are properly terminated.
ASTERISK-25272 #close
Reported by: Etienne Lessard
patches:
 AST-25272.patch submitted by Etienne Lessard (license #6394)

Change-Id: Id75ad202300960a1e91afe15e319d992936ecc17
2016-02-11 11:26:03 -06:00
Mark Michelson 9714da7aa4 res_odbc: Remove connection management
Asterisk by default will create a single database connection and share
it among all threads that attempt to access the database. In previous
versions of Asterisk, this was tolerable, because the most used channel
driver, chan_sip, mostly accessed the database from a single thread.
With PJSIP, however, many threads may be attempting to perform database
operations, and there is the potential for many more database accesses,
meaning the concurrency is a horrible bottleneck if only one connection
is shared.

Asterisk has a connection pooling facility built into it, but the
implementation has flaws. For one, there is a strict limit on the number
of simultaneous connections that could be made to the database. Anything
beyond the maximum would result in a failed operation. Attempting to
predict what the maximum should be is nearly impossible even for someone
intimately familiar with Asterisk's threading model. In addition, use of
transactions in the dialplan can cause some severe bugs if connection
pooling is enabled.

This commit seeks to fix the concurrency problem by removing all
connection management code from Asterisk and leaving that to the
underlying unixODBC code instead. Now, Asterisk does not share a single
connection, nor does it try to maintain a connection pool. Instead, all
Asterisk ever does is request a connection from unixODBC and allow
unixODBC to either allocate those connections or retrieve them from a
pool.

Doing this has a bit of a ripple effect. For one, since connections are
not long-lived objects, several of the safeguards that previously
existed have been removed. We don't have to worry about trying to use a
connection that has gone stale. In every case, when we request a
connection, it has just been made and we don't need to perform any
sanity checks to be sure it's still active.

Another major player affected by this change is transactions.
Transactions and their respective connections were so tightly coupled
that it was almost pornographic. This code change moves
transaction-related code to its own file separate from the core ODBC
functionality. This way, the core of ODBC does not even have to know
that transactions exist.

In making this large change, I had to look at a lot of code and
understand it. When making this change, I discovered several places
where the behavior is definitely not ideal, but it seemed outside the
scope of this change to be fixing it. Instead, any place where I saw
some sort of room for improvement has had a XXX comment added explaining
what could be altered to improve it.

Change-Id: I37a84def5ea4ddf93868ce8105f39de078297fbf
2016-01-22 11:59:06 -06:00
Matt Jordan 3b9cba4294 funcs/func_cdr: Correctly report high precision values for duration and billsec
When CDRs were refactored, func_cdr's ability to report high precision values
for duration and billsec (the 'f' option) was broken. This was due to func_cdr
incorrectly interpreting the duration/billsec values provided by the CDR engine
in milliseconds, as opposed to seconds. Since the CDR engine only provides
duration and billsec in seconds, and does not expose either attribute with
sufficient precision to merely pass back the underlying value, this patch fixes
the bug by re-calculating duration and billsec with microsecond precision based
on the start/answer/end times on the CDR.

ASTERISK-25179 #close

Change-Id: I8bc63822b496537a5bf80baf6102c06206bee841
2016-01-20 08:11:44 -06:00
Rusty Newton 68cad96ffd func_channel: Add help text for undocumented CHANNEL function arguments
Adding help text documentation for:
* hangupsource
* appname
* appdata
* exten
* context
* channame
* uniqueid
* linkedid

ASTERISK-24097 #close
Reported by: Steven T. Wheeler
Tested by: Rusty Newton

Change-Id: Ib94b00568b0433987df87d5b67ea529b5905754d
2016-01-14 09:26:15 -06:00
Joshua Colp 0be147f713 Merge "ast_format_cap_get_names: To display all formats, the buffer was increased." 2015-11-10 14:58:18 -06:00
Alexander Traud cf79b62778 ast_format_cap_get_names: To display all formats, the buffer was increased.
ASTERISK-25533 #close

Change-Id: Ie1a9d1a6511b3f1a56b93d04475fbf8a4e40010a
2015-11-09 16:58:52 +01:00
Walter Doekes 7dd8f89a50 func_callerid: Document that CALLERID(pres) is available.
CALLERPRES() says that it's deprecated in favor of CALLERID(num-pres)
and CALLERID(name-pres).  But for channel driver that don't make a
distinction between the two (e.g. SIP), it makes more sense to get/set
both at once.  This change reveals the availability of CALLERID(pres),
CONNECTEDLINE(pres), REDIRECTING(orig-pres), REDIRECTING(to-pres) and
REDIRECTING(from-pres).

ASTERISK-25373 #close

Change-Id: I5614ae4ab7d3bbe9c791c1adf147e10de8698d7a
2015-11-06 18:03:47 -05:00
Matt Jordan 7be6194d6f funcs/func_holdintercept: Actually add the HOLD_INTERCEPT function
When ab803ec342 was committed, it accidentally forgot to actually *add* the
HOLD_INTERCEPT function. This highlights two interesting points:
* Gerrit forces you to put the patch as it is going to into the repo up for
  review, which Review Board did not. Yay Gerrit.
* No one apparently bothered to use this feature, or else they don't know about
  it. I'm going to go with the latter explanation.

ASTERISK-24922

Change-Id: Ida38278f259dd07c334a36f9b7d5475b5db72396
2015-10-20 22:24:00 -05:00
Ivan Poddubny c944263e36 func_presencestate: Return "not_set" when no data is set in AstDB
Return AST_PRESENCE_NOT_SET when CustomPresence AstDB key does not
exist, i.e. when a new CustomPresence is added in the dialplan.

ASTERISK-25400 #close
Reported by: Andrew Nagy

Change-Id: I6fb17b16591b5a55fbffe96f3994ec26b1b1723a
2015-10-07 09:24:31 +03:00
Rusty Newton d02196448b Documentation: A couple of trivial fixes in sip.conf.sample and func_cdr.c
* In sip.conf.sample fix sentence where we said that WS or WSS are supported
   transports for use in an outbound register definition. They are not
   supported in that case.
 * In func_cdr.c made it clear that the Disable option for CDR_PROP can be used
   to enable CDR on a channel.

ASTERISK-24867 #close
Reported by: Rusty Newton

ASTERISK-24853 #close
Reported by: PSDK

Change-Id: I3d698bc6302b9d00a0a995b5c4ad9a42d69b48ca
2015-07-20 12:39:48 -05:00
Corey Farrell ea9d5f155e func_pjsip_aor: Fix leaked contact from iterator.
ASTERISK-25162 #close

Change-Id: Id79aa3c6fe490016ee98efc97ac4c1d3f461f97e
2015-06-15 17:14:56 -05:00
Corey Farrell 0a46d43b9c Fix potential crash after unload of func_periodic_hook or test_message.
These modules save a pointer to the context they create on load, and
use that pointer to destroy the context at unload.  It is not safe
to save this pointer, it is replaced during load of pbx_config,
pbx_lua or pbx_ael.

This change causes the modules to pass NULL to ast_context_destroy,
a safer way to perform the unregistration since it does not use
a pointer that could become invalid.

ASTERISK-25085 #close
Reported by: Corey Farrell

Change-Id: I6a00ec8e38046058f97dc703e1adcde9bf517835
2015-05-14 05:41:30 -05:00
Rodrigo Ramírez Norambuena eec010829a AST_MODULE_INFO: Format corrections to the usages of AST_MODULE_INFO macro.
Change-Id: Icf88f9f861c6b2a16e5f626ff25795218a6f2723
2015-05-13 16:34:23 -05:00
George Joseph 298faf7c50 pjsip_options: Fix non-qualified contacts showing as unavailable
The "Add qualify_timeout processing and eventing" patch introduced
an issue where contacts that had qualify_frequency set to 0 were
showing Unavailable instead Unknown.  This patch checks for
qualify_frequency=0 and create an "Unknown"  contact_status
with an RTT = 0.

Previously, the lack of contact_status implied Unknown but since
we're now changing endpoint state based on contact_status, I've
had to add new UNKNOWN status so that changes could trigger the
appropriate contact_status observers.

ASTERISK-24977: #close

Change-Id: Ifcbc01533ce57f0e4e584b89a395326e098b8fe7
2015-04-19 20:07:45 -05:00
Mark Michelson aae45acbda Detect potential forwarding loops based on count.
A potential problem that can arise is the following:

* Bob's phone is programmed to automatically forward to Carol.
* Carol's phone is programmed to automatically forward to Bob.
* Alice calls Bob.

If left unchecked, this results in an endless loops of call forwards
that would eventually result in some sort of fiery crash.

Asterisk's method of solving this issue was to track which interfaces
had been dialed. If a destination were dialed a second time, then
the attempt to call that destination would fail since a loop was
detected.

The problem with this method is that call forwarding has evolved. Some
SIP phones allow for a user to manually forward an incoming call to an
ad-hoc destination. This can mean that:

* There are legitimate use cases where a device may be dialed multiple
times, or
* There can be human error when forwarding calls.

This change removes the old method of detecting forwarding loops in
favor of keeping a count of the number of destinations a channel has
dialed on a particular branch of a call. If the number exceeds the
set number of max forwards, then the call fails. This approach has
the following advantages over the old:

* It is much simpler.
* It can detect loops involving local channels.
* It is user configurable.

The only disadvantage it has is that in the case where there is a
legitimate forwarding loop present, it takes longer to detect it.
However, the forwarding loop is still properly detected and the
call is cleaned up as it should be.

Address review feedback on gerrit.

* Correct "mfgium" to "Digium"
* Decrement max forwards by one in the case where allocation of the
  max forwards datastore is required.
* Remove irrelevant code change from pjsip_global_headers.c

ASTERISK-24958 #close

Change-Id: Ia7e4b7cd3bccfbd34d9a859838356931bba56c23
2015-04-17 15:58:07 -05:00
Matt Jordan 4a58261694 git migration: Refactor the ASTERISK_FILE_VERSION macro
Git does not support the ability to replace a token with a version
string during check-in. While it does have support for replacing a
token on clone, this is somewhat sub-optimal: the token is replaced
with the object hash, which is not particularly easy for human
consumption. What's more, in practice, the source file version was often
not terribly useful. Generally, when triaging bugs, the overall version
of Asterisk is far more useful than an individual SVN version of a file. As a
result, this patch removes Asterisk's support for showing source file
versions.

Specifically, it does the following:

* Rename ASTERISK_FILE_VERSION macro to ASTERISK_REGISTER_FILE, and
  remove passing the version in with the macro. Other facilities
  than 'core show file version' make use of the file names, such as
  setting a debug level only on a specific file. As such, the act of
  registering source files with the Asterisk core still has use. The
  macro rename now reflects the new macro purpose.

* main/asterisk:
  - Refactor the file_version structure to reflect that it no longer
    tracks a version field.
  - Remove the "core show file version" CLI command. Without the file
    version, it is no longer useful.
  - Remove the ast_file_version_find function. The file version is no
    longer tracked.
  - Rename ast_register_file_version/ast_unregister_file_version to
    ast_register_file/ast_unregister_file, respectively.

* main/manager: Remove value from the Version key of the ModuleCheck
  Action. The actual key itself has not been removed, as doing so would
  absolutely constitute a backwards incompatible change. However, since
  the file version is no longer tracked, there is no need to attempt to
  include it in the Version key.

* UPGRADE: Add notes for:
  - Modification to the ModuleCheck AMI Action
  - Removal of the "core show file version" CLI command

Change-Id: I6cf0ff280e1668bf4957dc21f32a5ff43444a40e
2015-04-13 03:48:57 -04:00
Matthew Jordan ea0098724e clang compiler warnings: Fix autological comparisons
This fixes autological comparison warnings in the following:
 * chan_skinny: letohl may return a signed or unsigned value, depending on the
   macro chosen
 * func_curl: Provide a specific cast to CURLoption to prevent mismatch
 * cel: Fix enum comparisons where the enum can never be negative
 * enum: Fix comparison of return result of dn_expand, which returns a signed
   int value
 * event: Fix enum comparisons where the enum can never be negative
 * indications: tone_data.freq1 and freq2 are unsigned, and hence can never be
   negative
 * presencestate: Use the actual enum value for INVALID state
 * security_events: Fix enum comparisons where the enum can never be negative
 * udptl: Don't bother to check if the return value from encode_length is less
   than 0, as it returns an unsigned int
 * translate: Since the parameters are unsigned int, don't bother checking
   to see if they are negative. The cast to unsigned int would already blow
   past the matrix bounds.
 * res_pjsip_exten_state: Use a temporary value to cache the return of
   ast_hint_presence_state
 * res_stasis_playback: Fix enum comparisons where the enum can never be
   negative
 * res_stasis_recording: Add an enum value for the case where the recording
   operation is in error; fix enum comparisons
 * resource_bridges: Use enum value as opposed to -1
 * resource_channels: Use enum value as opposed to -1

Review: https://reviewboard.asterisk.org/r/4533
ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4533.patch submitted by dkdegroot (License 6600)
........

Merged revisions 434469 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 434470 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434471 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-09 12:57:21 +00:00
Matthew Jordan af4d802773 clang compiler warnings: Fix sometimes-initialized warning in func_math
This patch fixes a bug in a unit test in func_math where a variable could be
passed to ast_free that wasn't allocated. This patch corrects the issue and
ensures that we only attempt to free a variable if we previously allocated
it.

Review: https://reviewboard.asterisk.org/r/4552

ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4552.patch submitted by dkdegroot (License 6600)
........

Merged revisions 434190 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 434191 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434192 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-07 02:10:31 +00:00
Matthew Jordan d2776d4d45 clang compiler warnings: Fix a variety of "unused" warnings
This patch fixes the -Wunused-value -Wunused-variable -Wunused-const-variable
errors caught by clang. Specifically:

* apps/app_queue.c: removed unused qpm_cmd_usage[], qum_cmd_usage[],
                    qsmp_cmd_usage[]
* cel/cel_sqlite3_custom.c: removed unused name[] = "cel_sqlite3_custom"
* channels/chan_pjsip.c: removed unused desc[] = "PJSIP Channel"
* codecs/gsm/src/gsm_create.c: removed unused ident[] = "$Header$"
* funcs/func_env.c:729: Fixed ast_str_append_substr.
* main/editline/np/strlcat.c: removed unused rcsid variable
* main/editline/np/strlcpy.c: removed unused rcsid variable
* main/security_events.c: removed unused TIMESTAMP_STR_LEN
* utils/conf2ael.c: removed unused cfextension_states
* utils/extconf.c: removed unused cfextension_states

Review: https://reviewboard.asterisk.org/r/4526

ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4526.patch submitted by dkdegroot (License 6600)
........

Merged revisions 433693 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433694 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433695 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-28 12:56:43 +00:00
Matthew Jordan 60f01520e7 Fix compilations errors on 64-bit OpenBSD systems
In versiong 5.5, OpenBSD went to 64-bit time values. This requires a cast to
(long) when printing members of certain time structs.

Review: https://reviewboard.asterisk.org/r/4507

ASTERISK-24879 #close
Reported by: snuffy
Tested by: snuffy
patches:
  openbsd-time64.diff uploaded by snuffy (License 5024)
........

Merged revisions 433268 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433269 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433270 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-23 00:05:48 +00:00
Matthew Jordan 627cc16a8d funcs/func_env: Fix regression caused in FILE read operation
When r432935 was merged, it did correctly fix a situation where a FILE read
operation on the middle of a file buffer would not read the requested length
in the parameters passed to the FILE function. Unfortunately, it would also
allow the FILE function to append more bytes than what was available in the
buffer if the length exceeded the end of the buffer length.

This patch takes the minimum of the remaining bytes in the buffer along with
the calculated length to append provided by the original patch, and uses
that as the length to append in the return result. This patch also updates
the unit tests with the scenarios that were originally pointed out in
ASTERISK-21765 that the original implementation treated incorrectly.

ASTERISK-21765
........

Merged revisions 433173 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433174 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433175 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-19 19:20:21 +00:00
Joshua Colp 0d52907d2b func_curl: Don't hold exclusive lock when performing HTTP request.
This code originally kept a lock held when performing the HTTP
request to ensure that the options provided to curl remain valid.
This doesn't seem to be necessary these days and holding the lock
caused requests to happen sequentially instead of in parallel.

ASTERISK-18708 #close
Reported by: Dave Cabot
........

Merged revisions 432948 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432949 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432950 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-14 02:01:12 +00:00
Matthew Jordan b4cc056067 FILE: fix retrieval of file contents when offset is specified
The loop that reads in a file was not correctly using the offset when
determining what bytes to append to the output. This patch corrects
the logic such that the correct portion of the file is extracted when an
offset is specified.

ASTERISK-21765
Reported by: John Zhong
Tested by: Matt Jordan, Di-Shi Sun
patches:
  file_read_390821.patch uploaded by Di-Shi Sun (License 5076)
........

Merged revisions 432935 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432938 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432940 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-14 01:22:01 +00:00
Mark Michelson 3cccfac399 Multiple revisions 431297-431298
........
  r431297 | mmichelson | 2015-01-28 11:05:26 -0600 (Wed, 28 Jan 2015) | 17 lines
  
  Mitigate possible HTTP injection attacks using CURL() function in Asterisk.
  
  CVE-2014-8150 disclosed a vulnerability in libcURL where HTTP request injection
  can be performed given properly-crafted URLs.
  
  Since Asterisk makes use of libcURL, and it is possible that users of Asterisk may
  get cURL URLs from user input or remote sources, we have made a patch to Asterisk
  to prevent such HTTP injection attacks from originating from Asterisk.
  
  ASTERISK-24676 #close
  Reported by Matt Jordan
  
  Review: https://reviewboard.asterisk.org/r/4364
  
  AST-2015-002
........
  r431298 | mmichelson | 2015-01-28 11:12:49 -0600 (Wed, 28 Jan 2015) | 3 lines
  
  Fix compilation error from previous patch.
........

Merged revisions 431297-431298 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 431299 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 431301 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431302 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-28 17:34:57 +00:00
David M. Lee 965777ccfc Various fixes for OS X
This patch addresses compilation errors on OS X. It's been a while, so
there's quite a few things.

 * Fixed __attribute__ decls in route.h to be portable.
 * Fixed htonll and ntohll to work when they are defined as macros.
 * Replaced sem_t usage with our ast_sem wrapper.
 * Added ast_sem_timedwait to our ast_sem wrapper.
 * Fixed some GCC 4.9 warnings using sig*set() functions.
 * Fixed some format strings for portability.
 * Fixed compilation issues with res_timing_kqueue (although tests still fail
   on OS X).
 * Fixed menuconfig /sbin/launchd detection, which disables res_timing_kqueue
   on OS X).

ASTERISK-24539 #close
Reported by: George Joseph

ASTERISK-24544 #close
Reported by: George Joseph

Review: https://reviewboard.asterisk.org/r/4327/
........

Merged revisions 431092 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431093 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-26 14:50:40 +00:00
Walter Doekes 49cbfa7de6 Fix typo's (retrieve, specified, address).
........

Merged revisions 430996 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 430998 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431000 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-23 15:13:08 +00:00
Richard Mudgett e4738a59eb CHANNEL(peer), chan_iax2, res_fax, SNMP agent: Fix deadlock from reaching across a bridge.
Calling ast_channel_bridge_peer() cannot be done while holding any channel
locks.  The reported issue hit the deadlock in chan_iax2, but an audit of
the ast_channel_bridge_peer() calls found three more locations where the
same deadlock can occur.

* Made CHANNEL(peer), res_fax, and the SNMP agent not call
ast_channel_bridge_peer() with any channel locked.  For CHANNEL(peer) I
had to rework the logic to not hold the channel lock.

* Made chan_iax2 no longer call ast_channel_bridge_peer().  It was done
for legacy reasons that no longer apply.

* Removed the iax.conf forcejitterbuffer option.  It is now always enabled
when the jitterbuffer option is enabled.  If you put a jitter buffer on a
channel it will be on the channel.

ASTERISK-24600 #close
Reported by: Jeff Collell

Review: https://reviewboard.asterisk.org/r/4342/
........

Merged revisions 430817 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430819 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-20 16:59:30 +00:00
Matthew Jordan b38acbce6e funcs/func_curl: Fix memory leak when CURLOPT channel datastore is destroyed
When the channel datastore associated with the usage of CURLOPT on a specific
channel is freed, the underlying structure holding the list of options is not
disposed of. This patch properly frees the structure in the datastore .destroy
callback.

ASTERISK-24672 #close
Reported by: Kristian Hogh
patches:
  func_curl-memory-leak.diff uploaded by Kristian Hogh (License 6639)
........

Merged revisions 430487 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 430488 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430489 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-12 15:18:24 +00:00
George Joseph 685f7ef924 func_config: Add ability to retrieve specific occurrence of a variable
I guess nobody uses templates with AST_CONFIG because today if you have a
context that inherits from a template and you call AST_CONFIG on the context,
you'll get the value from the template even if you've overridden it in the
context.  This is because AST_CONFIG only gets the first occurrence which is
always from the template.

This patch adds an optional 'index' parameter to AST_CONFIG which lets you
specify the exact occurrence to retrieve, or '-1' to retrieve the last.
The default behavior is the current behavior.

Tested-by: George Joseph

Review: https://reviewboard.asterisk.org/r/4313/
........

Merged revisions 430315 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430316 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-07 17:54:13 +00:00
Joshua Colp f7cf988a82 pjsip: Add 'PJSIP_AOR' and 'PJSIP_CONTACT' dialplan functions.
The PJSIP_AOR dialplan function allows inspection of configured AORs including
what contacts are currently bound to them.

The PJSIP_CONTACT dialplan function allows inspection of contacts in existence.
These can include both externally added (by way of registration) or permanent
ones.

ASTERISK-24341
Reported by: xrobau

Review: https://reviewboard.asterisk.org/r/4308/
........

Merged revisions 430179 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430180 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-05 17:53:42 +00:00
Kevin Harwell 2486b48cec AST-2014-018 - func_db: DB Dialplan function permission escalation via AMI.
The DB dialplan function when executed from an external protocol (for instance
AMI), could result in a privilege escalation.

Asterisk now inhibits the DB function from being executed from an external
interface if the live_dangerously option is set to no.

ASTERISK-24534
Reported by: Gareth Palmer
patches: submitted by Gareth Palmer (license 5169)
........

Merged revisions 428331 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 428363 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 428409 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 428413 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@428418 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-20 16:35:21 +00:00
Corey Farrell 97e1c7f3a9 func_talkdetect: Fix stasis message leak in audiohook callback.
ASTERISK-24482 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4142/
........

Merged revisions 427203 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 427204 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@427205 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-04 19:46:33 +00:00
Corey Farrell ab16f46139 func_cdr: Fix CDR_PROP payload leak
Remove duplicate allocation of payload, preventing leak.

ASTERISK-24455 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4113/
........

Merged revisions 426252 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@426253 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-28 11:12:03 +00:00
Richard Mudgett 0165c5f95a chan_pjsip: Fix deadlock when masquerading PJSIP channels.
Performing a directed call pickup resulted in a deadlock when PJSIP
channels were involved.

A masquerade needs to hold onto the channel locks while it swaps channel
information between the two channels involved in the masquerade.  With
PJSIP channels, the fixup routine needed to push a fixup task onto the
PJSIP channel's serializer.  Unfortunately, if the serializer was also
processing a task that needed to lock the channel, you get deadlock.

* Added a new control frame that is used to notify the channels that a
masquerade is about to start and when it has completed.

* Added the ability to query taskprocessors if the current thread is the
taskprocessor thread.

* Added the ability to suspend/unsuspend the PJSIP serializer thread so a
masquerade could fixup the PJSIP channel without using the serializer.

ASTERISK-24356 #close
Reported by: rmudgett

Review: https://reviewboard.asterisk.org/r/4034/
........

Merged revisions 424471 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 424472 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@424473 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-03 17:47:42 +00:00
Walter Doekes 37179a2b1f core: Don't allow free to mean ast_free (and malloc, etc..).
This gets rid of most old libc free/malloc/realloc and replaces them
with ast_free and friends. When compiling with MALLOC_DEBUG you'll
notice it when you're mistakenly using one of the libc variants. For
the legacy cases you can define WRAP_LIBC_MALLOC before including
asterisk.h.

Even better would be if the errors were also enabled when compiling
without MALLOC_DEBUG, but that's a slightly more invasive header
file change.

Those compiling addons/format_mp3 will need to rerun
./contrib/scripts/get_mp3_source.sh.

ASTERISK-24348 #related
Review: https://reviewboard.asterisk.org/r/4015/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@423978 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-26 14:41:38 +00:00
Richard Mudgett 9183416fe2 func_channel: Add CHANNEL(onhold) item to get the current hold status of the channel.
It would be useful to get the current hold status of a channel.

Added CHANNEL(onhold) item that returns 1 (onhold) and 0 (not-onhold) for
the hold status of a channel.

ASTERISK-24038
Reported by: Matt Jordan

AFS-113 #close
Reported by: Mark Michelson

Review: https://reviewboard.asterisk.org/r/3983/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@422870 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-09 16:14:02 +00:00
Richard Mudgett 025bd1bf3f func_channel.c: Add missing locking to some CHANNEL() requests.
* The CHANNEL() audionativeformat, videonativeformat, audioreadformat, and
audiowriteformat now need locking since the media format rework when
accessing the channel's format pointers.

* Increased the buffer size for CHANNEL() audionativeformat and
videonativeformat output strings since the allow=all can be a lengthy
list.

* Tweaked the CHANNEL() XML documentation for secure_bridge_signaling,
secure_bridge_media, and state.

* Ensured the output buffer is initialized for secure_bridge_signaling and
secure_bridge_media.

* Made use the locked_copy_string() macro instead of inlining it for trace
and checkhangup.
........

Merged revisions 422700 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@422701 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-05 20:38:27 +00:00
George Joseph 1de8b8035e func_config: Change 'Not Found' message from ERROR to DEBUG
When you call the CONFIG dialplan function with the name of a variable that
doesn't exist in the target context you get an ERROR.  This does nothing but
clutter up the logs with messages that may be perfectly acceptable.  Just
because a variable wasn't in the context doesn't mean it's an error.  Maybei
t's optional or just needs to be defaulted or ignored.

This patch changes the log level from ERROR to DEBUG.  If a dialplan developer
wants to debug their dialplan they still canby setting the console debug level 
as needed.

Tested by: George Joseph
Review: https://reviewboard.asterisk.org/r/3919/
........

Merged revisions 421327 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 421328 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 421329 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 421337 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@421341 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-08-18 20:20:59 +00:00
Matthew Jordan 6650704414 funcs/func_jitterbuffer: Tweak documentation
This patch merely reformats and cleans up a bit of the jitterbuffer
documentation for the wiki.
........

Merged revisions 420639 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420640 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-08-11 01:31:56 +00:00
Walter Doekes 8610daec3b Add documentation to the ability to retrieve the source port of a SIP call.
(belongs with r419970)

ASTERISK-24040 #close
Patches:
	func_channel.c.diff uploaded by dtryba

Review: https://reviewboard.asterisk.org/r/3781/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420144 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-08-06 15:32:22 +00:00
Kinsey Moore f1036f40dc Stasis: Allow message types to be blocked
This introduces stasis.conf and a mechanism to prevent certain message
types from being published. Internally, this works by preventing the
chosen message types from being created which ensures that those
message types can never be published. This patch also adjusts message
publishers such that message payloads are not created if the related
message type is not available.

ASTERISK-23943 #close
Review: https://reviewboard.asterisk.org/r/3823/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420124 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-08-06 12:55:28 +00:00
Matthew Jordan 922e3203a9 xmldocs: Add support for an <example> tag in the Asterisk XML Documentation
This patch adds support for an <example /> tag in the XML documentation schema.

For CLI help, this doesn't change the formatting too much:
 - Preceeding white space is removed
 - Unlike with para elements, new lines are preserved

However, having an <example /> tag in the XML schema allows for the wiki
documentation generation script to surround the documentation with {code} or
{noformat} tags, generating much better content for the wiki - and allowing us
to put dialplan examples (and other code snippets, if desired) into the
documentation for an application/function/AMI command/etc.

Review: https://reviewboard.asterisk.org/r/3807/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419822 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-31 11:49:40 +00:00
Richard Mudgett 2758cc76e5 datastores: Audit ast_channel_datastore_remove usage.
Audit of v1.8 usage of ast_channel_datastore_remove() for datastore memory
leaks.

* Fixed leaks in app_speech_utils and func_frame_trace.

* Fixed app_speech_utils not locking the channel when accessing the
channel datastore list.

Review: https://reviewboard.asterisk.org/r/3859/

Audit of v11 usage of ast_channel_datastore_remove() for datastore memory
leaks.

* Fixed leak in func_jitterbuffer.  (Was not in v12)

Review: https://reviewboard.asterisk.org/r/3860/

Audit of v12 usage of ast_channel_datastore_remove() for datastore memory
leaks.

* Fixed leaks in abstract_jb.

* Fixed leak in ast_channel_unsuppress().  Used by ARI mute control and
res_mutestream.

* Fixed ref leak in ast_channel_suppress().  Used by ARI mute control and
res_mutestream.

Review: https://reviewboard.asterisk.org/r/3861/
........

Merged revisions 419684 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 419685 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 419686 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419688 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-28 18:58:43 +00:00
Mark Michelson dcf1ad14da Add module support level to ast_module_info structure. Print it in CLI "module show" .
ASTERISK-23919 #close
Reported by Malcolm Davenport

Review: https://reviewboard.asterisk.org/r/3802



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419592 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-25 16:47:17 +00:00
Matthew Jordan a2c912e997 media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
 1. Asterisk was limited in how many formats it could handle.
 2. Formats, being a bit field, could not include any attribute information.
    A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.

Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.

Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.

Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.

Generally, the new philosophy for handling formats is as follows:
 * The ast_format structure is reference counted. This removed a large amount
   of the memory allocations and copying that was done in prior versions.
 * In order to prevent race conditions while keeping things performant, the
   ast_format structure is immutable by convention and lock-free. Violate this
   tenet at your peril!
 * Because formats are reference counted, codecs are also reference counted.
   The Asterisk core generally provides built-in codecs and caches the
   ast_format structures created to represent them. Generally, to prevent
   inordinate amounts of module reference bumping, codecs and formats can be
   added at run-time but cannot be removed.
 * All compatibility with the bit field representation of codecs/formats has
   been moved to a compatibility API. The primary user of this representation
   is chan_iax2, which must continue to maintain its bit-field usage of formats
   for interoperability concerns.
 * When a format is negotiated with attributes, or when a format cannot be
   represented by one of the cached formats, a new format object is created or
   cloned from an existing format. That format may have the same codec
   underlying it, but is a different format than a version of the format with
   different attributes or without attributes.
 * While formats are reference counted objects, the reference count maintained
   on the format should be manipulated with care. Formats are generally cached
   and will persist for the lifetime of Asterisk and do not explicitly need
   to have their lifetime modified. An exception to this is when the user of a
   format does not know where the format came from *and* the user may outlive
   the provider of the format. This occurs, for example, when a format is read
   from a channel: the channel may have a format with attributes (hence,
   non-cached) and the user of the format may last longer than the channel (if
   the reference to the channel is released prior to the format's reference).

For more information on this work, see the API design notes:
  https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite

Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.

There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).

Reviews:
 https://reviewboard.asterisk.org/r/3814
 https://reviewboard.asterisk.org/r/3808
 https://reviewboard.asterisk.org/r/3805
 https://reviewboard.asterisk.org/r/3803
 https://reviewboard.asterisk.org/r/3801
 https://reviewboard.asterisk.org/r/3798
 https://reviewboard.asterisk.org/r/3800
 https://reviewboard.asterisk.org/r/3794
 https://reviewboard.asterisk.org/r/3793
 https://reviewboard.asterisk.org/r/3792
 https://reviewboard.asterisk.org/r/3791
 https://reviewboard.asterisk.org/r/3790
 https://reviewboard.asterisk.org/r/3789
 https://reviewboard.asterisk.org/r/3788
 https://reviewboard.asterisk.org/r/3787
 https://reviewboard.asterisk.org/r/3786
 https://reviewboard.asterisk.org/r/3784
 https://reviewboard.asterisk.org/r/3783
 https://reviewboard.asterisk.org/r/3778
 https://reviewboard.asterisk.org/r/3774
 https://reviewboard.asterisk.org/r/3775
 https://reviewboard.asterisk.org/r/3772
 https://reviewboard.asterisk.org/r/3761
 https://reviewboard.asterisk.org/r/3754
 https://reviewboard.asterisk.org/r/3753
 https://reviewboard.asterisk.org/r/3751
 https://reviewboard.asterisk.org/r/3750
 https://reviewboard.asterisk.org/r/3748
 https://reviewboard.asterisk.org/r/3747
 https://reviewboard.asterisk.org/r/3746
 https://reviewboard.asterisk.org/r/3742
 https://reviewboard.asterisk.org/r/3740
 https://reviewboard.asterisk.org/r/3739
 https://reviewboard.asterisk.org/r/3738
 https://reviewboard.asterisk.org/r/3737
 https://reviewboard.asterisk.org/r/3736
 https://reviewboard.asterisk.org/r/3734
 https://reviewboard.asterisk.org/r/3722
 https://reviewboard.asterisk.org/r/3713
 https://reviewboard.asterisk.org/r/3703
 https://reviewboard.asterisk.org/r/3689
 https://reviewboard.asterisk.org/r/3687
 https://reviewboard.asterisk.org/r/3674
 https://reviewboard.asterisk.org/r/3671
 https://reviewboard.asterisk.org/r/3667
 https://reviewboard.asterisk.org/r/3665
 https://reviewboard.asterisk.org/r/3625
 https://reviewboard.asterisk.org/r/3602
 https://reviewboard.asterisk.org/r/3519
 https://reviewboard.asterisk.org/r/3518
 https://reviewboard.asterisk.org/r/3516
 https://reviewboard.asterisk.org/r/3515
 https://reviewboard.asterisk.org/r/3512
 https://reviewboard.asterisk.org/r/3506
 https://reviewboard.asterisk.org/r/3413
 https://reviewboard.asterisk.org/r/3410
 https://reviewboard.asterisk.org/r/3387
 https://reviewboard.asterisk.org/r/3388
 https://reviewboard.asterisk.org/r/3389
 https://reviewboard.asterisk.org/r/3390
 https://reviewboard.asterisk.org/r/3321
 https://reviewboard.asterisk.org/r/3320
 https://reviewboard.asterisk.org/r/3319
 https://reviewboard.asterisk.org/r/3318
 https://reviewboard.asterisk.org/r/3266
 https://reviewboard.asterisk.org/r/3265
 https://reviewboard.asterisk.org/r/3234
 https://reviewboard.asterisk.org/r/3178

ASTERISK-23114 #close
Reported by: mjordan
  media_formats_translation_core.diff uploaded by kharwell (License 6464)
  rb3506.diff uploaded by mjordan (License 6283)
  media_format_app_file.diff uploaded by kharwell (License 6464) 
  misc-2.diff uploaded by file (License 5000)
  chan_mild-3.diff uploaded by file (License 5000) 
  chan_obscure.diff uploaded by file (License 5000) 
  jingle.diff uploaded by file (License 5000) 
  funcs.diff uploaded by file (License 5000) 
  formats.diff uploaded by file (License 5000) 
  core.diff uploaded by file (License 5000) 
  bridges.diff uploaded by file (License 5000) 
  mf-codecs-2.diff uploaded by file (License 5000) 
  mf-app_fax.diff uploaded by file (License 5000) 
  mf-apps-3.diff uploaded by file (License 5000) 
  media-formats-3.diff uploaded by file (License 5000) 

ASTERISK-23715
  rb3713.patch uploaded by coreyfarrell (License 5909)
  rb3689.patch uploaded by mjordan (License 6283)
  
ASTERISK-23957
  rb3722.patch uploaded by mjordan (License 6283) 
  mf-attributes-3.diff uploaded by file (License 5000) 

ASTERISK-23958
Tested by: jrose
  rb3822.patch uploaded by coreyfarrell (License 5909) 
  rb3800.patch uploaded by jrose (License 6182)
  chan_sip.diff uploaded by mjordan (License 6283) 
  rb3747.patch uploaded by jrose (License 6182)

ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
  sip_cleanup.diff uploaded by opticron (License 6273)
  chan_sip_caps.diff uploaded by mjordan (License 6283) 
  rb3751.patch uploaded by coreyfarrell (License 5909) 
  chan_sip-3.diff uploaded by file (License 5000) 

ASTERISK-23960 #close
Tested by: opticron
  direct_media.diff uploaded by opticron (License 6273) 
  pjsip-direct-media.diff uploaded by file (License 5000) 
  format_cap_remove.diff uploaded by opticron (License 6273) 
  media_format_fixes.diff uploaded by opticron (License 6273) 
  chan_pjsip-2.diff uploaded by file (License 5000) 

ASTERISK-23966 #close
Tested by: rmudgett
  rb3803.patch uploaded by rmudgetti (License 5621)
  chan_dahdi.diff uploaded by file (License 5000) 
  
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
  rb3814.patch uploaded by rmudgett (License 5621) 
  moh_cleanup.diff uploaded by opticron (License 6273) 
  bridge_leak.diff uploaded by opticron (License 6273) 
  translate.diff uploaded by file (License 5000) 
  rb3795.patch uploaded by rmudgett (License 5621) 
  tls_fix.diff uploaded by mjordan (License 6283) 
  fax-mf-fix-2.diff uploaded by file (License 5000) 
  rtp_transfer_stuff uploaded by mjordan (License 6283) 
  rb3787.patch uploaded by rmudgett (License 5621) 
  media-formats-explicit-translate-format-3.diff uploaded by file (License 5000) 
  format_cache_case_fix.diff uploaded by opticron (License 6273) 
  rb3774.patch uploaded by rmudgett (License 5621) 
  rb3775.patch uploaded by rmudgett (License 5621) 
  rtp_engine_fix.diff uploaded by opticron (License 6273) 
  rtp_crash_fix.diff uploaded by opticron (License 6273) 
  rb3753.patch uploaded by mjordan (License 6283) 
  rb3750.patch uploaded by mjordan (License 6283) 
  rb3748.patch uploaded by rmudgett (License 5621) 
  media_format_fixes.diff uploaded by opticron (License 6273) 
  rb3740.patch uploaded by mjordan (License 6283) 
  rb3739.patch uploaded by mjordan (License 6283) 
  rb3734.patch uploaded by mjordan (License 6283) 
  rb3689.patch uploaded by mjordan (License 6283) 
  rb3674.patch uploaded by coreyfarrell (License 5909) 
  rb3671.patch uploaded by coreyfarrell (License 5909) 
  rb3667.patch uploaded by coreyfarrell (License 5909) 
  rb3665.patch uploaded by mjordan (License 6283) 
  rb3625.patch uploaded by coreyfarrell (License 5909) 
  rb3602.patch uploaded by coreyfarrell (License 5909) 
  format_compatibility-2.diff uploaded by file (License 5000) 
  core.diff uploaded by file (License 5000) 
  


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
Richard Mudgett b71be2112e func_audiohookinherit.c: Fixup some XML documentation wording.
........

Merged revisions 418937 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418938 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-18 16:47:23 +00:00
Jonathan Rose af4cd65143 Channels: Masquerades to automatically move frame/audio hooks
Whenever possible, audiohooks and framehooks will now be copied over
to the channel that the masquerading channel gets cloned into. This
should occur for all audiohooks and most framehooks. As a result,
in Asterisk 12.5 and up, the AUDIOHOOK_INHERIT function is now
deprecated and its behavior is essentially the new default for all
audiohooks, plus some additional audiohooks/framehooks.

Review: https://reviewboard.asterisk.org/r/3721/
........

Merged revisions 418914 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418936 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-18 16:28:10 +00:00
Jonathan Rose 4420ce6e5c func_uri: URIENCODE/URIDECODE - allow empty strings as argument
Previously these two dialplan functions would issue warnings and
return failure when an empty string is used as the argument. Now
they will not issue a warning and will successfully return an
empty string.

ASTERISK-23911 #close
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/3745/
........

Merged revisions 418641 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 418649 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 418650 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418654 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-15 17:57:17 +00:00
Mark Michelson fc52fd8884 Allow the PUSH and UNSHIFT functions to set inheritable channel variables.
........

Merged revisions 416500 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 416501 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 416502 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416503 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-17 18:45:11 +00:00
Walter Doekes 795af210a3 func_odbc: Fix fixed size buffers fix (r414968).
The change that removed the fixed size buffers in odbc-related code --
removing arbitrary column width limits -- was incomplete. This change
adds: no segfault on writesql without insertsql and return value checks
after strdup.

While I was in the vicinity I cleaned up the linefeeds in the odbc
function descriptions, moved some code for clarity, removed some blobs
and noted (but didn't fix) that the 'odbc write ... exec' CLI command
doesn't behave as the dialplan equivalent when insertsql= is used.

ASTERISK-23582 #close
Review: https://reviewboard.asterisk.org/r/3579/
........

Merged revisions 414997 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 414998 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 414999 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415000 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-03 07:36:42 +00:00
Matthew Jordan 53968c00b3 TALK_DETECT: A channel function that raises events when talking is detected
This patch adds a new channel function TALK_DETECT that, when set on a
channel, causes events indicating the start/stop of talking on a channel to be
emitted to both AMI and ARI clients. 

The function allows setting both the silence threshold (the length of silence
after which we decide no one is talking) as well as the talking threshold (the
amount of energy that counts as talking). Parameters can be updated on a channel
after talk detection has been enabled, and talk detection can be removed at
any time.

The events raised by the function use a nomenclature similar to existing AMI/ARI
events.
For AMI: ChannelTalkingStart/ChannelTalkingStop
For ARI: ChannelTalkingStarted/ChannelTalkingFinished

Review: https://reviewboard.asterisk.org/r/3563/

#ASTERISK-23786 #close
Reported by: Matt Jordan
........

Merged revisions 414934 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@414935 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-30 12:42:57 +00:00
Joshua Colp dcfae78574 res_config_odbc: Use dynamically sized buffers to store row data so values do not get truncated.
ASTERISK-23582 #close
ASTERISk-23582 #comment Reported by: Walter Doekes

Review: https://reviewboard.asterisk.org/r/3557/
........

Merged revisions 414693 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 414694 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 414695 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@414696 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-28 11:37:50 +00:00
Scott Griepentrog 43bd3580e2 pbx.c: prevent potential crash from recursive replace()
Recurisve usage of replace() resulted in corruption of the
temporary string storage and potential crash.  By changing
the string to be allocated separtely per instance, this is
eliminated.

ASTERISK-23650 #comment Reported by: Roel van Meer
ASTERISK-23650 #close

Review: https://reviewboard.asterisk.org/r/3539/
........

Merged revisions 414214 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 414215 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 414216 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@414217 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-21 19:08:39 +00:00
Kinsey Moore 21949def8e Fix 32bit build for func_env
........

Merged revisions 413592 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 413595 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 413597 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413599 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-09 23:18:21 +00:00
Kinsey Moore abd3e4040b Allow Asterisk to compile under GCC 4.10
This resolves a large number of compiler warnings from GCC 4.10 which
cause the build to fail under dev mode. The vast majority are
signed/unsigned mismatches in printf-style format strings.
........

Merged revisions 413586 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 413587 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 413588 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413589 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-09 22:49:26 +00:00
Mark Michelson 68066907e1 Ensure that presence state is decoded properly on Asterisk startup.
The CustomPresence provider callback will automatically base64 decode
stored data if the 'e' option was present when the state was set. However,
since the provider callback was bypassed on Asterisk startup, encoded
presence subtypes and messages were being sent instead. This fix makes
it so the provider callback is always used when providing presence
state updates.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413469 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-07 21:58:37 +00:00
Mark Michelson 120ac66df9 Make behavior of the PRESENCE_STATE 'e' option more consistent.
When writing presence state, if 'e' is specified, then the presence state will
be stored in the astdb encoded. However, consumers of presence state events or those
that query for the presence state will be given decoded information. If base64 encoding
is desired for consumers, then the information can be base64-encoded manually and the
'e' option can be omitted.

closes issue ASTERISK-23671
Reported by Mark Michelson

Review: https://reviewboard.asterisk.org/r/3482



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413183 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-01 16:21:09 +00:00
Russell Bryant 4b9b4790d9 Fix error loading res_monitor.
For some odd reason, loading app_mixmonitor was fine, but res_monitor was not.
This patch fixes a set of issues related to func_periodic_hook exporting the
beep functions that gets res_monitor working again.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@412910 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-04-23 15:02:39 +00:00
Russell Bryant 5b7a769fd8 (mix)monitor: Add options to enable a periodic beep
Add an option to enable a periodic beep to be played into a call if it
is being recorded.  If enabled, it uses the PERIODIC_HOOK() function
internally to play the 'beep' prompt into the call at a specified
interval.  This option is provided for both Monitor() and
MixMonitor().

Review: https://reviewboard.asterisk.org/r/3424/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@412427 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-04-15 23:21:19 +00:00
Russell Bryant 39ba6a16f5 func_periodic_hook: move module ref
The previous code left one error path where the module would be unref'd twice
instead of once.  It was done once in the error handling block, and again inside
of datastore destruction.

Now the module ref is only released in the datastore destructor and only acquired
when the datastore has been successfully allocated.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@412280 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-04-12 01:35:34 +00:00
Russell Bryant 23329d07cf func_periodic_hook: add module ref counting
This module lacked necessary module ref count incrementing and decrementing
when used.  This patch adds it.  There's already a datastore used, so doing the
ref counting along with the lifetime of the datastore provides a convenient
place to do it.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@412279 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-04-12 01:26:28 +00:00
Russell Bryant 607c6e9772 func_periodic_hook: List more modules as dependencies
This module makes use of some existing Asterisk components.  app_chanspy was
already listed as a dependency.  There are a few function modules used, as
well, so list them.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411897 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-04-08 00:26:57 +00:00
Russell Bryant ea290b2c3e func_periodic_hook: New function for periodic hooks.
This commit introduces a new dialplan function, PERIODIC_HOOK().
It allows you run to a dialplan hook on a channel periodically.  The
original use case that inspired this was the ability to play a beep
periodically into a call being recorded.  The implementation is much
more generic though and could be used for many other things.

The implementation makes heavy use of existing Asterisk components.
It uses a combination of Local channels and ChanSpy() to run some
custom dialplan and inject any audio it generates into an active call.

The other important bit of the implementation is how it figures out
when to trigger the beep playback.  This implementation uses the
audiohook API, even though it's not actually touching the audio in any
way.  It's a convenient way to get a callback and check if it's time
to kick off another beep.  It would be nice if this was timer event
based instead of polling based, but unfortunately I don't see a way to
do it that won't interfere with other things.

Review: https://reviewboard.asterisk.org/r/3362/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411768 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-04-05 13:06:34 +00:00
Corey Farrell fbe0dfaf44 Fix dialplan function NULL channel safety issues
(closes issue ASTERISK-23391)
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/3386/
........

Merged revisions 411313 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 411314 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 411315 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411328 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-27 19:21:44 +00:00
Mark Michelson d44aefeef4 Fix stuck channel in ARI through the introduction of synchronous bridge actions.
Playing back a file to a channel in an ARI bridge would attempt to wait until
the playback concluded before returning. The method used involved signaling the
waiting thread in the ARI custom playback function.

The problem with this is that there were some corner cases that were not accounted for:
* If a bridge channel could not be found, then we never would attempt the playback but
  would still attempt to wait for the playback to complete.
* If the bridge playfile action failed to queue, we would still attempt to wait for the
  playback to complete.
* If the bridge playfile action were queued but some circumstance caused the playback
  not to occur (the bridge dies, the channel is removed from the bridge), then we would
  never be notified.

The solution to this is to move the waiting logic into the bridge code. A new bridge
API function is added to queue a synchronous action on a bridge. The waiting thread
is notified when the queued frame has been freed, either due to an error occurring
or due to successful playback. As a failsafe, the waiting thread has a 10 minute
timeout just in case there is a frame leak somewhere.

Review: https://reviewboard.asterisk.org/r/3338
........

Merged revisions 410673 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410684 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-17 17:22:12 +00:00
George Joseph a4906e9f86 sorcery: Create AST_SORCERY dialplan function.
This patch creates the AST_SORCERY dialplan function which allows someone to
retrieve any value from a sorcery-based config file.  It's similar to 
AST_CONFIG.

The creation of the function itself was fairly straightforward but it required
changes to the underlying sorcery infrastructure that rippled into individual
sorcery objects.  The changes stemmed from inconsistencies in how sorcery
created ast_variable objectsets from sorcery objects and the inconsistency
in how individual objects used that feature especially when it came to
parameters that can be specified multiple times like contact in aor and match
in identify.  You can read more here...
http://lists.digium.com/pipermail/asterisk-dev/2014-February/065202.html

So, what this patch does, besides actually creating the AST_SORCERY function,
is the following...

* Creates ast_variable_list_append which is a helper to append one ast_variable
  list to another.
* Modifies the ast_sorcery_object_field_register functions to accept the
  already-defined sorcery_fields_handler callback.
* Modifies ast_sorcery_objectset_create to accept a parameter indicating return
  type preference...a single ast_variable with all values concatenated or an
  ast_variable list with multiple entries.  Also fixed a few bugs.
* Modifies individual sorcery object implementations to use the new function
  definition of the ast_sorcery_object_field_register functions.
* Modifies location.c and res_pjsip_endpoint_identifier_ip.c to implement
  sorcery_fields_handler handlers so they return multiple occurrences as an
  ast_variable_list.
* Added a whole bunch of tests to test_sorcery.

(closes issue ASTERISK-22537)
Review: http://reviewboard.asterisk.org/r/3254/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410042 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-06 22:39:54 +00:00
Mark Michelson ad39358e19 Fix documentation for PRESENCE_STATE to properly illustrate how to create a presence hint.
There was a missing comma.
This was discovered by Dan Kaplan.
........

Merged revisions 409886 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 409887 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@409888 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-05 18:47:30 +00:00
Michael L. Young 959c3a7c15 func_audiohookinheritance: Check If A Channel Was Specified
This patch prevents a crash when using the function audiohookinheritance without
setting the channel.

(closes issue ASTERISK-23104)
Reported by: Joel Vandal
Tested by: Joel Vandal
Patches:
    asterisk-23104_audiohook_inherit_no_channel-11.diff
                                     uploaded by Michael L. Young (license 5026)

Review: https://reviewboard.asterisk.org/r/3272/
........

Merged revisions 409623 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 409625 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 409626 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@409627 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-04 19:34:52 +00:00
Matthew Jordan 5fd63e2d0b funcs/func_cdr: Handle empty time values when extracting parsed values
When extracting timestamps that are parsed, time stamp values that are not set
(time values of 0.000000) should not actually result in a parsed string. The
value should be skipped, and the result of the CDR function should be an
empty string.

Prior to this patch, the result was fed to the time formatting, which would
result in an output of a date/time in 1969.
........

Merged revisions 407747 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407748 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-02-07 19:40:23 +00:00
Matthew Jordan 9e7a10d894 funcs/func_cdr: Fix non-epoch timestamps broken by improper char array deref
Thanks to snuffy for pointing this issue out and fixing it.

(closes issue ASTERISK-23250)
Reported by: snuffy
patches:
  func_cdr-fix.diff uploaded by snuffy (License 5024)
........

Merged revisions 407259 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407260 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-02-04 16:55:39 +00:00
Richard Mudgett 828f339a9c verbosity: Fix performance of console verbose messages.
The per console verbose level feature as previously implemented caused a
large performance penalty.  The fix required some minor incompatibilities
if the new rasterisk is used to connect to an earlier version.  If the new
rasterisk connects to an older Asterisk version then the root console
verbose level is always affected by the "core set verbose" command of the
remote console even though it may appear to only affect the current
console.  If an older version of rasterisk connects to the new version
then the "core set verbose" command will have no effect.

* Fixed the verbose performance by not generating a verbose message if
nothing is going to use it and then filtered any generated verbose
messages before actually sending them to the remote consoles.

* Split the "core set debug" and "core set verbose" CLI commands to remove
the per module verbose support that cannot work with the per console
verbose level.

* Added a silent option to the "core set verbose" command.

* Fixed "core set debug off" tab completion.

* Made "core show settings" list the current console verbosity in addition
to the root console verbosity.

* Changed the default verbose level of the 'verbose' setting in the
logger.conf [logfiles] section.  The default is now to once again follow
the current root console level.  As a result, using the AMI Command action
with "core set verbose" could again set the root console verbose level and
affect the verbose level logged.

(closes issue AST-1252)
Reported by: Guenther Kelleter

Review: https://reviewboard.asterisk.org/r/3114/
........

Merged revisions 405431 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 405432 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@405436 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-14 18:14:02 +00:00
Matthew Jordan 373965dbff CDRs: Synchronize dialplan applications that manipulate CDRs with the engine
In https://reviewboard.asterisk.org/r/3057/, applications and functions that
manipulate CDRs were made to interact over Stasis. This was done to
synchronize manipulations of CDRs from the dialplan with the updates the
engine itself receives over the message bus.

This change rested on a faulty premise: that messages published to the CDR
topic or to a topic that forwards to the CDR topic are synchronized with the
messages handled by the CDR topic subscription in the CDR engine. This is not
the case. There is no ordering guaranteed for two messages published to the
same topic; ordering is only guaranteed if a message is published to the same
subscriber.

Stasis was modified in r405311 to allow a publisher to synchronize on the
subscriber. This patch uses that API to synchronize the CDR publishers with
the CDR engine message router, which maintains the overall topic subscription.

(closes issue ASTERISK-22884)
Reported by: Matt Jordan

Review: https://reviewboard.asterisk.org/r/3099/
........

Merged revisions 405312 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@405314 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-12 22:13:12 +00:00
Scott Griepentrog ff02c8e254 func_strings: use memmove to prevent overlapping memory on strcpy
When calling REPLACE() with an empty replace-char argument, strcpy
is used to overwrite the the matching <find-char>.  However as the
src and dest arguments to strcpy must not overlap, it causes other
parts of the string to be overwritten with adjacent characters and
the result is mangled.  Patch replaces call to strcpy with memmove
and adds a test suite case for REPLACE.

(closes issue ASTERISK-22910)
Reported by: Gareth Palmer
Review: https://reviewboard.asterisk.org/r/3083/
Patches:
    func_strings.patch uploaded by Gareth Palmer (license 5169)
........

Merged revisions 404674 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 404675 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 404676 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404677 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-02 19:38:09 +00:00
Richard Mudgett e4803bbd9e Voicemail: Remove mailbox identifier format (box@context) assumptions in the system.
This change is in preparation for external MWI support.

Removed code from the system for normal mailbox handling that appends
@default to the mailbox identifier if it does not have a context.  The
only exception is the legacy hasvoicemail users.conf option.  The legacy
option will only work for app_voicemail mailboxes.  The system cannot make
any assumptions about the format of the mailbox identifer used by
app_voicemail.

chan_sip and chan_dahdi/sig_pri had the most changes because they both
tried to interpret the mailbox identifier.  chan_sip just stored and
compared the two components.  chan_dahdi actually used the box
information.

The ISDN MWI support configuration options had to be reworked because
chan_dahdi was parsing the box@context format to get the box number.  As a
result the mwi_vm_boxes chan_dahdi.conf option was added and is documented
in the chan_dahdi.conf.sample file.

Review: https://reviewboard.asterisk.org/r/3072/
........

Merged revisions 404348 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404350 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-19 16:52:43 +00:00
Matthew Jordan 7e9febbf86 app_cdr,app_forkcdr,func_cdr: Synchronize with engine when manipulating state
When doing the rework of the CDR engine that pushed all of the logic into cdr.c
and made it respond to changes in channel state over Stasis, we knew that
accessing the CDR engine from the dialplan would be "slightly"
non-deterministic. Dialplan threads would be accessing CDRs while Stasis
threads would be updating the state of said CDRs - whereas in the past,
everything happened on the dialplan threads. Tests have shown that "slightly"
is in reality "very".

This patch synchronizes things by making the dialplan applications/functions
that manipulate CDRs do so over Stasis. ForkCDR, NoCDR, ResetCDR, CDR, and
CDR_PROP now all use Stasis to send their requests over to the CDR engine,
and synchronize on the channel Stasis topic via a subscription so that they
return their values/control to the dialplan at the appropriate time.

While going through this, the following changes were also made:
 * DISA, which can reset the CDR when a user successfully authenticates, now
   just uses the ResetCDR app to do this. This prevents having to duplicate
   the same Stasis synchronization logic in that application.
 * Answer no longer disables CDRs. It actually didn't work anyway - calling
   DISABLE on the channel's CDR doesn't stop the CDR from getting the Answer
   time - it just kills all CDRs on that channel, which isn't what the caller
   would intend.

(closes issue ASTERISK-22884)
(closes issue ASTERISK-22886)

Review: https://reviewboard.asterisk.org/r/3057/
........

Merged revisions 404294 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404295 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-19 00:50:01 +00:00
Kevin Harwell 28c0cb28d0 channel locking: Add locking for channel snapshot creation
Original commit message by mmichelson (asterisk 12 r403311):

"This adds channel locks around calls to create channel snapshots as well
as other functions which operate on a channel and then end up
creating a channel snapshot. Functions that expect the channel to be
locked prior to being called have had their documentation updated to
indicate such."

The above was initially committed and then reverted at r403398.  The problem
was found to be in core_local.c in the publish_local_bridge_message function.
The ast_unreal_lock_all function locks and adds a reference to the returned
channels and while they were being unlocked they were not being unreffed when
no longer needed.  Fixed by unreffing the channels.

Also in bridge.c a lock was obtained on "other->chan", but then an attempt was
made to unlock "other" and not the previously locked channel.  Fixed by
unlocking "other->chan"

(closes issue ASTERISK-22709)
Reported by: John Bigelow
........

Merged revisions 404237 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404260 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-18 20:33:37 +00:00
Rusty Newton 2a6df87fcd func_strings: Documentation fix for QUOTE()
Example output was inaccurate.

(issue ASTERISK-22970)
(closes issue ASTERISK-22970)
Reported by: Gareth Palmer
Patches:
   func_strings.patch uploaded by Gareth Palmer (license 5169)
........

Merged revisions 404081 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 404087 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 404099 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404100 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-18 00:36:54 +00:00
David M. Lee 744556c01d security: Inhibit execution of privilege escalating functions
This patch allows individual dialplan functions to be marked as
'dangerous', to inhibit their execution from external sources.

A 'dangerous' function is one which results in a privilege escalation.
For example, if one were to read the channel variable SHELL(rm -rf /)
Bad Things(TM) could happen; even if the external source has only read
permissions.

Execution from external sources may be enabled by setting
'live_dangerously' to 'yes' in the [options] section of asterisk.conf.
Although doing so is not recommended.

Also, the ABI was changed to something more reasonable, since Asterisk
12 does not yet have a public release.

(closes issue ASTERISK-22905)
Review: http://reviewboard.digium.internal/r/432/
........

Merged revisions 403913 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 403917 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 403959 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403960 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-16 19:11:51 +00:00
Matthew Jordan ce423d2ea4 func_channel, chan_pjsip: Add CHANNEL read function support for chan_pjsip
This patch adds CHANNEL read support for chan_pjsip. This allows the dialplan
to use the CHANNEL function on a chan_pjsip channel to obtain run-time
information about the channel from the PJSIP channel driver and the PJSIP
stack. This includes:
 * RTP information, including source/destination media addresses, whether or
   not the media is secure, held, and other properties.
 * RTCP information. This includes sets of parseable information, as well as
   individual statistic attriutes.
 * PJSIP information. This includes URIs, local/remote signalling addresses,
   whether or not the signalling is secure, and other properties.
 * The endpoint name. This can be used in conjunction with the PJSIP_ENDPOINT
   function to obtain more detailed endpoint information.

Review: https://reviewboard.asterisk.org/r/3038/
........

Merged revisions 403618 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403619 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-11 13:06:30 +00:00
Matthew Jordan f46b30bd36 func_pjsip_endpoint: Add PJSIP_ENDPOINT function for querying endpoint details
This patch adds a new function, PJSIP_ENDPOINT, which lets the dialplan query,
for any endpoint, any property configured on an endpoint. This function is a
companion to the CHANNEL function, which can be used to extract the endpoint
name for a channel.

Review: https://reviewboard.asterisk.org/r/3035
........

Merged revisions 403616 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403617 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-11 12:31:57 +00:00
David M. Lee 1212906351 Reverting r403311. It's causing ARI tests to hang.
........

Merged revisions 403398 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403404 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-05 22:10:20 +00:00
Mark Michelson 8e8b329e14 Add channel locking for channel snapshot creation.
This adds channel locks around calls to create channel snapshots as well
as other functions which operate on a channel and then end up
creating a channel snapshot. Functions that expect the channel to be
locked prior to being called have had their documentation updated to
indicate such.
........

Merged revisions 403311 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403314 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-03 17:07:29 +00:00
Jonathan Rose beb5cdbef5 memory leaks: Memory leak cleanup patch by Corey Farrell (first set)
(issue ASTERSIK-22467)
Reported by: Corey Farrell
Patches:
    chan_sip-parse_contact_header_test-free-contacts.patch uploaded by coreyfarrell (license 5909)
    cli-filename-completion-leak.patch uploaded by coreyfarrell (license 5909)
    func_math.patch uploaded by corefarrell (license 5909)
    main-test-cleanup.patch uploaded by coreyfarrell (license 5909)
    test_dlinklists.patch uploaded by coreyfarrell (license 5909)
........

Merged revisions 401660 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 401661 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 401662 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@401663 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-10-23 20:10:30 +00:00
Kinsey Moore 4e72ad1b4f Fix func_config list entry allocation
The AST_CONFIG dialplan function defined in func_config.c allocates its
config file list entries using ast_malloc. List entry allocations
destined for use with Asterisk's linked list API must be ast_calloc()d
or otherwise initialized so that list pointers are set to NULL. These
uses of ast_malloc have been replaced by ast_calloc to prevent
dereferencing of uninitialized pointer values when traversing the list.

(closes issue ASTERISK-22483)
Reported by: Brian Scott
........

Merged revisions 400694 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 400697 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 400701 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400704 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-10-08 18:19:59 +00:00
Matthew Jordan de07050d0f Parse arguments passed to the CDR_PROP function correctly
I can only blame this on a bad merge, because this in no way worked properly
the way it was written. Mea culpa. The function should now parse its arguments
correctly and function properly. (Note that the API used by the CDR_PROP
function has working unit tests... this was merely bad coding of the actual
registered function)

(closes issue ASTERISK-22613)
Reported by: Private Name
........

Merged revisions 400196 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400197 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-30 19:58:19 +00:00
David M. Lee 2de42c2a25 Multiple revisions 399887,400138,400178,400180-400181
........
  r399887 | dlee | 2013-09-26 10:41:47 -0500 (Thu, 26 Sep 2013) | 1 line
  
  Minor performance bump by not allocate manager variable struct if we don't need it
........
  r400138 | dlee | 2013-09-30 10:24:00 -0500 (Mon, 30 Sep 2013) | 23 lines
  
  Stasis performance improvements
  
  This patch addresses several performance problems that were found in
  the initial performance testing of Asterisk 12.
  
  The Stasis dispatch object was allocated as an AO2 object, even though
  it has a very confined lifecycle. This was replaced with a straight
  ast_malloc().
  
  The Stasis message router was spending an inordinate amount of time
  searching hash tables. In this case, most of our routers had 6 or
  fewer routes in them to begin with. This was replaced with an array
  that's searched linearly for the route.
  
  We more heavily rely on AO2 objects in Asterisk 12, and the memset()
  in ao2_ref() actually became noticeable on the profile. This was
  #ifdef'ed to only run when AO2_DEBUG was enabled.
  
  After being misled by an erroneous comment in taskprocessor.c during
  profiling, the wrong comment was removed.
  
  Review: https://reviewboard.asterisk.org/r/2873/
........
  r400178 | dlee | 2013-09-30 13:26:27 -0500 (Mon, 30 Sep 2013) | 24 lines
  
  Taskprocessor optimization; switch Stasis to use taskprocessors
  
  This patch optimizes taskprocessor to use a semaphore for signaling,
  which the OS can do a better job at managing contention and waiting
  that we can with a mutex and condition.
  
  The taskprocessor execution was also slightly optimized to reduce the
  number of locks taken.
  
  The only observable difference in the taskprocessor implementation is
  that when the final reference to the taskprocessor goes away, it will
  execute all tasks to completion instead of discarding the unexecuted
  tasks.
  
  For systems where unnamed semaphores are not supported, a really
  simple semaphore implementation is provided. (Which gives identical
  performance as the original taskprocessor implementation).
  
  The way we ended up implementing Stasis caused the threadpool to be a
  burden instead of a boost to performance. This was switched to just
  use taskprocessors directly for subscriptions.
  
  Review: https://reviewboard.asterisk.org/r/2881/
........
  r400180 | dlee | 2013-09-30 13:39:34 -0500 (Mon, 30 Sep 2013) | 28 lines
  
  Optimize how Stasis forwards are dispatched
  
  This patch optimizes how forwards are dispatched in Stasis.
  
  Originally, forwards were dispatched as subscriptions that are invoked
  on the publishing thread. This did not account for the vast number of
  forwards we would end up having in the system, and the amount of work it
  would take to walk though the forward subscriptions.
  
  This patch modifies Stasis so that rather than walking the tree of
  forwards on every dispatch, when forwards and subscriptions are changed,
  the subscriber list for every topic in the tree is changed.
  
  This has a couple of benefits. First, this reduces the workload of
  dispatching messages. It also reduces contention when dispatching to
  different topics that happen to forward to the same aggregation topic
  (as happens with all of the channel, bridge and endpoint topics).
  
  Since forwards are no longer subscriptions, the bulk of this patch is
  simply changing stasis_subscription objects to stasis_forward objects
  (which, admittedly, I should have done in the first place.)
  
  Since this required me to yet again put in a growing array, I finally
  abstracted that out into a set of ast_vector macros in
  asterisk/vector.h.
  
  Review: https://reviewboard.asterisk.org/r/2883/
........
  r400181 | dlee | 2013-09-30 13:48:57 -0500 (Mon, 30 Sep 2013) | 28 lines
  
  Remove dispatch object allocation from Stasis publishing
  
  While looking for areas for performance improvement, I realized that an
  unused feature in Stasis was negatively impacting performance.
  
  When a message is sent to a subscriber, a dispatch object is allocated
  for the dispatch, containing the topic the message was published to, the
  subscriber the message is being sent to, and the message itself.
  
  The topic is actually unused by any subscriber in Asterisk today. And
  the subscriber is associated with the taskprocessor the message is being
  dispatched to.
  
  First, this patch removes the unused topic parameter from Stasis
  subscription callbacks.
  
  Second, this patch introduces the concept of taskprocessor local data,
  data that may be set on a taskprocessor and provided along with the data
  pointer when a task is pushed using the ast_taskprocessor_push_local()
  call. This allows the task to have both data specific to that
  taskprocessor, in addition to data specific to that invocation.
  
  With those two changes, the dispatch object can be removed completely,
  and the message is simply refcounted and sent directly to the
  taskprocessor.
  
  Review: https://reviewboard.asterisk.org/r/2884/
........

Merged revisions 399887,400138,400178,400180-400181 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400186 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-30 18:55:27 +00:00
Richard Mudgett 83bf017db9 Fix incorrect usages of ast_realloc().
There are several locations in the code base where this is done:
buf = ast_realloc(buf, new_size);

This is going to leak the original buf contents if the realloc fails.

Review: https://reviewboard.asterisk.org/r/2832/
........

Merged revisions 398757 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 398758 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 398759 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@398760 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-10 18:05:47 +00:00
Richard Mudgett 186db8fdaf Fix some uninitialized buffers for CDR handling valgrind found.
* Made ast_strftime_locale() ensure that the output buffer is initialized.
The std library strftime() returns 0 and does not touch the buffer if it
has an error.  However, the function can also return 0 without an error.

(closes issue ASTERISK-22412)
Reported by: rmudgett
........

Merged revisions 397902 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397903 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-28 23:15:43 +00:00
Richard Mudgett 5482fd21c8 Some CDR code optimization.
........

Merged revisions 397892 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397893 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-28 22:24:01 +00:00
Richard Mudgett 4ea0acbb44 Whitespace and curly braces.
........

Merged revisions 397885 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397886 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-28 21:38:39 +00:00
Kinsey Moore 59753b1ea1 Strip down the old event system
This removes unused code, event types, IE pltypes, and event IE types
where possible and makes several functions private that were once
public. This includes a renumbering of the remaining event and IE types
which breaks binary compatibility with previous versions. The last
remaining consumers of the old event system (or parts thereof) are
main/security_events.c, res/res_security_log.c, tests/test_cel.c,
tests/test_event.c, main/cel.c, and the CEL backends.

Review: https://reviewboard.asterisk.org/r/2703/
(closes issue ASTERISK-22139)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396887 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-17 14:39:27 +00:00
David M. Lee c790848794 ARI: Add recording controls
This patch implements the controls from ARI recordings. The controls
are:

 * DELETE /recordings/live/{recordingName} - stop recording and
   discard it
 * POST /recordings/live/{recordingName}/stop - stop recording
 * POST /recordings/live/{recordingName}/pause - pause recording
 * POST /recordings/live/{recordingName}/unpause - resume recording
 * POST /recordings/live/{recordingName}/mute - mute recording (record
   silence to the file)
 * POST /recordings/live/{recordingName}/unmute - unmute recording.

Since this underlying functionality did not already exist, is was
added to app.c by a set of control frames, similar to how playback
control works. The pause/mute control frames are toggles, even though
the ARI controls are idempotent, to be consistent with the playback
control frames.

(closes issue ASTERISK-22181)
Review: https://reviewboard.asterisk.org/r/2697/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396331 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-06 14:44:45 +00:00
Walter Doekes 07d3705b42 Check result of ast_var_assign() calls for memory allocation failure (2).
Missed a spot in the previous commit.
........

Merged revisions 396310 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396311 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-06 08:43:22 +00:00
Walter Doekes ccdfe67bf2 Check result of ast_var_assign() calls for memory allocation failure.
We try to keep the system running even when all available memory is
spent.

Review: https://reviewboard.asterisk.org/r/2734/
........

Merged revisions 396279 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 396287 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396309 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-06 08:36:15 +00:00
Mark Michelson f8622e7c5c Get rid of ast_bridged_channel() and the bridged_channel field on ast_channels.
This commit is smaller than the initial review placed on review board. This is because
a change to allow for channel drivers to access parking functionality externally was
committed and invalidated quite a few of the changes initially made.

(closes issue ASTERISK-22039)
reported by Matt Jordan

Review: https://reviewboard.asterisk.org/r/2717



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396103 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-02 14:05:07 +00:00
Kinsey Moore 03090a88ba Fix documentation replication issues
This prevents XML documentation duplication by expanding channel and
bridge snapshot tags into channel and bridge snapshot parameter sets
with a given prefix or defaulting to no prefix. This also prevents
documentation from becoming fractured and out of date by keeping all
variations of the documentation in template form such that it only
needs to be updated once and keeps maintenance to a minimum.

Review: https://reviewboard.asterisk.org/r/2708/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395985 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-01 17:07:52 +00:00
Matthew Jordan cafc115896 A great big renaming patch
This patch renames the bridging* files to bridge*. This may seem pedantic
and silly, but it fits better in line with current Asterisk naming conventions:
* channel is not "channeling"
* monitor is not "monitoring"
etc.

A bridge is an object. It is a first class citizen in Asterisk. "Bridging" is
the act of using a bridge on a set of channels - and the API that fulfills that
role is more than just the action.

(closes issue ASTERISK-22130)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395378 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-25 04:06:32 +00:00
Matthew Jordan 9d8a5ceb02 Move after bridge callbacks into their own file
One more major refactoring to go.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395367 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-25 02:20:23 +00:00
Jonathan Rose f3fcf0aa2e func_channel: dtmf_features setting
Allows reading andsetting dtmf features via a channel function
CHANNEL(dtmf_features)

(closes issue ASTERISK-21876)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2648/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395215 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-23 21:32:33 +00:00
Matthew Jordan 88e344d2df Clean up documentation
This patch cleans up documentation in func_channel for the following items:
* rtpsource
* secure_signaling
* secure_media
* various OOH323 parameters

(closes issue ASTERISK-20969)
Reported by: snuffy
patches:
  func_chan-update.diff uploaded by snuffy (License 5024)
........

Merged revisions 394980 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 394981 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394982 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-21 22:09:23 +00:00
Matthew Jordan a3592db1fb Clarify documentation for function PASSTHRU
It is not apparent to the average user that the PASSTHRU function should not
be passed as ${PASSTHRU(string)} but just as PASSTHRU(string) to functions
which take a variable name and not its contents.

This patch clarifies the behavior in the documentation and provides an example.

(closes issue ASTERISK-21717)
Reported by: Richard Miller
patches:
  func_strings.diff uploaded by Richard Miller (license 5685)
........

Merged revisions 394302 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 394303 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394304 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-14 02:00:02 +00:00
Jonathan Rose d014ad2261 func_channel: Read/Write after_bridge_goto option
Allows reading and setting of a channel's after_bridge_goto datastore

(closes issue ASTERISK-21875)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2628/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393005 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-26 20:59:14 +00:00
Matthew Jordan 68103abba3 Handle variable substitution in dummy variables
When func_cdr is used for variable substitution, there is no channel name
and hence no run-time information available for CDR variable substitution.
In that case, the correct thing to do is to use the CDR object on the channel
passed to the function. This patch checks to see if the channel passed in
has a name - if not, it uses ast_cdr_format_var instead of ast_cdr_get_var.

This allows CDR backends to continue to use variable substitution in order to
resolve ast_cdr object properties.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392214 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-19 01:28:40 +00:00
David M. Lee 4aa47d6893 Fix build warnings related to printf/scanf of tv_usec.
The type of tv_usec is suseconds_t. On Linux, this is usually a long int, but
the specification is actually pretty lax on what it might actually be. And,
sadly, there's no printf/scanf width specifier for suseconds_t. So it could
bit an int or a long, but there's not a great way to tell which it is.

This patch fixes scanf by reading into a long temporary variable that's then
stored into the tv_usec. It fixes printf by casting the tv_usec to a long
first.

This patch also adds some missing width specifiers for some debug statements,
which would cause ".000001" to be displayed at ".1".


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392076 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-17 18:58:56 +00:00
Matthew Jordan 6258bbe7bd Update Asterisk's CDRs for the new bridging framework
This patch is the initial push to update Asterisk's CDR engine for the new
bridging framework. This patch guts the existing CDR engine and builds the new
on top of messages coming across Stasis. As changes in channel state and bridge
state are detected, CDRs are built and dispatched accordingly. This
fundamentally changes CDRs in a few ways.
(1) CDRs are now *very* reflective of the actual state of channels and bridges.
    This means CDRs track well with what an actual channel is doing - which
    is useful in transfer scenarios (which were previously difficult to pin
    down). It does, however, mean that CDRs cannot be 'fooled'. Previous
    behavior in Asterisk allowed for CDR applications, channels, and other
    properties to be spoofed in parts of the code - this no longer works.
(2) CDRs have defined behavior in multi-party scenarios. This behavior will not
    be what everyone wants, but it is a defined behavior and as such, it is
    predictable.
(3) The CDR manipulation functions and applications have been overhauled. Major
    changes have been made to ResetCDR and ForkCDR in particular. Many of the
    options for these two applications no longer made any sense with the new
    framework and the (slightly) more immutable nature of CDRs.

There are a plethora of other changes. For a full description of CDR behavior,
see the CDR specification on the Asterisk wiki.

(closes issue ASTERISK-21196)

Review: https://reviewboard.asterisk.org/r/2486/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@391947 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-06-17 03:00:38 +00:00
Richard Mudgett 3d63833bd6 Merge in the bridge_construction branch to make the system use the Bridging API.
Breaks many things until they can be reworked.  A partial list:
chan_agent
chan_dahdi, chan_misdn, chan_iax2 native bridging
app_queue
COLP updates
DTMF attended transfers
Protocol attended transfers


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@389378 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-21 18:00:22 +00:00
David M. Lee b97c71bb11 Fix shutdown assertions in stasis-core
In r388005, macros were introduced to consistently define message
types. This added an assert if a message type was used either before
it was initialized or after it had been cleaned up. It turns out that
this assertion fires during shutdown.

This actually exposed a hidden shutdown ordering problem. Since
unsubscribing is asynchronous, it's possible that the message types
used by the subscription could be freed before the final message of
the subscription was processed.

This patch adds stasis_subscription_join(), which blocks until the
last message has been processed by the subscription. Since joining was
most commonly done right after an unsubscribe, a
stasis_unsubscribe_and_join() convenience function was also added.

Similar functions were also added to the stasis_caching_topic and
stasis_message_router, since they wrap subscriptions and have similar
problems.

Other code in trunk was refactored to join() where appropriate, or at
least verify that the subscription was complete before being
destroyed.

Review: https://reviewboard.asterisk.org/r/2540


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@389011 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-17 21:10:32 +00:00
Matthew Jordan b3bb6608ef Migrate SHARED's use of the VarSet AMI event to Stasis-Core
This patch removes the direct call to AMI from the SHARED function
and instead call Stasis-Core. Stasis-Core delivers the notification
that a shared variable has changed on a channel to all interested
consumers.

(issue ASTERISK-21462)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@387630 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-05-04 15:24:31 +00:00