]> git.ipfire.org Git - thirdparty/asterisk.git/log
thirdparty/asterisk.git
2 years agoUpdate CHANGES and UPGRADE.txt for 18.17.0
Asterisk Development Team [Thu, 2 Mar 2023 16:35:33 +0000 (11:35 -0500)] 
Update CHANGES and UPGRADE.txt for 18.17.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Change-Id: Ic50e95b4fc10f74ab15416d908e8a87ee8ec2f85

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

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

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

2 years 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 years 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 years 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 years 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 years 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 years 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 years agoRevert "res_rtp_asterisk: Asterisk Media Experience Score (MES)"
George Joseph [Mon, 9 Jan 2023 13:20:24 +0000 (07:20 -0600)] 
Revert "res_rtp_asterisk: Asterisk Media Experience Score (MES)"

This reverts commit 62745013a4de9bafeda8dad6cab2b98c050ff69d.

Reason for revert: Issue when transcoding to/from g722

Change-Id: I1665a5442bfb6d7bfa06fdcea3374f4581395b4a

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

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

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

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

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

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

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

2 years agoUpdate CHANGES and UPGRADE.txt for 18.16.0
Asterisk Development Team [Thu, 15 Dec 2022 12:37:38 +0000 (07:37 -0500)] 
Update CHANGES and UPGRADE.txt for 18.16.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2 years agoooh323c: not checking for IE minimum length
Mike Bradeen [Mon, 6 Jun 2022 23:11:30 +0000 (17:11 -0600)] 
ooh323c: not checking for IE minimum length

When decoding q.931 encoded calling/called number
now checking for length being less than minimum required.

ASTERISK-30103

Change-Id: I3dcfce0f35eca258dc450f87c92d4d7af402c2e7

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

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

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

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

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

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

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

2 years agomanager: Update ModuleCheck documentation.
Naveen Albert [Thu, 3 Nov 2022 22:01:16 +0000 (22:01 +0000)] 
manager: Update ModuleCheck documentation.

The ModuleCheck XML documentation falsely
claims that the module's version number is returned.
This has not been the case since 14, since the version
number is not available anymore, but the documentation
was not changed at the time. It is now updated to
reflect this.

ASTERISK-30285 #close

Change-Id: Idde2d1205a11f2623fa1ddab192faa3dc4081e91

2 years agoapp_mixmonitor: Add option to delete files on exit.
Naveen Albert [Thu, 3 Nov 2022 20:56:01 +0000 (20:56 +0000)] 
app_mixmonitor: Add option to delete files on exit.

Adds an option that allows MixMonitor to delete
its copy of any recording files before exiting.

This can be handy in conjunction with options
like m, which copy the file elsewhere, and the
original files may no longer be needed.

ASTERISK-30284 #close

Change-Id: Ida093679c67e300efc154a97b6d8ec0f104e581e

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

2 years agoapp_stack: Print proper exit location for PBXless channels.
Naveen Albert [Sat, 1 Oct 2022 19:49:20 +0000 (19:49 +0000)] 
app_stack: Print proper exit location for PBXless channels.

When gosub is executed on channels without a PBX, the context,
extension, and priority are initialized to the channel driver's
default location for that endpoint. As a result, the last Return
will restore this location and the Gosub logs will print out bogus
information about our exit point.

To fix this, on channels that don't have a PBX, the execution
location is left intact on the last return if there are no
further stack frames left. This allows the correct location
to be printed out to the user, rather than the bogus default
context.

ASTERISK-30076 #close

Change-Id: I1d42a99c9aa9e3708d32718863175158a894e414
(cherry picked from commit 12d18b0a40381eb90145e352bf144a71f8dd2555)

2 years agorunUnittests.sh: Save coredumps to proper directory
George Joseph [Wed, 2 Nov 2022 14:24:22 +0000 (08:24 -0600)] 
runUnittests.sh:  Save coredumps to proper directory

Fixed the specification of "outputdir" when calling ast_coredumper
so the txt files are saved in the correct place.

ASTERISK-30282

Change-Id: Ic631cb90c1e4c29d970c982dff45fda5e0eb15b6

2 years agochan_rtp: Make usage of ast_rtp_instance_get_local_address clearer
George Joseph [Wed, 2 Nov 2022 12:41:29 +0000 (06:41 -0600)] 
chan_rtp: Make usage of ast_rtp_instance_get_local_address clearer

unicast_rtp_request() was setting the channel variables like this:

pbx_builtin_setvar_helper(chan, "UNICASTRTP_LOCAL_ADDRESS",
    ast_sockaddr_stringify_addr(&local_address));
ast_rtp_instance_get_local_address(instance, &local_address);
pbx_builtin_setvar_helper(chan, "UNICASTRTP_LOCAL_PORT",
    ast_sockaddr_stringify_port(&local_address));

...which made it appear that UNICASTRTP_LOCAL_ADDRESS was being
set before local_address was set.  In fact, the address part of
local_address was set earlier in the function, just not the port.
This was confusing however so ast_rtp_instance_get_local_address()
is now being called before setting UNICASTRTP_LOCAL_ADDRESS.

ASTERISK-30281

Change-Id: I872ac49477100f4eb33891d46efc6ca21ec81aa4

2 years agores_pjsip: prevent crash on websocket disconnect
Mike Bradeen [Thu, 13 Oct 2022 16:19:17 +0000 (10:19 -0600)] 
res_pjsip: prevent crash on websocket disconnect

When a websocket (or potentially any stateful connection) is quickly
created then destroyed, it is possible that the qualify thread will
destroy the transaction before the initialzing thread is finished
with it.

Depending on the timing, this can cause an assertion within pjsip.

To prevent this, ast_send_stateful_response will now create the group
lock and add a reference to it before creating the transaction.

While this should resolve the crash, there is still the potential that
the contact will not be cleaned up properly, see:ASTERISK~29286. As a
result, the contact has to 'time out' before it will be removed.

ASTERISK-28689

Change-Id: Id050fded2247a04d8f0fc5b8a2cf3e5482cb8cee

2 years agores_pjsip_outbound_registration: Allow to use multiple proxies for registration
Igor Goncharovsky [Fri, 9 Sep 2022 17:20:18 +0000 (23:20 +0600)] 
res_pjsip_outbound_registration: Allow to use multiple proxies for registration

Current registration code use pjsip_parse_uri to verify outbound_proxy
that is different from the reading this option for the endpoint. This
made value with multiple proxies invalid for registration pjsip settings.
Removing URI validation helps to use registration through multiple proxies.

ASTERISK-30217 #close

Change-Id: I064558e66f04b9f3260c46181812a01349761357

2 years agotcptls: Prevent crash when freeing OpenSSL errors.
Naveen Albert [Thu, 27 Oct 2022 11:32:12 +0000 (11:32 +0000)] 
tcptls: Prevent crash when freeing OpenSSL errors.

write_openssl_error_to_log has been erroneously
using ast_free instead of free, which will
cause a crash when MALLOC_DEBUG is enabled since
the memory was not allocated by Asterisk's memory
manager. This changes it to use the actual free
function directly to avoid this.

ASTERISK-30278 #close

Change-Id: Iac8b6468b718075809c45d8ad16b101af21a474d

2 years agotests: Fix compilation errors on 32-bit.
Naveen Albert [Sun, 23 Oct 2022 15:16:31 +0000 (15:16 +0000)] 
tests: Fix compilation errors on 32-bit.

Fix compilation errors caused by using size_t
instead of uintmax_t and non-portable format
specifiers.

ASTERISK-30273 #close

Change-Id: I363e6057ef84d54b88af80d23ad6147eef9216ee

2 years agores_pjsip: return all codecs on a re-INVITE without SDP
Henning Westerholt [Fri, 26 Aug 2022 08:59:16 +0000 (08:59 +0000)] 
res_pjsip: return all codecs on a re-INVITE without SDP

Currently chan_pjsip on receiving a re-INVITE without SDP will only
return the codecs that are previously negotiated and not offering
all enabled codecs.

This causes interoperability issues with different equipment (e.g.
from Cisco) for some of our customers and probably also in other
scenarios involving 3PCC infrastructure.

According to RFC 3261, section 14.2 we SHOULD return all codecs
on a re-INVITE without SDP

The PR proposes a new parameter to configure this behaviour:
all_codecs_on_empty_reinvite. It includes the code, documentation,
alembic migrations, CHANGES file and example configuration additions.

ASTERISK-30193 #close

Change-Id: I69763708d5039d512f391e296ee8a4d43a1e2148

2 years agores_pjsip_logger: Add method-based logging option.
Naveen Albert [Thu, 21 Jul 2022 00:03:34 +0000 (00:03 +0000)] 
res_pjsip_logger: Add method-based logging option.

Expands the pjsip logger to support the ability to filter
by SIP message method. This can make certain types of SIP debugging
easier by only logging messages of particular method(s).

ASTERISK-30146 #close

Co-authored-by: Sean Bright <sean@seanbright.com>
Change-Id: I9c8cbb6fc8686ef21190eb42e08bc9a9b147707f

2 years agores_pjsip_notify: Add option support for AMI.
Naveen Albert [Fri, 14 Oct 2022 22:24:00 +0000 (22:24 +0000)] 
res_pjsip_notify: Add option support for AMI.

The PJSIP notify CLI commands allow for using
"options" configured in pjsip_notify.conf.

This allows these same options to be used in
AMI actions as well.

Additionally, as part of this improvement,
some repetitive common code is refactored.

ASTERISK-30263 #close

Change-Id: Ie4496b322b63b61eaf9672183a959ab99a04b6b5

2 years agoDialing API: Cancel a running async thread, may not cancel all calls
Frederic LE FOLL [Thu, 6 Oct 2022 16:51:36 +0000 (18:51 +0200)] 
Dialing API: Cancel a running async thread, may not cancel all calls

race condition: ast_dial_join() may not cancel outgoing call, if
function is called just after called party answer and before
application execution (bit is_running_app not yet set).

This fix adds ast_softhangup() calls in addition to existing
pthread_kill() when is_running_app is not set.

ASTERISK-30258

Change-Id: Idbdd5c15122159661aa8e996a42d5800083131e4

2 years agochan_dahdi: Fix unavailable channels returning busy.
Naveen Albert [Sun, 23 Oct 2022 22:46:24 +0000 (22:46 +0000)] 
chan_dahdi: Fix unavailable channels returning busy.

This fixes dahdi_request to properly set the cause
code to CONGESTION instead of BUSY if no channels
were actually available.

Currently, the cause is erroneously set to busy
if the channel itself is found, regardless of its
current state. However, if the channel is not available
(e.g. T1 down, card not operable, etc.), then the
channel itself may not be in a functional state,
in which case CHANUNAVAIL is the correct cause to use.

This adds a simple check to ensure that busy tone
is only returned if a channel is encountered that
has an owner, since that is the only possible way
that a channel could actually be busy.

ASTERISK-30274 #close

Change-Id: Iad5870223c081240c925b19df8d6af136953b994

2 years agosay: Don't prepend ampersand erroneously.
Naveen Albert [Wed, 28 Sep 2022 12:38:37 +0000 (12:38 +0000)] 
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

2 years agores_pjsip_pubsub: Prevent removing subscriptions.
Naveen Albert [Sun, 16 Oct 2022 20:35:29 +0000 (20:35 +0000)] 
res_pjsip_pubsub: Prevent removing subscriptions.

pjproject does not provide any mechanism of removing
event packages, which means that once a subscription
handler is registered, it is effectively permanent.

pjproject will assert if the same event package is
ever registered again, so currently unloading and
loading any Asterisk modules that use subscriptions
will cause a crash that is beyond our control.

For that reason, we now prevent users from being
able to unload these modules, to prevent them
from ever being loaded twice.

ASTERISK-30264 #close

Change-Id: I7fdcb1a5e44d38b7ba10c44259fe98f0ae9bc12c

2 years agores_crypto: handle unsafe private key files
Philip Prindeville [Fri, 16 Sep 2022 18:45:55 +0000 (12:45 -0600)] 
res_crypto: handle unsafe private key files

ASTERISK-30213 #close

Change-Id: I4a77143d41615b7c4fc25bb1251c0a9cb87b417a

2 years agoaudiohook: add directional awareness
Mike Bradeen [Thu, 29 Sep 2022 20:55:20 +0000 (14:55 -0600)] 
audiohook: add directional awareness

Add enum to allow setting optional direction. If set to only one
direction, only feed matching-direction frames to the associated
slin factory.

This prevents mangling the transcoder on non-mixed frames when the
READ and WRITE frames would have otherwise required it.  Also
removes the need to mute or discard the un-wanted frames as they
are no longer added in the first place.

res_stasis_snoop is changed to use this addition to set direction
on audiohook based on spy direction.

If no direction is set, the ast_audiohook_init will init this enum
to BOTH which maintains existing functionality.

ASTERISK-30252

Change-Id: If8716bad334562a5d812be4eeb2a92e4f3be28eb

2 years agores_tonedetect: Add ringback support to TONE_DETECT.
Naveen Albert [Fri, 30 Sep 2022 11:24:19 +0000 (11:24 +0000)] 
res_tonedetect: Add ringback support to TONE_DETECT.

Adds support for detecting audible ringback tone
to the TONE_DETECT function using the p option.

ASTERISK-30254 #close

Change-Id: Ie2329ff245248768367d26749c285fbe823f6414

2 years agochan_dahdi: Resolve format truncation warning.
Naveen Albert [Sat, 1 Oct 2022 22:08:12 +0000 (22:08 +0000)] 
chan_dahdi: Resolve format truncation warning.

Fixes a format truncation warning in notify_message.

ASTERISK-30256 #close

Change-Id: I983a423c0214641ca4f8c9dfe0b19c47448fdee1

2 years agocdr: Allow bridging and dial state changes to be ignored.
Naveen Albert [Wed, 1 Jun 2022 16:06:14 +0000 (16:06 +0000)] 
cdr: Allow bridging and dial state changes to be ignored.

Allows bridging, parking, and dial messages to be globally
ignored for all CDRs such that only a single CDR record
is generated per channel.

This is useful when CDRs should endure for the lifetime of
an entire channel and bridging and dial updates in the
dialplan should not result in multiple CDR records being
created for the call. With the ignore bridging option,
bridging changes have no impact on the channel's CDRs.
With the ignore dial state option, multiple Dials and their
outcomes have no impact on the channel's CDRs. The
last disposition on the channel is preserved in the CDR,
so the actual disposition of the call remains available.

These two options can reduce the amount of "CDR hacks" that
have hitherto been necessary to ensure that CDR was not
"spoiled" by these messages if that was undesired, such as
putting a dummy optimization-disabled local channel between
the caller and the actual call and putting the CDR on the channel
in the middle to ensure that CDR would persist for the entire
call and properly record start, answer, and end times.
Enabling these options is desirable when calls correspond
to the entire lifetime of channels and the CDR should
reflect that.

Current default behavior remains unchanged.

ASTERISK-30091 #close

Change-Id: I393981af42732ec5ac3ff9266444abb453b7c832

2 years agores_crypto: don't modify fname in try_load_key()
Philip Prindeville [Fri, 16 Sep 2022 23:29:36 +0000 (17:29 -0600)] 
res_crypto: don't modify fname in try_load_key()

"fname" is passed in as a const char *, but strstr() mangles that
into a char *, and we were attempting to modify the string in place.
This is an unwanted (and undocumented) side-effect.

ASTERISK-30213

Change-Id: Ifa36d352aafeb7f9beec3f746332865c7d21e629

2 years agores_crypto: use ast_file_read_dirs() to iterate
Philip Prindeville [Fri, 16 Sep 2022 03:45:22 +0000 (21:45 -0600)] 
res_crypto: use ast_file_read_dirs() to iterate

ASTERISK-30213

Change-Id: I115f5f8942ffcfb23cd2559a55bac8a2eba081e0

2 years agores_geolocation: Update wiki documentation
George Joseph [Tue, 27 Sep 2022 14:35:35 +0000 (08:35 -0600)] 
res_geolocation: Update wiki documentation

Also added a note to the geolocation.conf.sample file
and added a README to the res/res_geolocation/wiki
directory.

Change-Id: I89c3c5db8c0701b33127993622d5e4f904bddfbc