asterisk/asterisk.git
7 days agoRevert "pbx_ael: Global variables are not expanded." master
Sean Bright [Sun, 19 Mar 2023 21:30:50 +0000 (16:30 -0500)]
Revert "pbx_ael: Global variables are not expanded."

This reverts commit c448dcd2f0e67acf527662574193994559ae853a.

Reason for revert: Behavior change that breaks existing dialplan.

ASTERISK-30472 #close

Change-Id: I20e44b4081d6ee0fe54cde44ac71dcf2d146f909

11 days agobridge_builtin_features: add beep via touch variable
Mike Bradeen [Wed, 1 Mar 2023 22:39:15 +0000 (15:39 -0700)]
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

11 days agores_mixmonitor: MixMonitorMute by MixMonitor ID
Mike Bradeen [Mon, 13 Mar 2023 19:27:06 +0000 (13:27 -0600)]
res_mixmonitor: MixMonitorMute by MixMonitor ID

While it is possible to create multiple mixmonitor instances
on a channel, it was not previously possible to mute individual
instances.

This change includes the ability to specify the MixMonitorID
when calling the manager action: MixMonitorMute.  This will
allow an individual MixMonitor instance to be muted via id.
This id can be stored as a channel variable using the 'i'
MixMonitor option.

As part of this change, if no MixMonitorID is specified in
the manager action MixMonitorMute, Asterisk will set the mute
flag on all MixMonitor spy-type audiohooks on the channel.
This is done via the new audiohook function:
ast_audiohook_set_mute_all.

ASTERISK-30464

Change-Id: Ibba8c7e750577aa1595a24b23316ef445245be98

2 weeks agoformat_sln: add .slin as supported file extension
Mike Bradeen [Tue, 14 Mar 2023 15:25:12 +0000 (09:25 -0600)]
format_sln: add .slin as supported file extension

Adds '.slin' to existing supported file extensions:
.sln and .raw

ASTERISK-30465

Change-Id: Ice848addc03a64c8404b87cb5d3b13399c57e496

2 weeks agocli: increase channel column width
Mike Bradeen [Mon, 6 Mar 2023 20:52:18 +0000 (13:52 -0700)]
cli: increase channel column width

For 'core show channels', the Channel name field is increased
to 64 characters and the Location name field is increased to
32 characters.

For 'core show channels verbose', the Channel name field is
increased to 80 characters, the Context is increased to 24
characters and the Extension is increased to 24 characters.

ASTERISK-30455

Change-Id: Ibec3742ce360ffc93bc56e9984c2a21dabc4d5e1

2 weeks agoapp_queue: periodic announcement configurable start time.
Jaco Kroon [Tue, 21 Feb 2023 12:24:36 +0000 (14:24 +0200)]
app_queue: periodic announcement configurable start time.

This newly introduced periodic-announce-startdelay makes it possible to
configure the initial start delay of the first periodic announcement
after which periodic-announce-frequency takes over.

ASTERISK-30437 #close
Change-Id: Ia79984b6377ef78f167ad9ea2ac084bec29955d0
Signed-off-by: Jaco Kroon <jaco@uls.co.za>

2 weeks agoapp_osplookup: Remove obsolete sample config.
Naveen Albert [Fri, 24 Feb 2023 13:48:16 +0000 (13:48 +0000)]
app_osplookup: Remove obsolete sample config.

ASTERISK_30302 previously removed app_osplookup,
but its sample config was not removed.
This removes it since nothing else uses it.

ASTERISK-30438 #close

Change-Id: Ife234208f5f197644475db4ab1af95a8551642fd

2 weeks agofunc_json: Fix JSON parsing issues.
Naveen Albert [Sun, 26 Feb 2023 15:40:15 +0000 (15:40 +0000)]
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

2 weeks agoapp_dial: Fix DTMF not relayed to caller on unanswered calls.
Naveen Albert [Sat, 4 Mar 2023 00:09:23 +0000 (00:09 +0000)]
app_dial: Fix DTMF not relayed to caller on unanswered calls.

DTMF frames are not handled in app_dial when sent towards the
caller. This means that if DTMF is sent to the calling party
and the call has not yet been answered, the DTMF is not audible.
This is now fixed by relaying DTMF frames if only a single
destination is being dialed.

ASTERISK-29516 #close

Change-Id: Iafd7430ac2915126d42dc48f0b73b262452ee027

2 weeks agoconfigure: fix detection of re-entrant resolver functions
Fabrice Fontaine [Wed, 8 Mar 2023 18:26:51 +0000 (19:26 +0100)]
configure: fix detection of re-entrant resolver functions

uClibc does not provide res_nsearch:
asterisk-16.0.0/main/dns.c:506: undefined reference to `res_nsearch'

Patch coded by Yann E. MORIN:
http://lists.busybox.net/pipermail/buildroot/2018-October/232630.html

ASTERISK-21795 #close

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
[Retrieved from:
https: //git.buildroot.net/buildroot/tree/package/asterisk/0005-configure-fix-detection-of-re-entrant-resolver-funct.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Change-Id: I79296f19e28ec764bbd1e991bf11c416d0b10563

2 weeks agores_agi: RECORD FILE plays 2 beeps.
Sean Bright [Wed, 8 Mar 2023 14:12:48 +0000 (09:12 -0500)]
res_agi: RECORD FILE plays 2 beeps.

Sending the "RECORD FILE" command without the optional
`offset_samples` argument can result in two beeps playing on the
channel.

This bug has been present since Asterisk 0.3.0 (2003-02-06).

ASTERISK-30457 #close

Change-Id: I95e88aa59378784d7f0eb648843f090e6723b787

2 weeks agoapp_senddtmf: Add SendFlash AMI action.
Naveen Albert [Sun, 26 Feb 2023 13:15:50 +0000 (13:15 +0000)]
app_senddtmf: Add SendFlash AMI action.

Adds an AMI action to send a flash event
on a channel.

ASTERISK-30440 #close

Change-Id: I4707aeecb3cd8f3e63fd0c3fe009798943c369c9

2 weeks agohttp.c: Minor simplification to HTTP status output.
Boris P. Korzun [Thu, 5 Jan 2023 12:33:08 +0000 (15:33 +0300)]
http.c: Minor simplification to HTTP status output.

Change the HTTP status page (located at /httpstatus by default) by:

* Combining the address and port into a single line.
* Changing "SSL" to "TLS"

ASTERISK-30433 #close

Change-Id: Id2ccb1218f00a68424aca2b651647d8b1f549bcb

2 weeks agomake_version: Strip svn stuff and suppress ref HEAD errors
George Joseph [Mon, 13 Mar 2023 19:35:07 +0000 (13:35 -0600)]
make_version: Strip svn stuff and suppress ref HEAD errors

* All of the code that used subversion has been removed.

* When Asterisk is checked out from a tag or commit instead
  of one of the regular branches, git would emit messages like
  "fatal: ref HEAD is not a symbolic ref" which weren't fatal
  at all.  Those are now suppressed.

Change-Id: I2a11bc9ebbaf6dfa50f53516ede50a6bac65ca3c

3 weeks agores_http_media_cache: Introduce options and customize
Holger Hans Peter Freyther [Sun, 16 Oct 2022 09:03:53 +0000 (17:03 +0800)]
res_http_media_cache: Introduce options and customize

Make the existing CURL parameters configurable and allow
to specify the usable protocols, proxy and DNS timeout.

ASTERISK-30340

Change-Id: I2eb02ef44190e026716720419bcbdbcc8125777b

3 weeks agocontrib: rc.archlinux.asterisk uses invalid redirect.
Sean Bright [Thu, 2 Mar 2023 14:59:51 +0000 (09:59 -0500)]
contrib: rc.archlinux.asterisk uses invalid redirect.

`rc.archlinux.asterisk`, which explicitly requests bash in its
shebang, uses the following command syntax:

  ${DAEMON} -rx "core stop now" > /dev/null 2&>1

The intent of which is to execute:

  ${DAEMON} -rx "core stop now"

While sending both stdout and stderr to `/dev/null`. Unfortunately,
because the `&` is in the wrong place, bash is interpreting the `2` as
just an additional argument to the `$DAEMON` command and not as a file
descriptor and proceeds to use the bashism `&>` to send stderr and
stdout to a file named `1`.

So we clean it up and just use bash's shortcut syntax.

Issue raised and a fix suggested (but not used) by peutch on GitHub¹.

ASTERISK-30449 #close

1. https://github.com/asterisk/asterisk/pull/31

Change-Id: Ie279bf4efb4d95cbf507313483d316e977303d19

3 weeks agomain/iostream.c: fix build with libressl
Fabrice Fontaine [Sat, 25 Feb 2023 10:27:12 +0000 (11:27 +0100)]
main/iostream.c: fix build with libressl

Fix the following build failure with libressl by using SSL_is_server
which is available since version 2.7.0 and
https://github.com/libressl-portable/openbsd/commit/d7ec516916c5eaac29b02d7a8ac6570f63b458f7:

iostream.c: In function 'ast_iostream_close':
iostream.c:559:41: error: invalid use of incomplete typedef 'SSL' {aka 'struct ssl_st'}
  559 |                         if (!stream->ssl->server) {
      |                                         ^~

ASTERISK-30107 #close

Fixes: - http://autobuild.buildroot.org/results/ce4d62d00bb77ba5b303cacf6be7e350581a62f9
Change-Id: Iea7f34970297f2fb50285d73462d0174ba7e9587

4 weeks agores_pjsip: Replace invalid UTF-8 sequences in callerid name
George Joseph [Thu, 16 Feb 2023 16:05:30 +0000 (09:05 -0700)]
res_pjsip: Replace invalid UTF-8 sequences in callerid name

* Added a new function ast_utf8_replace_invalid_chars() to
  utf8.c that copies a string replacing any invalid UTF-8
  sequences with the Unicode specified U+FFFD replacement
  character.  For example:  "abc\xffdef" becomes "abc\uFFFDdef".
  Any UTF-8 compliant implementation will show that character
  as a � character.

* Updated res_pjsip:set_id_from_hdr() to use
  ast_utf8_replace_invalid_chars and print a warning if any
  invalid sequences were found during the copy.

* Updated stasis_channels:ast_channel_publish_varset to use
  ast_utf8_replace_invalid_chars and print a warning if any
  invalid sequences were found during the copy.

ASTERISK-27830

Change-Id: I4ffbdb19c80bf0efc675d40078a3ca4f85c567d8

4 weeks agotest.c: Avoid passing -1 to FD_* family of functions.
Sean Bright [Tue, 28 Feb 2023 00:35:11 +0000 (19:35 -0500)]
test.c: Avoid passing -1 to FD_* family of functions.

This avoids buffer overflow errors when running tests that capture
output from child processes.

This also corrects a copypasta in an off-nominal error message.

Change-Id: Ib482847a3515364f14c7e7a0c0a4213851ddb10d

4 weeks agochan_iax2: Fix jitterbuffer regression prior to receiving audio.
Naveen Albert [Wed, 14 Dec 2022 16:00:51 +0000 (16:00 +0000)]
chan_iax2: Fix jitterbuffer regression prior to receiving audio.

ASTERISK_29392 (a security fix) introduced a regression by
not processing frames when we don't have an audio format.

Currently, chan_iax2 only calls jb_get to read frames from
the jitterbuffer when the voiceformat has been set on the pvt.
However, this only happens when we receive a voice frame, which
means that prior to receiving voice frames, other types of frames
get stalled completely in the jitterbuffer.

To fix this, we now fallback to using the format negotiated during
call setup until we've actually received a voice frame with a format.
This ensures we're always able to read from the jitterbuffer.

ASTERISK-30354 #close
ASTERISK-30162 #close

Change-Id: Ie4fd1e8e088a145ad89e0427c2100a530e964fe9

4 weeks agotest_crypto.c: Fix getcwd(…) build error.
Sean Bright [Mon, 27 Feb 2023 21:35:57 +0000 (16:35 -0500)]
test_crypto.c: Fix getcwd(…) build error.

`getcwd(…)` is decorated with the `warn_unused_result` attribute and
therefore needs its return value checked.

Change-Id: Idcccb20a0abf293202c28633d0e9ee0f6a9dbe93

4 weeks agopjproject_bundled: fix cross-compilation with ssl libs
Nick French [Sat, 11 Feb 2023 12:58:43 +0000 (06:58 -0600)]
pjproject_bundled: fix cross-compilation with ssl libs

Asterisk makefiles auto-detect ssl library availability,
then they assume that pjproject makefiles will also autodetect
an ssl library at the same time, so they do not pass on the
autodetection result to pjproject.

This normally works, except the pjproject makefiles disables
autodetection when cross-compiling.

Fix by explicitly configuring pjproject to use ssl if we
have been told to use it or it was autodetected

ASTERISK-30424 #close

Change-Id: I8fe2999ea46710e21d1d55a1bed92769c6ebded9

4 weeks agores_phoneprov.c: Multihomed SERVER cache prevention
cmaj [Sun, 8 Jan 2023 05:04:57 +0000 (22:04 -0700)]
res_phoneprov.c: Multihomed SERVER cache prevention

Phones moving between subnets on multi-homed server have their
initially connected interface IP cached in the SERVER variable,
even when it is not specified in the configuration files. This
prevents phones from obtaining the correct SERVER variable value
when they move to another subnet.

ASTERISK-30388 #close
Reported-by: cmaj

Change-Id: I1d18987a9d58e85556b4c4a6814ce7006524cc92

4 weeks agoapp_read: Add an option to return terminator on empty digits.
Mike Bradeen [Mon, 30 Jan 2023 23:14:30 +0000 (16:14 -0700)]
app_read: Add an option to return terminator on empty digits.

Adds 'e' option to allow Read() to return the terminator as the
dialed digits in the case where only the terminator is entered.

ie; if "#" is entered, return "#" if the 'e' option is set and ""
if it is not.

ASTERISK-30411

Change-Id: I49f3221824330a193a20c660f99da0f1fc2cbbc5

4 weeks agoapp_directory: Add a 'skip call' option.
Mike Bradeen [Fri, 27 Jan 2023 20:23:59 +0000 (13:23 -0700)]
app_directory: Add a 'skip call' option.

Adds 's' option to skip calling the extension and instead set the
extension as DIRECTORY_EXTEN channel variable.

ASTERISK-30405

Change-Id: Ib9d9db1ba5b7524594c640461b4aa8f752db8299

4 weeks agoapp_senddtmf: Add option to answer target channel.
Mike Bradeen [Mon, 6 Feb 2023 15:54:56 +0000 (08:54 -0700)]
app_senddtmf: Add option to answer target channel.

Adds a new option to SendDTMF() which will answer the specified
channel if it is not already up. If no channel is specified, the
current channel will be answered instead.

ASTERISK-30422

Change-Id: Iddcbd501fcdf9fef0f453b7a8115a90b11f1d085

5 weeks agores_pjsip: Prevent SEGV in pjsip_evsub_send_request
Mike Bradeen [Tue, 21 Feb 2023 20:25:28 +0000 (13:25 -0700)]
res_pjsip: Prevent SEGV in pjsip_evsub_send_request

contributed pjproject - patch to check sub->pending_notify
in evsub.c:on_tsx_state before calling
pjsip_evsub_send_request()

res_pjsip_pubsub - change post pjsip 2.13 behavior to use
pubsub_on_refresh_timeout to avoid the ao2_cleanup call on
the sub_tree. This is is because the final NOTIFY send is no
longer the last place the sub_tree is referenced.

ASTERISK-30419

Change-Id: Ib5cc662ce578e9adcda312e16c58a10b6453e438

6 weeks agoapp_queue: Minor docs and logging fixes for UnpauseQueueMember.
Sean Bright [Thu, 2 Feb 2023 14:19:18 +0000 (09:19 -0500)]
app_queue: Minor docs and logging fixes for UnpauseQueueMember.

ASTERISK-30417 #close

Change-Id: I7534e7a925bf92a7b5a5347f5f54225768c162fe

6 weeks agoapp_queue: Reset all queue defaults before reload.
Sean Bright [Tue, 31 Jan 2023 14:40:54 +0000 (09:40 -0500)]
app_queue: Reset all queue defaults before reload.

Several queue fields were not being set to their default value during
a reload.

Additionally added some sample configuration options that were missing
from queues.conf.sample.

Change-Id: I3a88c7877af91752b1b46a0c087384f7eb9c47e4

7 weeks agores_pjsip: Upgraded bundled pjsip to 2.13
Mike Bradeen [Fri, 20 Jan 2023 22:50:44 +0000 (15:50 -0700)]
res_pjsip: Upgraded bundled pjsip to 2.13

Removed multiple patches.

Code chages in res_pjsip_pubsub due to changes in evsub.

Pjsip now calls on_evsub_state() before on_rx_refresh(),
so the sub tree deletion that used to take place in
on_evsub_state() now must take place in on_rx_refresh().

Additionally, pjsip now requires that you send the NOTIFY
from within on_rx_refresh(), otherwise it will assert
when going to send the 200 OK. The idea is that it will
look for this NOTIFY and cache it until after sending the
response in order to deal with the self-imposed message
mis-order. Asterisk previously dealt with this by pushing
the NOTIFY in on_rx_refresh(), but pjsip now forces us
to use it's method.

Changes were required to configure in order to detect
which way pjsip handles this as the two are not
compatible for the reasons mentioned above.

A corresponding change in testsuite is required in order
to deal with the small interal timing changes caused by
moving the NOTIFY send.

ASTERISK-30325

Change-Id: I50b00cac89d950d3511d7b250a1c641965d9fe7f

8 weeks agodoxygen: Fix doxygen errors.
Sean Bright [Mon, 30 Jan 2023 21:17:08 +0000 (16:17 -0500)]
doxygen: Fix doxygen errors.

Change-Id: Ic50e95b4fc10f74ab15416d908e8a87ee8ec2f85

8 weeks agoapp_signal: Add signaling applications
Naveen Albert [Thu, 6 Jan 2022 22:11:44 +0000 (22:11 +0000)]
app_signal: Add signaling applications

Adds the Signal and WaitForSignal
applications, which can be used for inter-channel
signaling in the dialplan.

Signal supports sending a signal to other channels
listening for a signal of the same name, with an
optional data payload. The signal is received by
all channels waiting for that named signal.

ASTERISK-29810 #close

Change-Id: Ic34439de3d60f8609357666a465c354d81f5fef3

8 weeks agoapp_directory: add ability to specify configuration file
Mike Bradeen [Wed, 25 Jan 2023 22:27:31 +0000 (15:27 -0700)]
app_directory: add ability to specify configuration file

Adds option to app_directory to specify a filename from which to
read configuration instead of voicemail.conf ie;

same => n,Directory(,,c(directory.conf))

This configuration should contain a list of extensions using the
voicemail.conf format, ie;

2020=2020,Dog Dog,,,,attach=no|saycid=no|envelope=no|delete=no

ASTERISK-30404

Change-Id: Id58ccb1344ad1e563fa10db12f172fbd104a9d13

8 weeks agofunc_json: Enhance parsing capabilities of JSON_DECODE
Naveen Albert [Sat, 12 Feb 2022 21:59:52 +0000 (21:59 +0000)]
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

8 weeks agores_pjsip_session: Add overlap_context option.
Naveen Albert [Thu, 13 Oct 2022 13:45:26 +0000 (13:45 +0000)]
res_pjsip_session: Add overlap_context option.

Adds the overlap_context option, which can be used
to explicitly specify a context to use for overlap
dialing extension matches, rather than forcibly
using the context configured for the endpoint.

ASTERISK-30262 #close

Change-Id: Ibbcd4a8b11402428a187fb56b8d4e7408774a0db

8 weeks agores_stasis_snoop: Fix snoop crash
sungtae kim [Wed, 4 Jan 2023 12:35:20 +0000 (21:35 +0900)]
res_stasis_snoop: Fix snoop crash

Added NULL pointer check and channel lock to prevent resource release
while the chanspy is processing.

ASTERISK-29604

Change-Id: Ibdc675f98052da32333b19685b1708a3751b6d24

2 months agopbx_ael: Global variables are not expanded.
Sean Bright [Thu, 26 Jan 2023 20:18:08 +0000 (15:18 -0500)]
pbx_ael: Global variables are not expanded.

Variable references within global variable assignments are now
expanded rather than being included literally.

ASTERISK-30406 #close

Change-Id: I136e8d6395e90a4c92d9777a46a7bc3edb08d05d

2 months agores_monitor: Remove deprecated module.
Mike Bradeen [Sat, 19 Nov 2022 01:24:38 +0000 (18:24 -0700)]
res_monitor: Remove deprecated module.

ASTERISK-30303

Change-Id: I0462caefb4f9544e2e2baa23c498858310b52d50

2 months agoapp_playback.c: Fix PLAYBACKSTATUS regression.
Sean Bright [Thu, 5 Jan 2023 16:41:37 +0000 (11:41 -0500)]
app_playback.c: Fix PLAYBACKSTATUS regression.

In Asterisk 11, if a channel was redirected away during Playback(),
the PLAYBACKSTATUS variable would be set to SUCCESS. In Asterisk 12
(specifically commit 7d9871b3940fa50e85039aef6a8fb9870a7615b9) that
behavior was inadvertently changed and the same operation would result
in the PLAYBACKSTATUS variable being set to FAILED. The Asterisk 11
behavior has been restored.

Partial fix for ASTERISK~25661.

Change-Id: I53f54e56b59b61c99403a481b6cb8d88b5a559ff

2 months agores_rtp_asterisk: Don't use double math to generate timestamps
George Joseph [Wed, 11 Jan 2023 17:17:02 +0000 (10:17 -0700)]
res_rtp_asterisk: Don't use double math to generate timestamps

Rounding issues with double math were causing rtp timestamp
slips in outgoing packets.  We're now back to integer math
and are getting no more slips.

ASTERISK-30391

Change-Id: I6ba992b49ffdf9ebea074581dfa784a188c661a4

2 months agoapp_macro: Remove deprecated module.
Mike Bradeen [Mon, 12 Dec 2022 17:12:57 +0000 (10:12 -0700)]
app_macro: Remove deprecated module.

For most modules that interacted with app_macro, this change is limited
to no longer looking for the current context from the macrocontext when
set.  Additionally, the following modules are impacted:

app_dial - no longer supports M^ connected/redirecting macro
app_minivm - samples written using macro will no longer work.
The sample needs a re-write

app_queue - can no longer a macro on the called party's channel.
Use gosub which is currently supported

ccss - no callback macro, gosub only

app_voicemail - no macro support

channel  - remove macrocontext and priority, no connected line or
redirection macro options
options - stdexten is deprecated to gosub as the default and only
pbx - removed macrolock
pbx_dundi - no longer look for macro

snmp - removed macro context, exten, and priority

ASTERISK-30304

Change-Id: I830daab293117179b8d61bd4df0d971a1b3d07f6

2 months agoformat_wav: replace ast_log(LOG_DEBUG, ...) by ast_debug(1, ...)
Alexei Gradinari [Fri, 6 Jan 2023 16:06:09 +0000 (11:06 -0500)]
format_wav: replace ast_log(LOG_DEBUG, ...) by ast_debug(1, ...)

Each playback of WAV files results in logging
"Skipping unknown block 'LIST'".

To prevent unnecessary flooding of this DEBUG log this patch replaces
ast_log(LOG_DEBUG, ...) by ast_debug(1, ...).

Change-Id: Iaa09cf19c5348a05385518fdb8cb181b45fe05f0

2 months agores_pjsip_rfc3326: Add SIP causes support for RFC3326
Igor Goncharovsky [Fri, 18 Nov 2022 02:16:50 +0000 (08:16 +0600)]
res_pjsip_rfc3326: Add SIP causes support for RFC3326

Add ability to set HANGUPCAUSE when SIP causecode received in BYE (in addition to currently supported Q.850).

ASTERISK-30319 #close

Change-Id: I3f55622dc680ce713a2ffb5a458ef5dd39fcf645

2 months agores_rtp_asterisk: Asterisk Media Experience Score (MES)
George Joseph [Fri, 28 Oct 2022 10:57:56 +0000 (04:57 -0600)]
res_rtp_asterisk: Asterisk Media Experience Score (MES)

-----------------

This commit reinstates MES with some casting fixes to the
functions in time.h that convert between doubles and timeval
structures.  The casting issues were causing incorrect
timestamps to be calculated which caused transcoding from/to
G722 to produce bad or no audio.

ASTERISK-30391

-----------------

This module has been updated to provide additional
quality statistics in the form of an Asterisk
Media Experience Score.  The score is avilable using
the same mechanisms you'd use to retrieve jitter, loss,
and rtt statistics.  For more information about the
score and how to retrieve it, see
https://wiki.asterisk.org/wiki/display/AST/Media+Experience+Score

* Updated chan_pjsip to set quality channel variables when a
  call ends.
* Updated channels/pjsip/dialplan_functions.c to add the ability
  to retrieve the MES along with the existing rtcp stats when
  using the CHANNEL dialplan function.
* Added the ast_debug_rtp_is_allowed and ast_debug_rtcp_is_allowed
  checks for debugging purposes.
* Added several function to time.h for manipulating time-in-samples
  and times represented as double seconds.
* Updated rtp_engine.c to pass through the MES when stats are
  requested.  Also debug output that dumps the stats when an
  rtp instance is destroyed.
* Updated res_rtp_asterisk.c to implement the calculation of the
  MES.  In the process, also had to update the calculation of
  jitter.  Many debugging statements were also changed to be
  more informative.
* Added a unit test for internal testing.  The test should not be
  run during normal operation and is disabled by default.

Change-Id: I4fce265965e68c3fdfeca55e614371ee69c65038

2 months agoRevert "res_rtp_asterisk: Asterisk Media Experience Score (MES)"
George Joseph [Mon, 9 Jan 2023 13:21:46 +0000 (07:21 -0600)]
Revert "res_rtp_asterisk: Asterisk Media Experience Score (MES)"

This reverts commit e66c5da145b4545428fca768db7fb0921156af98.

Reason for revert: Issue when transcoding to/from g722

Change-Id: I12853c5b1d3a77f5b9200f41908fd238a17159dc

2 months agohttp.c: Fix NULL pointer dereference bug
Boris P. Korzun [Wed, 28 Dec 2022 19:33:42 +0000 (22:33 +0300)]
http.c: Fix NULL pointer dereference bug

If native HTTP is disabled but HTTPS is enabled and status page enabled
too, Core/HTTP crashes while loading. 'global_http_server' references
to NULL, but the status page tries to dereference it.

The patch adds a check for HTTP is enabled.

ASTERISK-30379 #close

Change-Id: I11b02fc920b72aaed9c809fc43210523ccfdc249

2 months agoloader: Allow declined modules to be unloaded.
Naveen Albert [Thu, 8 Dec 2022 21:44:25 +0000 (21:44 +0000)]
loader: Allow declined modules to be unloaded.

Currently, if a module declines to load, dlopen is called
to register the module but dlclose never gets called.
Furthermore, loader.c currently doesn't allow dlclose
to ever get called on the module, since it declined to
load and the unload function bails early in this case.

This can be problematic if a module is updated, since the
new module cannot be loaded into memory since we haven't
closed all references to it. To fix this, we now allow
modules to be unloaded, even if they never "loaded" in
Asterisk itself, so that dlclose is called and the module
can be properly cleaned up, allowing the updated module
to be loaded from scratch next time.

ASTERISK-30345 #close

Change-Id: Ifc743aadfa85ebe3284e02a63e124dafa64988d5

2 months agoapp_broadcast: Add Broadcast application
Naveen Albert [Mon, 15 Aug 2022 20:04:38 +0000 (20:04 +0000)]
app_broadcast: Add Broadcast application

Adds a new application, Broadcast, which can be used for
one-to-many transmission and many-to-one reception of
channel audio in Asterisk. This is similar to ChanSpy,
except it is designed for multiple channel targets instead
of a single one. This can make certain kinds of audio
manipulation more efficient and streamlined. New kinds
of audio injection impossible with ChanSpy are also made
possible.

ASTERISK-30180 #close

Change-Id: I7ba72f765dbab9b58deeae028baca3f4f8377726

2 months agofunc_frame_trace: Print text for text frames.
Naveen Albert [Tue, 13 Dec 2022 20:35:19 +0000 (20:35 +0000)]
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

2 months agoapp_cdr: Remove deprecated application and option.
Naveen Albert [Thu, 22 Dec 2022 01:58:54 +0000 (01:58 +0000)]
app_cdr: Remove deprecated application and option.

This removes the deprecated NoCDR application, which
was deprecated in Asterisk 12, having long been fully
superseded by the CDR_PROP function.

The deprecated e option to ResetCDR is also removed
for the same reason.

ASTERISK-30371 #close

Change-Id: Id9ed094d8e4baf98bcbc610035c2295bfafe9ec0

2 months agores_http_media_cache: Do not crash when there is no extension
Holger Hans Peter Freyther [Fri, 16 Dec 2022 07:00:42 +0000 (15:00 +0800)]
res_http_media_cache: Do not crash when there is no extension

Do not crash when a URL has no path component as in this case the
ast_uri_path function will return NULL. Make the code cope with not
having a path.

The below would crash
> media cache create http://google.com /tmp/foo.wav

Thread 1 "asterisk" received signal SIGSEGV, Segmentation fault.
0x0000ffff836616cc in strrchr () from /lib/aarch64-linux-gnu/libc.so.6
(gdb) bt
 #0  0x0000ffff836616cc in strrchr () from /lib/aarch64-linux-gnu/libc.so.6
 #1  0x0000ffff43d43a78 in file_extension_from_string (str=<optimized out>, buffer=buffer@entry=0xffffca9973c0 "",
    capacity=capacity@entry=64) at res_http_media_cache.c:288
 #2  0x0000ffff43d43bac in file_extension_from_url_path (bucket_file=bucket_file@entry=0x3bf96568,
    buffer=buffer@entry=0xffffca9973c0 "", capacity=capacity@entry=64) at res_http_media_cache.c:378
 #3  0x0000ffff43d43c74 in bucket_file_set_extension (bucket_file=bucket_file@entry=0x3bf96568) at res_http_media_cache.c:392
 #4  0x0000ffff43d43d10 in bucket_file_run_curl (bucket_file=0x3bf96568) at res_http_media_cache.c:555
 #5  0x0000ffff43d43f74 in bucket_http_wizard_create (sorcery=<optimized out>, data=<optimized out>, object=<optimized out>)
    at res_http_media_cache.c:613
 #6  0x0000000000487638 in bucket_file_wizard_create (sorcery=<optimized out>, data=<optimized out>, object=<optimized out>)
    at bucket.c:191
 #7  0x0000000000554408 in sorcery_wizard_create (object_wizard=object_wizard@entry=0x3b9f0718,
    details=details@entry=0xffffca9974a8) at sorcery.c:2027
 #8  0x0000000000559698 in ast_sorcery_create (sorcery=<optimized out>, object=object@entry=0x3bf96568) at sorcery.c:2077
 #9  0x00000000004893a4 in ast_bucket_file_create (file=file@entry=0x3bf96568) at bucket.c:727
 #10 0x00000000004f877c in ast_media_cache_create_or_update (uri=0x3bfa1103 "https://google.com",
    file_path=0x3bfa1116 "/tmp/foo.wav", metadata=metadata@entry=0x0) at media_cache.c:335
 #11 0x00000000004f88ec in media_cache_handle_create_item (e=<optimized out>, cmd=<optimized out>, a=0xffffca9976b8)
    at media_cache.c:640

ASTERISK-30375 #close

Change-Id: I6a9433688cb5d3d4be8758b7642d923bdde6c273

2 months agomanager: Fix appending variables.
Naveen Albert [Thu, 22 Dec 2022 01:01:01 +0000 (01:01 +0000)]
manager: Fix appending variables.

The if statement here is always false after the for
loop finishes, so variables are never appended.
This removes that to properly append to the end
of the variable list.

ASTERISK-30351 #close
Reported by: Sebastian Gutierrez

Change-Id: I1b7f8b85a8918f6a814cb933a479d4278cf16199

2 months agojson.h: Add ast_json_object_real_get.
Naveen Albert [Fri, 16 Dec 2022 18:25:52 +0000 (18:25 +0000)]
json.h: Add ast_json_object_real_get.

json.h contains macros to get a string and an integer
from a JSON object. However, the macro to do this for
JSON reals is missing. This adds that.

ASTERISK-30361 #close

Change-Id: I8d0e28d763febf27b05801cdc83b73282aa6ee7a

2 months agores_pjsip_transport_websocket: Add remote port to transport
George Joseph [Fri, 23 Dec 2022 12:02:43 +0000 (05:02 -0700)]
res_pjsip_transport_websocket: Add remote port to transport

When Asterisk receives a new websocket conenction, it creates a new
pjsip transport for it and copies connection data into it.  The
transport manager then uses the remote IP address and port on the
transport to create a monitor for each connection.  However, the
remote port wasn't being copied, only the IP address which meant
that the transport manager was creating only 1 monitoring entry for
all websocket connections from the same IP address. Therefore, if
one of those connections failed, it deleted the transport taking
all the the connections from that same IP address with it.

* We now copy the remote port into the created transport and the
  transport manager behaves correctly.

ASTERISK-30369

Change-Id: Ib506d40897ea6286455ac0be4dfbb0ed43b727e1

2 months agochan_sip: Remove deprecated module.
Mike Bradeen [Mon, 28 Nov 2022 20:05:21 +0000 (13:05 -0700)]
chan_sip: Remove deprecated module.

ASTERISK-30297

Change-Id: Ic700168c80b68879d9cee8bb07afe2712fb17996

2 months agores_rtp_asterisk: Asterisk Media Experience Score (MES)
George Joseph [Fri, 28 Oct 2022 10:57:56 +0000 (04:57 -0600)]
res_rtp_asterisk: Asterisk Media Experience Score (MES)

This module has been updated to provide additional
quality statistics in the form of an Asterisk
Media Experience Score.  The score is avilable using
the same mechanisms you'd use to retrieve jitter, loss,
and rtt statistics.  For more information about the
score and how to retrieve it, see
https://wiki.asterisk.org/wiki/display/AST/Media+Experience+Score

* Updated chan_pjsip to set quality channel variables when a
  call ends.
* Updated channels/pjsip/dialplan_functions.c to add the ability
  to retrieve the MES along with the existing rtcp stats when
  using the CHANNEL dialplan function.
* Added the ast_debug_rtp_is_allowed and ast_debug_rtcp_is_allowed
  checks for debugging purposes.
* Added several function to time.h for manipulating time-in-samples
  and times represented as double seconds.
* Updated rtp_engine.c to pass through the MES when stats are
  requested.  Also debug output that dumps the stats when an
  rtp instance is destroyed.
* Updated res_rtp_asterisk.c to implement the calculation of the
  MES.  In the process, also had to update the calculation of
  jitter.  Many debugging statements were also changed to be
  more informative.
* Added a unit test for internal testing.  The test should not be
  run during normal operation and is disabled by default.

ASTERISK-30280

Change-Id: I458cb9a311e8e5dc1db769b8babbcf2e093f107a

2 months agopbx_app: Update outdated pbx_exec channel snapshots.
Naveen Albert [Wed, 21 Dec 2022 15:01:20 +0000 (15:01 +0000)]
pbx_app: Update outdated pbx_exec channel snapshots.

pbx_exec makes a channel snapshot before executing applications.
This doesn't cause an issue during normal dialplan execution
where pbx_exec is called over and over again in succession.
However, if pbx_exec is called "one off", e.g. using
ast_pbx_exec_application, then a channel snapshot never ends
up getting made after the executed application returns, and
inaccurate snapshot information will linger for a while, causing
"core show channels", etc. to show erroneous info.

This is fixed by manually making a channel snapshot at the end
of ast_pbx_exec_application, since we anticipate that pbx_exec
might not get called again immediately.

ASTERISK-30367 #close

Change-Id: I2a5131053aa9d11badbc0ef2ef40b1f83d0af086

3 months agores_pjsip_session: Use Caller ID for extension matching.
Naveen Albert [Sat, 26 Nov 2022 12:54:29 +0000 (12:54 +0000)]
res_pjsip_session: Use Caller ID for extension matching.

Currently, there is no Caller ID available to us when
checking for an extension match when handling INVITEs.
As a result, extension patterns that depend on the Caller ID
are not matched and calls may be incorrectly rejected.

The Caller ID is not available because the supplement that
adds Caller ID to the session does not execute until after
this check. Supplement callbacks cannot yet be executed
at this point since the session is not yet in the appropriate
state.

To fix this without impacting existing behavior, the Caller ID
number is now retrieved before attempting to pattern match.
This ensures pattern matching works correctly and there is
no behavior change to the way supplements are called.

ASTERISK-28767 #close

Change-Id: Iec7f5a3b90e51b65ccf74342f96bf80314b7cfc7

3 months agopbx_builtins: Remove deprecated and defunct functionality.
Naveen Albert [Tue, 29 Nov 2022 21:44:28 +0000 (21:44 +0000)]
pbx_builtins: Remove deprecated and defunct functionality.

This removes the ImportVar and SetAMAFlags applications
which have been deprecated since Asterisk 12, but were
never removed previously.

Additionally, it removes remnants of defunct options
that themselves were removed years ago.

ASTERISK-30335 #close

Change-Id: I749520c7b08d4c9d5eebbf640d4fbc81950eda8d

3 months agores_pjsip_sdp_rtp.c: Use correct timeout when put on hold.
Ben Ford [Mon, 12 Dec 2022 18:42:17 +0000 (12:42 -0600)]
res_pjsip_sdp_rtp.c: Use correct timeout when put on hold.

When a call is put on hold and it has moh_passthrough and rtp_timeout
set on the endpoint, the wrong timeout will be used. rtp_timeout_hold is
expected to be used, but rtp_timeout is used instead. This change adds a
couple of checks for locally_held to determine if rtp_timeout_hold needs
to be used instead of rtp_timeout.

ASTERISK-30350

Change-Id: I7b106fc244332014216d12bba851cefe884cc25f

3 months agoapp_voicemail_odbc: Fix string overflow warning.
Naveen Albert [Mon, 14 Nov 2022 13:12:19 +0000 (13:12 +0000)]
app_voicemail_odbc: Fix string overflow warning.

Fixes a negative offset warning by initializing
the buffer to empty.

Additionally, although it doesn't currently complain
about it, the size of a buffer is increased to
accomodate the maximum size contents it could have.

ASTERISK-30240 #close

Change-Id: I8eecedf14d3f2a75864797f802277cac89a32877

3 months agostreams: Ensure that stream is closed in ast_stream_and_wait on error
Peter Fern [Tue, 22 Nov 2022 03:37:19 +0000 (14:37 +1100)]
streams:  Ensure that stream is closed in ast_stream_and_wait on error

When ast_stream_and_wait returns an error (for example, when attempting
to stream to a channel after hangup) the stream is not closed, and
callers typically do not check the return code. This results in leaking
file descriptors, leading to resource exhaustion.

This change ensures that the stream is closed in case of error.

ASTERISK-30198 #close
Reported-by: Julien Alie

Change-Id: Ie46b67314590ad75154595a3d34d461060b2e803

3 months agofunc_callerid: Warn about invalid redirecting reason.
Naveen Albert [Sat, 26 Nov 2022 00:03:57 +0000 (00:03 +0000)]
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

3 months agoapp_sendtext: Remove references to removed applications.
Naveen Albert [Sat, 10 Dec 2022 22:51:11 +0000 (22:51 +0000)]
app_sendtext: Remove references to removed applications.

Removes see-also references to applications that don't
exist anymore (removed in Asterisk 19),
so these dead links don't show up on the wiki.

ASTERISK-30347 #close

Change-Id: I9539bc30f57cd65aa4e2d5ce8185eafa09567909

3 months agores_pjsip: Fix path usage in case dialing with '@'
Igor Goncharovsky [Fri, 4 Nov 2022 10:11:07 +0000 (16:11 +0600)]
res_pjsip: Fix path usage in case dialing with '@'

Fix aor lookup on sip path addition. Issue happens in case of dialing
with @ and overriding user part of RURI.

ASTERISK-30100 #close
Reported-by: Yury Kirsanov

Change-Id: I3f2c42a583578c94397b113e32ca3ebf2d600e13

3 months agores_geoloc: fix NULL pointer dereference bug
Alexandre Fournier [Fri, 9 Dec 2022 19:37:13 +0000 (14:37 -0500)]
res_geoloc: fix NULL pointer dereference bug

The `ast_geoloc_datastore_add_eprofile` function does not return 0 on
success, it returns the size of the underlying datastore. This means
that the datastore will be freed and its pointer set to NULL when no
error occured at all.

ASTERISK-30346

Change-Id: Iea9b209bd1244cc57b903b9496cb680c356e4bb9

3 months agores_pjsip_aoc: Don't assume a body exists on responses.
Joshua C. Colp [Tue, 13 Dec 2022 15:25:17 +0000 (11:25 -0400)]
res_pjsip_aoc: Don't assume a body exists on responses.

When adding AOC to an outgoing response the code
assumed that a body would exist for comparing the
Content-Type. This isn't always true.

The code now checks to make sure the response has
a body before checking the Content-Type.

ASTERISK-21502

Change-Id: Iaead371434fc3bc693dad487228106a7d7a5ac76

3 months agoapp_if: Fix format truncation errors.
Naveen Albert [Mon, 12 Dec 2022 15:16:17 +0000 (15:16 +0000)]
app_if: Fix format truncation errors.

Fixes format truncation warnings in gcc 12.2.1.

ASTERISK-30349 #close

Change-Id: I42be4edf0284358b906e765d1966b6b9d66e1d3c

3 months agochan_alsa: Remove deprecated module.
Mike Bradeen [Mon, 14 Nov 2022 19:44:09 +0000 (12:44 -0700)]
chan_alsa: Remove deprecated module.

ASTERISK-30298

Change-Id: I5c8afb781528afdf55d237e3bffa5e4a862ae8c7

3 months agomanager: AOC-S support for AOCMessage
Michael Kuron [Tue, 1 Nov 2022 20:37:30 +0000 (21:37 +0100)]
manager: AOC-S support for AOCMessage

ASTERISK-21502

Change-Id: I051b778f8c862d3b4794d28f2f3d782316707b08

3 months agochan_mgcp: Remove deprecated module.
Mike Bradeen [Tue, 15 Nov 2022 17:03:21 +0000 (10:03 -0700)]
chan_mgcp: Remove deprecated module.

Also removes res_pktcops to avoid merge conflicts
with ASTERISK~30301.

ASTERISK-30299

Change-Id: I41a316d327646a197b6f112f7f637aceb5111b41

3 months agores_pjsip_aoc: New module for sending advice-of-charge with chan_pjsip
Michael Kuron [Sun, 23 Oct 2022 09:42:34 +0000 (11:42 +0200)]
res_pjsip_aoc: New module for sending advice-of-charge with chan_pjsip

chan_sip supported sending AOC-D and AOC-E information in SIP INFO
messages in an "AOC" header in a format that was originally defined by
Snom. In the meantime, ETSI TS 124 647 introduced an XML-based AOC
format that is supported by devices from multiple vendors, including
Snom phones with firmware >= 8.4.2 (released in 2010).

This commit adds a new res_pjsip_aoc module that inserts AOC information
into outgoing messages or sends SIP INFO messages as described below.
It also fixes a small issue in res_pjsip_session which didn't always
call session supplements on outgoing_response.

* AOC-S in the 180/183/200 responses to an INVITE request
* AOC-S in SIP INFO (if a 200 response has already been sent or if the
  INVITE was sent by Asterisk)
* AOC-D in SIP INFO
* AOC-D in the 200 response to a BYE request (if the client hangs up)
* AOC-D in a BYE request (if Asterisk hangs up)
* AOC-E in the 200 response to a BYE request (if the client hangs up)
* AOC-E in a BYE request (if Asterisk hangs up)

The specification defines one more, AOC-S in an INVITE request, which
is not implemented here because it is not currently possible in
Asterisk to have AOC data ready at this point in call setup. Once
specifying AOC-S via the dialplan or passing it through from another
SIP channel's INVITE is possible, that might be added.

The SIP INFO requests are sent out immediately when the AOC indication
is received. The others are inserted into an appropriate outgoing
message whenever that is ready to be sent. In the latter case, the XML
is stored in a channel variable at the time the AOC indication is
received. Depending on where the AOC indications are coming from (e.g.
PRI or AMI), it may not always be possible to guarantee that the AOC-E
is available in time for the BYE.

Successfully tested AOC-D and both variants of AOC-E with a Snom D735
running firmware 10.1.127.10. It does not appear to properly support
AOC-S however, so that could only be tested by inspecting SIP traces.

ASTERISK-21502 #close
Reported-by: Matt Jordan <mjordan@digium.com>

Change-Id: Iebb7ad0d5f88526bc6629d3a1f9f11665434d333

3 months agores_hep: Add support for named capture agents.
Naveen Albert [Mon, 21 Nov 2022 18:53:49 +0000 (18:53 +0000)]
res_hep: Add support for named capture agents.

Adds support for the capture agent name field
of the Homer protocol to Asterisk by allowing
users to specify a name that will be sent to
the HEP server.

ASTERISK-30322 #close

Change-Id: I6136583017f9dd08daeb8be02f60fb8df4639a2b

3 months agores_pjsip: Fix typo in from_domain documentation
Marcel Wagner [Fri, 25 Nov 2022 09:59:07 +0000 (10:59 +0100)]
res_pjsip: Fix typo in from_domain documentation

This fixes a small typo in the from_domain documentation on the endpoint documentation

ASTERISK-30328 #close

Change-Id: Ia6f0897c3f5cab899ef2cde6b3ac07265b8beb21

3 months agoapp_if: Adds conditional branch applications
Naveen Albert [Mon, 28 Jun 2021 16:56:18 +0000 (16:56 +0000)]
app_if: Adds conditional branch applications

Adds the If, ElseIf, Else, ExitIf, and EndIf
applications for conditional execution
of a block of dialplan, similar to the While,
EndWhile, and ExitWhile applications. The
appropriate branch is executed at most once
if available and may be broken out of while
inside.

ASTERISK-29497

Change-Id: I3aa3bd35a5add82465c6ee9bd86b64601f0e1f49

3 months agores_pjsip_session.c: Map empty extensions in INVITEs to s.
Naveen Albert [Mon, 17 Oct 2022 00:33:44 +0000 (00:33 +0000)]
res_pjsip_session.c: Map empty extensions in INVITEs to s.

Some SIP devices use an empty extension for PLAR functionality.

Rather than rejecting these empty extensions, we now use the s
extension for such calls to mirror the existing PLAR functionality
in Asterisk (e.g. chan_dahdi).

ASTERISK-30265 #close

Change-Id: I0861a405cd49bbbf532b52f7b47f0e2810832590

3 months agores_pjsip: Update contact_user to point out default
Marcel Wagner [Thu, 17 Nov 2022 19:30:45 +0000 (20:30 +0100)]
res_pjsip: Update contact_user to point out default

Updates the documentation for the 'contact_user' field to point out the
default outbound contact if no contact_user is specified 's'

ASTERISK-30316 #close

Change-Id: I61f24fb9164e4d07e05908a2511805281874c876

3 months agores_pjsip_header_funcs: Add custom parameter support.
Naveen Albert [Thu, 21 Jul 2022 19:07:04 +0000 (19:07 +0000)]
res_pjsip_header_funcs: Add custom parameter support.

Adds support for custom URI and header parameters
in the From header in PJSIP. Parameters can be
both set and read using this function.

ASTERISK-30150 #close

Change-Id: Ifb1bc3c512ad5f6faeaebd7817f004a2ecbd6428

3 months agoapp_voicemail: Fix missing email in msg_create_from_file.
Naveen Albert [Thu, 3 Nov 2022 20:28:23 +0000 (20:28 +0000)]
app_voicemail: Fix missing email in msg_create_from_file.

msg_create_from_file currently does not dispatch emails,
which means that applications using this function, such
as MixMonitor, will not trigger notifications to users
(only AMI events are sent our currently). This is inconsistent
with other ways users can receive voicemail.

This is fixed by adding an option that attempts to send
an email and falling back to just the notifications as
done now if that fails. The existing behavior remains
the default.

ASTERISK-30283 #close

Change-Id: I597cbb9cf971a18d8776172b26ab187dc096a5c7

3 months agoari: Destroy body variables in channel create.
Joshua C. Colp [Thu, 8 Dec 2022 10:33:02 +0000 (06:33 -0400)]
ari: Destroy body variables in channel create.

When passing a JSON body to the 'create' channel route
it would be converted into Asterisk variables, but never
freed resulting in a memory leak.

This change makes it so that the variables are freed in
all cases.

ASTERISK-30344

Change-Id: I924dbd866a01c6073e2d6fb846ccaa27ef72d49d

3 months agores_adsi: Fix major regression caused by media format rearchitecture.
Naveen Albert [Wed, 23 Nov 2022 22:59:16 +0000 (22:59 +0000)]
res_adsi: Fix major regression caused by media format rearchitecture.

The commit that rearchitected media formats,
a2c912e9972c91973ea66902d217746133f96026 (ASTERISK_23114)
introduced a regression by improperly translating code in res_adsi.c.
In particular, the pointer to the frame buffer was initialized
at the top of adsi_careful_send, rather than dynamically updating it
for each frame, as is required.

This resulted in the first frame being repeatedly sent,
rather than advancing through the frames.
This corrupted the transmission of the CAS to the CPE,
which meant that CPE would never respond with the DTMF acknowledgment,
effectively completely breaking ADSI functionality.

This issue is now fixed, and ADSI now works properly again.

ASTERISK-29793 #close

Change-Id: Icdeddf733eda2981c98712d1ac9cddc0db507dbe

3 months agofunc_presencestate: Fix invalid memory access.
Naveen Albert [Sun, 13 Nov 2022 22:15:07 +0000 (22:15 +0000)]
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

3 months agosig_analog: Fix no timeout duration.
Naveen Albert [Thu, 1 Dec 2022 11:54:23 +0000 (11:54 +0000)]
sig_analog: Fix no timeout duration.

ASTERISK_28702 previously attempted to fix an
issue with flash hook hold timing out after
just under 17 minutes, when it should have never
been timing out. It fixed this by changing 999999
to INT_MAX, but it did so in chan_dahdi, which
is the wrong place since ss_thread is now in
sig_analog and the one in chan_dahdi is mostly
dead code.

This fixes this by porting the fix to sig_analog.

ASTERISK-30336 #close

Change-Id: I05eb69cc0b5319d357842a70bd26ef64d145cb15

3 months agoxmldoc: Allow XML docs to be reloaded.
Naveen Albert [Sat, 5 Nov 2022 12:11:08 +0000 (12:11 +0000)]
xmldoc: Allow XML docs to be reloaded.

The XML docs are currently only loaded on
startup with no way to update them during runtime.
This makes it impossible to load modules that
use ACO/Sorcery (which require documentation)
if they are added to the source tree and built while
Asterisk is running (e.g. external modules).

This adds a CLI command to reload the XML docs
during runtime so that documentation can be updated
without a full restart of Asterisk.

ASTERISK-30289 #close

Change-Id: I4f265b0e5517e757c5453a0f241201a5788d3a07

3 months agortp_engine.h: Update examples using ast_format_set.
Naveen Albert [Thu, 24 Nov 2022 15:56:55 +0000 (15:56 +0000)]
rtp_engine.h: Update examples using ast_format_set.

This file includes some doxygen comments referencing
ast_format_set. This is an obsolete API that was
removed years back, but documentation was not fully
updated to reflect that. These examples are
updated to the current way of doing things
(using the format cache).

ASTERISK-30327 #close

Change-Id: I570f3b8007fa17ba470cc7117f44bfe7c555d2f7

3 months agoapp_osplookup: Remove deprecated module.
Mike Bradeen [Fri, 18 Nov 2022 20:06:31 +0000 (13:06 -0700)]
app_osplookup: Remove deprecated module.

ASTERISK-30302

Change-Id: I2268189646fa0b587675d8619322818143172474

3 months agochan_skinny: Remove deprecated module.
Mike Bradeen [Wed, 16 Nov 2022 15:51:25 +0000 (08:51 -0700)]
chan_skinny: Remove deprecated module.

ASTERISK-30300

Change-Id: I8be11455010b8ec552e62b0719368342e8a1bae9

3 months agoapp_mixmonitor: Add option to use real Caller ID for voicemail.
Naveen Albert [Fri, 4 Nov 2022 11:04:08 +0000 (11:04 +0000)]
app_mixmonitor: Add option to use real Caller ID for voicemail.

MixMonitor currently uses the Connected Line as the Caller ID
for voicemails. This is due to the implementation being written
this way for use with Digium phones. However, in general this
is not correct for generic usage in the dialplan, and people
may need the real Caller ID instead. This adds an option to do that.

ASTERISK-30286 #close

Change-Id: I3d0ce76dfe75e2a614e0f709ab27acbd2478267c

3 months agomanager: prevent file access outside of config dir
Mike Bradeen [Mon, 3 Oct 2022 18:54:40 +0000 (12:54 -0600)]
manager: prevent file access outside of config dir

Add live_dangerously flag to manager and use this flag to
determine if a configuation file outside of AST_CONFIG_DIR
should be read.

ASTERISK-30176

Change-Id: I46b26af4047433b49ae5c8a85cb8cda806a07404
(cherry picked from commit 81f10e847efdbe8ec264062ee234e1098c29b3f6)

3 months agopjsip_transport_events: Fix possible use after free on transport
George Joseph [Mon, 10 Oct 2022 14:35:54 +0000 (08:35 -0600)]
pjsip_transport_events: Fix possible use after free on transport

It was possible for a module that registered for transport monitor
events to pass in a pjsip_transport that had already been freed.
This caused pjsip_transport_events to crash when looking up the
monitor for the transport.  The fix is a two pronged approach.

1. We now increment the reference count on pjsip_transports when we
create monitors for them, then decrement the count when the
transport is going to be destroyed.

2. There are now APIs to register and unregister monitor callbacks
by "transport key" which is a string concatenation of the remote ip
address and port.  This way the module needing to monitor the
transport doesn't have to hold on to the transport object itself to
unregister.  It just has to save the transport_key.

* Added the pjsip_transport reference increment and decrement.

* Changed the internal transport monitor container key from the
  transport->obj_name (which may not be unique anyway) to the
  transport_key.

* Added a helper macro AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR() that
  fills a buffer with the transport_key using a passed-in
  pjsip_transport.

* Added the following functions:
  ast_sip_transport_monitor_register_key
  ast_sip_transport_monitor_register_replace_key
  ast_sip_transport_monitor_unregister_key
  and marked their non-key counterparts as deprecated.

* Updated res_pjsip_pubsub and res_pjsip_outbound_register to use
  the new "key" monitor functions.

NOTE: res_pjsip_registrar also uses the transport monitor
functionality but doesn't have a persistent object other than
contact to store a transport key.  At this time, it continues to
use the non-key monitor functions.

ASTERISK-30244

Change-Id: I1a20baf2a8643c272dcf819871d6c395f148f00b
(cherry picked from commit 7684c9e907fb85f5c58b025d9e385ad2600f12a2)

3 months agopjproject: 2.13 security fixes
Ben Ford [Tue, 29 Nov 2022 20:02:26 +0000 (14:02 -0600)]
pjproject: 2.13 security fixes

Backports two security fixes (c4d3498 and 450baca) from pjproject 2.13.

ASTERISK-30338

Change-Id: I86fdc003d5d22cb66e7cc6dc3313a8194f27eb69

4 months agopbx_builtins: Allow Answer to return immediately.
Naveen Albert [Fri, 11 Nov 2022 20:30:27 +0000 (20:30 +0000)]
pbx_builtins: Allow Answer to return immediately.

The Answer application currently waits for up to 500ms
for media, even if users specify a different timeout.

This adds an option to not wait for media on the channel
by doing a raw answer instead. The default 500ms threshold
is also documented.

ASTERISK-30308 #close

Change-Id: Id59cd340c44b8b8b2384c479e17e5123e917cba4

4 months agochan_dahdi: Allow FXO channels to start immediately.
Naveen Albert [Fri, 11 Nov 2022 00:47:57 +0000 (00:47 +0000)]
chan_dahdi: Allow FXO channels to start immediately.

Currently, chan_dahdi will wait for at least one
ring before an incoming call can enter the dialplan.
This is generally necessary in order to receive
the Caller ID spill and/or distinctive ringing
detection.

However, if neither of these is required, then there
is nothing gained by waiting for one ring and this
unnecessarily delays call setup. Users can now
use immediate=yes to make FXO channels (FXS signaled)
begin processing dialplan as soon as Asterisk receives
the call.

ASTERISK-30305 #close

Change-Id: I20818b370b2e4892c7f40c8a8753fa06a81750b5

4 months agocore & res_pjsip: Improve topology change handling.
Maximilian Fridrich [Wed, 7 Sep 2022 12:06:55 +0000 (14:06 +0200)]
core & res_pjsip: Improve topology change handling.

This PR contains two relatively separate changes in channel.c and
res_pjsip_session.c which ensure that topology changes are not ignored
in cases where they should be handled.

For channel.c:

The function ast_channel_request_stream_topology_change only triggers a
stream topology request change indication, if the channel's topology
does not equal the requested topology. However, a channel could be in a
state where it is currently "negotiating" a new topology but hasn't
updated it yet, so the topology request change would be lost. Channels
need to be able to handle such situations internally and stream
topology requests should therefore always be passed on.

In the case of chan_pjsip for example, it queues a session refresh
(re-INVITE) if it is currently in the middle of a transaction or has
pending requests (among other reasons).

Now, ast_channel_request_stream_topology_change always indicates a
stream topology request change even if the requested topology equals the
channel's topology.

For res_pjsip_session.c:

The function resolve_refresh_media_states does not process stream state
changes if the delayed active state differs from the current active
state. I.e. if the currently active stream state has changed between the
time the sip session refresh request was queued and the time it is being
processed, the session refresh is ignored. However, res_pjsip_session
contains logic that ensures that session refreshes are queued and
re-queued correctly if a session refresh is currently not possible. So
this check is not necessary and led to some session refreshes being
lost.

Now, a session refresh is done even if the delayed active state differs
from the current active state and it is checked whether the delayed
pending state differs from the current active - because that means a
refresh is necessary.

Further, the unit test of resolve_refresh_media_states was adapted to
reflect the new behavior. I.e. the changes to delayed pending are
prioritized over the changes to current active because we want to
preserve the original intention of the pending state.

ASTERISK-30184

Change-Id: Icd0703295271089057717006730b555b9a1d4e5a

4 months agosla: Prevent deadlock and crash due to autoservicing.
Naveen Albert [Sat, 24 Sep 2022 10:15:09 +0000 (10:15 +0000)]
sla: Prevent deadlock and crash due to autoservicing.

SLAStation currently autoservices the station channel before
creating a thread to actually dial the trunk. This leads
to duplicate servicing of the channel which causes assertions,
deadlocks, crashes, and moreover not the correct behavior.

Removing the autoservice prevents the crash, but if the station
hangs up before the trunk answers, the call hangs since the hangup
was never serviced on the channel.

This is fixed by not autoservicing the channel, but instead
servicing it in the thread dialing the trunk, since it is doing
so synchronously to begin with. Instead of sleeping for 100ms
in a loop, we simply use the channel for timing, and abort
if it disappears.

The same issue also occurs with SLATrunk when a call is answered,
because ast_answer invokes ast_waitfor_nandfds. Thus, we use
ast_raw_answer instead which does not cause any conflict and allows
the call to be answered normally without thread blocking issues.

ASTERISK-29998 #close

Change-Id: Icc237d50354b5910000d2305901e86d2c87bb9d8

4 months agoBuild system: Avoid executable stack.
Jaco Kroon [Mon, 7 Nov 2022 15:30:00 +0000 (17:30 +0200)]
Build system: Avoid executable stack.

Found in res_geolocation, but I believe others may have similar issues,
thus not linking to a specific issue.

Essentially gcc doesn't mark the stack for being non-executable unless
it's compiling the source, this informs ld via gcc to mark the object as
not requiring an executable stack (which a binary blob obviously
doesn't).

ASTERISK-30321

Change-Id: I71bcc2fd1fe0c82a28b3257405d6f2b566fd9bfc
Signed-off-by: Jaco Kroon <jaco@uls.co.za>

4 months agofunc_json: Fix memory leak.
Naveen Albert [Thu, 10 Nov 2022 12:11:53 +0000 (12:11 +0000)]
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

4 months agotest_json: Remove duplicated static function.
Naveen Albert [Thu, 10 Nov 2022 12:20:43 +0000 (12:20 +0000)]
test_json: Remove duplicated static function.

Removes the function mkstemp_file and uses
ast_file_mkftemp from file.h instead.

ASTERISK-30295 #close

Change-Id: I7412ec06f88c39ee353bcdb8c976c2fcac546609

4 months agores_agi: Respect "transmit_silence" option for "RECORD FILE".
Joshua C. Colp [Wed, 16 Nov 2022 11:40:26 +0000 (07:40 -0400)]
res_agi: Respect "transmit_silence" option for "RECORD FILE".

The "RECORD FILE" command in res_agi has its own
implementation for actually doing the recording. This
has resulted in it not actually obeying the option
"transmit_silence" when recording.

This change causes it to now send silence if the
option is enabled.

ASTERISK-30314

Change-Id: Ib3a85601ff35d1b904f836691bad8a4b7e957174

4 months agofile.c: Don't emit warnings on winks.
Naveen Albert [Sun, 6 Nov 2022 16:39:30 +0000 (16:39 +0000)]
file.c: Don't emit warnings on winks.

Adds an ignore case for wink since it should
pass through with no warning.

ASTERISK-30290 #close

Change-Id: Ieb7e34daa717357ac5c93efb0059f6c2321f16ad