Commit Graph

912 Commits

Author SHA1 Message Date
Naveen Albert 410909fbfb func_frame_trace: Add CLI command to dump frame queue.
This adds a simple CLI command that can be used for
analyzing all frames currently queued to a channel.

A couple log messages are also adjusted to be more
useful in tracing bridging problems.

Resolves: #533
(cherry picked from commit d075a08d7e)
2024-03-07 14:17:22 +00:00
Naveen Albert a6d856aba2 func_channel: Expose previously unsettable options.
Certain channel options are not set anywhere or
exposed in any way to users, making them unusable.
This exposes some of these options which make sense
for users to manipulate at runtime.

Resolves: #442
(cherry picked from commit c222343ec6)
2024-01-12 18:29:19 +00:00
Sean Bright 69a19aabd8 func_curl.c: Remove CURLOPT() plaintext documentation.
I assume this was missed when initially converting to XML
documentation and we've been kicking the can down the road since.

(cherry picked from commit 9e1a60727e)
2024-01-12 18:29:19 +00:00
Naveen Albert 4d928ee975 func_lock: Add missing see-also refs to documentation.
Resolves: #423
(cherry picked from commit 12b353eae0)
2024-01-12 18:29:19 +00:00
Sean Bright d7a01afa50 func_curl.c: Ensure channel is locked when manipulating datastores.
(cherry picked from commit acb2348f90)
2024-01-12 18:29:18 +00:00
Bastian Triller 7a1208410a func_json: Fix crashes for some types
This commit fixes crashes in JSON_DECODE() for types null, true, false
and real numbers.

In addition it ensures that a path is not deeper than 32 levels.

Also allow root object to be an array.

Add unit tests for above cases.

(cherry picked from commit e6d5b8d8cf)
2024-01-12 18:29:18 +00:00
Mike Bradeen 58a37523dd func_periodic_hook: Add hangup step to avoid timeout
func_periodic_hook does not hangup after playback, relying on hangup
which keeps the channel alive longer than necessary.

Resolves: #325
(cherry picked from commit dd817c2708)
2024-01-12 18:29:18 +00:00
George Joseph 9ee35c259a func_periodic_hook: Don't truncate channel name
func_periodic_hook was truncating long channel names which
causes issues when you need to run other dialplan functions/apps
on the channel.

Resolves: #319
(cherry picked from commit 9e2433f73f)
2024-01-12 18:29:18 +00:00
Joshua C. Colp 6521066fbe variables: Add additional variable dialplan functions.
Using the Set dialplan application does not actually
delete channel or global variables. Instead the
variables are set to an empty value.

This change adds two dialplan functions,
GLOBAL_DELETE and DELETE which can be used to
delete global and channel variables instead
of just setting them to empty.

There is also no ability within the dialplan to
determine if a global or channel variable has
actually been set or not.

This change also adds two dialplan functions,
GLOBAL_EXISTS and VARIABLE_EXISTS which can be
used to determine if a global or channel variable
has been set or not.

Resolves: #289

UserNote: Four new dialplan functions have been added.
GLOBAL_DELETE and DELETE have been added which allows
the deletion of global and channel variables.
GLOBAL_EXISTS and VARIABLE_EXISTS have been added
which checks whether a global or channel variable has
been set.

(cherry picked from commit abe4f62554)
2024-01-12 18:29:18 +00:00
phoneben cbcde0624b func_cut: Add example to documentation.
This adds an example to the XML documentation clarifying usage
of the CUT function to address a common misusage.

(cherry picked from commit c0b8adfe4d)
2023-09-06 16:55:59 +00:00
Sean Bright 29fbf1b2c8 func_export: Use correct function argument as variable name.
Fixes #208

(cherry picked from commit b8aee4a2c6)
2023-09-06 16:55:59 +00:00
Naveen Albert f40e50ce19 sig_analog: Add fuller Caller ID support.
A previous change, ASTERISK_29991, made it possible
to send additional Caller ID parameters that were
not previously supported.

This change adds support for analog DAHDI channels
to now be able to receive these parameters for
on-hook Caller ID, in order to enhance the usability
of CPE that support these parameters.

Resolves: #94
ASTERISK-30331

UserNote: Additional Caller ID properties are now supported on
incoming calls to FXS stations, namely the
redirecting reason and call qualifier.

(cherry picked from commit 87f44dc0f9)
2023-07-10 11:49:47 +00:00
Mike Bradeen 2ac8388c6d bridge_builtin_features: add beep via touch variable
Add periodic beep option to one-touch recording by setting
the touch variable TOUCH_MONITOR_BEEP or
TOUCH_MIXMONITOR_BEEP to the desired interval in seconds.

If the interval is less than 5 seconds, a minimum of 5
seconds will be imposed.  If the interval is set to an
invalid value, it will default to 15 seconds.

A new test event PERIODIC_HOOK_ENABLED was added to the
func_periodic_hook hook_on function to indicate when
a hook is started.  This is so we can test that the touch
variable starts the hook as expected.

ASTERISK-30446

Change-Id: I800e494a789ba7a930bbdcd717e89d86040d6661
(cherry picked from commit ffe346b2de)
2023-05-08 18:13:35 +00:00
Naveen Albert e104bd0852 func_json: Fix JSON parsing issues.
Fix issue with returning empty instead of dumping
the JSON string when recursing.

Also adds a unit test to capture this fix.

ASTERISK-30441 #close

Change-Id: If0bde9f3fe84f7af485e0838205cc21e0f752a85
(cherry picked from commit f9fd76677f)
2023-05-08 18:13:35 +00:00
Naveen Albert 8a45cd7af4 func_json: Enhance parsing capabilities of JSON_DECODE
Adds support for arrays to JSON_DECODE by allowing the
user to print out entire arrays or index a particular
key or print the number of keys in a JSON array.

Additionally, adds support for recursively iterating a
JSON tree in a single function call, making it easier
to parse JSON results with multiple levels. A maximum
depth is imposed to prevent potentially blowing
the stack.

Also fixes a bug with the unit tests causing an empty
string to be printed instead of the actual test result.

ASTERISK-29913 #close

Change-Id: I603940b216a3911b498fc6583b18934011ef5d5b
2023-01-30 08:50:48 -06:00
Naveen Albert 68e345286b func_frame_trace: Print text for text frames.
Since text frames contain a text body, make FRAME_TRACE
more useful for text frames by actually printing the text.

ASTERISK-30353 #close

Change-Id: Ia6ce3d15cecd7a673a528d34faac86854a2bab50
2023-01-05 06:11:02 -06:00
Naveen Albert cbb1fd2cb9 func_callerid: Warn about invalid redirecting reason.
Currently, if a user attempts to set a Caller ID related
function to an invalid value, a warning is emitted,
except for when setting the redirecting reason.
We now emit a warning if we were unable to successfully
parse the user-provided reason.

ASTERISK-30332 #close

Change-Id: Ic341f5d5f7303b6f1115549be64db58a85944f5a
2022-12-20 08:53:25 -06:00
Naveen Albert 83eb113e0f func_presencestate: Fix invalid memory access.
When parsing information from AstDB while loading,
it is possible that certain pointers are never
set, which leads to invalid memory access and
then, fatally, invalid free attempts on this memory.
We now initialize to NULL to prevent this.

ASTERISK-30311 #close

Change-Id: I6120681d04fd2c12a9473f35ce95a1f8e74e3929
2022-12-08 10:21:26 -06:00
Naveen Albert 002afc3f2a func_json: Fix memory leak.
A memory leak was present in func_json due to
using ast_json_free, which just calls ast_free,
as opposed to recursively freeing the JSON
object as needed. This is now fixed to use the
right free functions.

ASTERISK-30293 #close

Change-Id: I982324dde841dc9147c8d8ad35c8719daf418b49
2022-11-21 08:29:40 -06:00
Naveen Albert 407216a0a5 say: Don't prepend ampersand erroneously.
Some logic in say.c for determining if we need
to also add an ampersand for file seperation was faulty,
as non-successful files would increment the count, causing
a leading ampersand to be added improperly.

This is fixed, and a unit test that captures this regression
is also added.

ASTERISK-30248 #close

Change-Id: I02c1d3a11d82fe4ea8b462070cbd1effb5834d2b
2022-10-26 07:48:17 -05:00
Naveen Albert 407167cc28 func_logic: Don't emit warning if both IF branches are empty.
The IF function currently emits warnings if both IF branches
are empty. However, there is no actual necessity that either
branch be non-empty as, unlike other conditional applications/
functions, nothing is inherently done with IF, and both
sides could legitimately be empty. The warning is thus turned
into a debug message.

ASTERISK-30243 #close

Change-Id: I5250625dd720f95e1859b5dfb933905d7e7a730e
2022-09-26 12:20:21 -05:00
Naveen Albert 1ed4518328 func_export: Add EXPORT function
Adds the EXPORT function, which allows write
access to variables and functions on other
channels.

ASTERISK-29432 #close

Change-Id: I7492645ae4307553d0f586d78e13a4f586231fdf
2022-09-26 07:53:20 -05:00
Naveen Albert 8aae0b9f08 func_scramble: Fix null pointer dereference.
Fix segfault due to null pointer dereference
inside the audiohook callback.

ASTERISK-30220 #close

Change-Id: Ideb80f606974366e89d619d908744230b5a5a259
2022-09-22 11:26:09 -05:00
Naveen Albert ab1dbfef75 func_strings: Add trim functions.
Adds TRIM, LTRIM, and RTRIM, which can be used
for trimming leading and trailing whitespace
from strings.

ASTERISK-30222 #close

Change-Id: I50fb0c40726d044a7a41939fa9026f3da4872554
2022-09-22 05:49:00 -05:00
Naveen Albert 2dac2bf8dc func_frame_trace: Remove bogus assertion.
The FRAME_TRACE function currently asserts if it sees
a MASQUERADE_NOTIFY. However, this is a legitimate thing
that can happen so asserting is inappropriate, as there
are no clear negative ramifications of such a thing. This
is adjusted to be like the other frames to print out
the subclass.

ASTERISK-30210 #close

Change-Id: I8ecbdcf17e35f64bdeab42868471f581ad1d1a56
2022-09-11 18:04:59 -05:00
Naveen Albert 83912496ab func_srv: Document field parameter.
Adds missing documentation for the field parameter
for the SRVRESULT function.

ASTERISK-30151
Reported by: Chris Young

Change-Id: I4385a2e0892a07e30dea1a8a0588e2c1bea2b1f1
2022-07-27 12:10:25 -05:00
Naveen Albert bcc18ca9f5 general: Fix various typos.
ASTERISK-30089 #close

Change-Id: I1f5db911fd05a3a211c522c13e990fa1d0e62275
2022-07-12 07:46:03 -05:00
Naveen Albert 51d262af12 xmldocs: Improve examples.
Use example tags instead of regular para tags
where possible.

ASTERISK-30090

Change-Id: Iada8bbfda08f30b118cedf2d040bbb21e4966ec5
2022-06-09 03:47:41 -05:00
George Joseph 4aa541683b GCC12: Fixes for 16+
Most issues were in stringfields and had to do with comparing
a pointer to an constant/interned string with NULL.  Since the
string was a constant, a pointer to it could never be NULL so
the comparison was always "true".  gcc now complains about that.

There were also a few issues where determining if there was
enough space for a memcpy or s(n)printf which were fixed
by defining some of the involved variables as "volatile".

There were also a few other miscellaneous fixes.

ASTERISK-30044

Change-Id: Ia081ca1bcfb329df6487c4660aaf1944309eb570
2022-05-09 08:21:45 -05:00
Naveen Albert 306ce09df2 func_db: Add function to return cardinality at prefix
Adds the DB_KEYCOUNT function, which can be used to retrieve
the number of keys at a given prefix in AstDB.

ASTERISK-29968 #close

Change-Id: Ib2393b77b7e962dbaae6192f8576bc3f6ba92d09
2022-04-27 11:41:52 -05:00
Naveen Albert 6ddb0ec939 func_evalexten: Extension evaluation function.
This adds the EVAL_EXTEN function, which may be used to retrieve
the variable-substituted data at any extension.

ASTERISK-29486

Change-Id: Iad81019689674c9f4ac77d235f5d7234adbb1432
2022-04-27 03:15:35 -05:00
Naveen Albert 0c70d497bc documentation: Adds versioning information.
Adds version information for applications, functions,
and manager events/actions.

This is not completely exhaustive by any means but
covers most new things added that have release
versioning information in the issue tracker.

ASTERISK-29940 #close

Change-Id: I506401e93c799715dbbe97c0a8ba18af2bf5e131
2022-04-26 17:40:39 -05:00
Joshua C. Colp 4aedaaadeb func_odbc: Add SQL_ESC_BACKSLASHES dialplan function.
Some databases depending on their configuration using backslashes
for escaping. When combined with the use of ' this can result in
a broken func_odbc query.

This change adds a SQL_ESC_BACKSLASHES dialplan function which can
be used to escape the backslashes.

This is done as a dialplan function instead of being always done
as some databases do not require this, and always doing it would
result in incorrect data being put into the database.

ASTERISK-29838

Change-Id: I152bf34899b96ddb09cca3e767254d8d78f0c83d
2022-04-14 12:13:43 -05:00
Naveen Albert 27fb4fd5bc func_channel: Add lastcontext and lastexten.
Adds the lastcontext and lastexten channel fields to allow users
to access previous dialplan execution locations.

ASTERISK-29840 #close

Change-Id: Ib455fe300cc8e9a127686896ee2d0bd11e900307
2022-02-25 14:43:20 -06:00
Naveen Albert e26b57984f asterisk: Add macro for curl user agent.
Currently, each module that uses libcurl duplicates the standard
Asterisk curl user agent.

This adds a global macro for the Asterisk user agent used for
curl requests to eliminate this duplication.

ASTERISK-29861 #close

Change-Id: I9fc37935980384b4daf96ae54fa3c9adb962ed2d
2022-02-25 13:04:14 -06:00
Naveen Albert b1765c93e4 func_db: Add validity check for key names when writing.
Adds a simple sanity check for key names when users are
writing data to AstDB. This captures four cases indicating
malformed keynames that generally result in bad data going
into the DB that the user didn't intend: an empty key name,
a key name beginning or ending with a slash, and a key name
containing two slashes in a row. Generally, this is the
result of a variable being used in the key name being empty.

If a malformed key name is detected, a warning is emitted
to indicate the bug in the dialplan.

ASTERISK-29925 #close

Change-Id: Ifc08a9fe532a519b1b80caca1aafed7611d573bf
2022-02-23 15:19:59 -06:00
Naveen Albert 7ae8321925 func_frame_drop: Fix typo referencing wrong buffer
In order to get around the issue of certain frames
having names that could overlap, func_frame_drop
surrounds names with commas for the purposes of
comparison.

The buffer is allocated and printed to properly,
but the original buffer is used for comparison.
In most cases, this wouldn't have had any effect,
but that was not the intention behind the buffer.
This updates the code to reference the modified
buffer instead.

ASTERISK-29854 #close

Change-Id: I430b52e14e712d0e62a23aa3b5644fe958b684a7
2022-01-31 08:55:04 -06:00
Naveen Albert 5f59e0d36f documentation: Document built-in system and channel vars
Documentation for built-in special system and channel
vars is currently outdated, and updating is a manual
process since there is no XML documentation for these
anywhere.

This adds documentation for system vars to func_env
and for channel vars to func_channel so that they
appear along with the corresponding fields that would
be accessed using a function.

ASTERISK-29848 #close

Change-Id: I6997f925c4a45fffe71321861f5898a8b7182fa9
2022-01-12 08:20:21 -06:00
Naveen Albert b64e894650 func_json: Adds JSON_DECODE function
Adds the JSON_DECODE function for parsing JSON in the
dialplan. JSON parsing already exists in the Asterisk
core and is used for many different things. This
function exposes the basic parsing capability to
the user in the dialplan, for instance, in conjunction
with CURL for using API responses.

ASTERISK-29706 #close

Change-Id: Iea60c49a7358dfdc2db60803cdc9a742f808ba2c
2021-12-13 12:25:08 -06:00
Alexander Traud cc025026b7 progdocs: Fix for Doxygen, the hidden parts.
ASTERISK-29779

Change-Id: If338163488498f65fa7248b60e80299c0a928e4b
2021-12-02 10:37:38 -06:00
Naveen Albert 24a04054ad documentation: Standardize examples
Most examples in the XML documentation use the
example tag to demonstrate examples, which gets
parsed specially in the Wiki to make it easier
to follow for users.

This fixes a few modules to use the example
tag instead of vanilla para tags to bring them
in line with the standard syntax.

ASTERISK-29777 #close

Change-Id: I9acb6cc5faf1d220e73c6dd28592371d768d279b
2021-12-01 12:27:30 -06:00
Alexander Traud 00fc7212bd odbc: Fix for Doxygen.
ASTERISK-29754

Change-Id: Ia09eb68d283d201d9a6fbeccfc0efe83fe0502a5
2021-11-19 02:50:36 -06:00
Josh Soref 1b1f5f9f67 funcs: Spelling fixes
Correct typos of the following word families:

effectively
emitted
expect
anthony

ASTERISK-29714

Change-Id: Ic16f9ec855bb6d14ec8e170b90af9a36b06d488a
2021-11-15 19:28:27 -06:00
Sean Bright 886983b114 func_talkdetect.c: Fix logical errors in silence detection.
There are 3 separate changes here:

1. The documentation erroneously stated that the dsp_talking_threshold
   argument was a number of milliseconds when it is actually an energy
   level used by the DSP code to classify talking vs. silence.

2. Fixes a copy paste error in the argument handling code.

3. Don't erroneously switch to the talking state if we aren't actively
   handling a frame we've classified as talking.

Patch inspired by one provided by Moritz Fain (License #6961).

ASTERISK-27816 #close

Change-Id: I5953fd570b98b49c41cee55bfe3b941753fb2511
2021-10-19 10:24:52 -05:00
Naveen Albert d900130021 func_vmcount: Add support for multiple mailboxes
Allows multiple mailboxes to be specified for VMCOUNT
instead of just one.

ASTERISK-29661 #close

Change-Id: I9108528300795fd5b607efa9d4dd7b74be031813
2021-09-22 14:30:38 -05:00
Naveen Albert de6ecd5e34 func_channel: Add CHANNEL_EXISTS function.
Adds a function to check for the existence of a channel by
name or by UNIQUEID.

ASTERISK-29656 #close

Change-Id: Ib464e9eb6e13dc683a846286798fecff4fd943cb
2021-09-22 09:13:57 -05:00
Naveen Albert b8fc77a35b func_strings: Add STRBETWEEN function
Adds the STRBETWEEN function, which can be used to insert a
substring between each character in a string. For instance,
this can be used to insert pauses between DTMF tones in a
string of digits.

ASTERISK-29627

Change-Id: Ice23009d4a8e9bb9718d2b2301d405567087d258
2021-09-10 15:53:25 -05:00
Naveen Albert e0111a56fa func_env: Add DIRNAME and BASENAME functions
Adds the DIRNAME and BASENAME functions, which are
wrappers around the corresponding C library functions.
These can be used to safely and conveniently work with
file paths and names in the dialplan.

ASTERISK-29628 #close

Change-Id: Id3aeb907f65c0ff96b6e57751ff0cb49d61db7f3
2021-09-10 11:48:10 -05:00
Naveen Albert ddf6299b8d func_sayfiles: Retrieve say file names
Up until now, all of the logic used to translate
arguments to the Say applications has been
directly coupled to playback, preventing other
modules from using this logic.

This refactors code in say.c and adds a SAYFILES
function that can be used to retrieve the file
names that would be played. These can then be
used in other applications or for other purposes.

Additionally, a SayMoney application and a SayOrdinal
application are added. Both SayOrdinal and SayNumber
are also expanded to support integers greater than
one billion.

ASTERISK-29531

Change-Id: If9718c89353b8e153d84add3cc4637b79585db19
2021-09-10 11:46:03 -05:00
Naveen Albert 85ef06d300 func_math: Return integer instead of float if possible
The MIN, MAX, and ABS functions all support float
arguments, but currently return floats even if the
arguments are all integers and the response is
a whole number, in which case the user is likely
expecting an integer. This casts the float to an integer
before printing into the response buffer if possible.

ASTERISK-29495

Change-Id: I902d29eacf3ecd0f8a6a5e433c97f0421d205488
2021-08-19 11:13:39 -05:00