Commit Graph

34298 Commits

Author SHA1 Message Date
sarangr7
c37d2cd0d7 main/dial.c: Set channel hangup cause on timeout in handle_timeout_trip
When dial attempts timeout in the core dialing API, the channel's hangup
cause was not being set before hanging up. Only the ast_dial_channel
structure's internal cause field was updated, but the actual ast_channel
hangup cause remained unset.

This resulted in incorrect or missing hangup cause information being
reported through CDRs, AMI events, and other mechanisms that read the
channel's hangup cause when dial timeouts occurred via applications
using the dialing API (FollowMe, Page, etc.).

The fix adds proper channel locking and sets AST_CAUSE_NO_ANSWER on
the channel before calling ast_hangup(), ensuring consistent hangup
cause reporting across all interfaces.

Resolves: #1660
2025-12-29 19:37:32 +00:00
Sean Bright
6863fae4b8 cel: Add missing manager documentation.
The LOCAL_OPTIMIZE_BEGIN, STREAM_BEGIN, STREAM_END, and DTMF CEL
events were not all documented in the CEL configuration file or the
manager documentation for the CEL event.
2025-12-29 18:37:29 +00:00
Sean Bright
ef672b5add res_odbc: Use SQL_SUCCEEDED() macro where applicable.
This is just a cleanup of some repetitive code.
2025-12-29 18:33:02 +00:00
Justin T. Gibbs
0c7cf8f26c rtp/rtcp: Configure dual-stack behavior via IPV6_V6ONLY
Dual-stack behavior (simultaneous listening for IPV4 and IPV6
connections on a single socket) is required by Asterisk's ICE
implementation.  On systems with the IPV6_V6ONLY sockopt, set
the option to 0 (dual-stack enabled) when binding to the IPV6
any address. This ensures correct behavior regardless of the
system's default dual-stack configuration.
2025-12-29 18:04:51 +00:00
Sean Bright
4dd0537a0f http.c: Include remote address in URI handler message.
Resolves: #1662
2025-12-29 18:01:43 +00:00
Joshua C. Colp
a12251ca88 pjsip: Move from threadpool to taskpool
This change moves the PJSIP module from the threadpool API
to the taskpool API. PJSIP-specific implementations for
task usage have been removed and replaced with calls to
the optimized taskpool implementations instead. The need
for a pool of serializers has also been removed as
taskpool inherently provides this. The default settings
have also been changed to be more realistic for common
usage.

UpgradeNote: The threadpool_* options in pjsip.conf have now
been deprecated though they continue to be read and used.
They have been replaced with taskpool options that give greater
control over the underlying taskpool used for PJSIP. An alembic
upgrade script has been added to add these options to realtime
as well.
2025-12-16 17:03:43 +00:00
phoneben
bb008fbf7c Disable device state caching for ephemeral channels
chan_audiosocket/chan_rtp/res_stasis_snoop: Disable device state caching for ephemeral channels

Resolves: #1638
2025-12-16 14:56:02 +00:00
George Joseph
1bb03370f4 chan_websocket: Add locking in send_event and check for NULL websocket handle.
On an outbound websocket connection, when the triggering caller hangs up,
webchan_hangup() closes the outbound websocket session and sets the websocket
session handle to NULL.  If the hangup happened in the tiny window between
opening the outbound websocket connection and before read_thread_handler()
was able to send the MEDIA_START message, it could segfault because the
websocket session handle was NULL.  If it didn't actually segfault, there was
also the possibility that the websocket instance wouldn't get cleaned up which
could also cause the channel snapshot to not get cleaned up.  That could
cause memory leaks and `core show channels` to list phantom WebSocket
channels.

To prevent the race, the send_event() macro now locks the websocket_pvt
instance and checks the websocket session handle before attempting to send
the MEDIA_START message.

Resolves: #1643
Resolves: #1645
2025-12-15 16:01:25 +00:00
phoneben
d5962bb4dc Fix false null-deref warning in channel_state
Resolve analyzer warning in channel_state by checking AST_FLAG_DEAD on snapshot, which is guaranteed non-NULL.

Resolves: #1430
2025-12-10 12:58:04 +00:00
George Joseph
3fe9377c90 endpoint.c: Plug a memory leak in ast_endpoint_shutdown().
Commit 26795be introduced a memory leak of ast_endpoint when
ast_endpoint_shutdown() was called. The leak occurs only if a configuration
change removes an endpoint and isn't related to call volume or the length of
time asterisk has been running.  An ao2_ref(-1) has been added to
ast_endpoint_shutdown() to plug the leak.

Resolves: #1635
2025-12-09 19:39:10 +00:00
Sean Bright
786156e3ba Revert "func_hangupcause.c: Add access to Reason headers via HANGUPCAUSE()"
This reverts commit 5177662990.

For rationale, see #1621 and #1606
2025-12-09 17:04:06 +00:00
Paul Donald
4eae01c067 configs: rename phoneprov_users.conf to .sample so make installs it
This conf file should be suffixed .sample so that make installs it
at compile time. Otherwise res_phoneprov complains at runtime as to
its absence and refuses to start.

Fixes: #1626
2025-12-09 16:58:16 +00:00
Sean Bright
03a7e33917 cel_manager.c: Correct manager event mask for CEL events.
There is no EVENT_FLAG_CEL and these events are raised with as
EVENT_FLAG_CALL.
2025-12-09 14:08:51 +00:00
Sean Bright
8998e0a152 app_queue.c: Update docs to correct QueueMemberPause event name. 2025-12-05 16:33:49 +00:00
Mike Bradeen
5f2c9ffd0d taskprocessors: Improve logging and add new cli options
This change makes some small changes to improve log readability in
addition to the following changes:

Modified 'core show taskprocessors' to now show Low time and High time
for task execution.

New command 'core show taskprocessor name <taskprocessor-name>' to dump
taskprocessor info and current queue.

Addionally, a new test was added to demonstrate the 'show taskprocessor
name' functionality:
test execute category /main/taskprocessor/ name taskprocessor_cli_show

Setting 'core set debug 3 taskprocessor.c' will now log pushed tasks.
(Warning this is will cause extremely high levels of logging at even
low traffic levels.)

Resolves: #1566

UserNote: New CLI command has been added -
core show taskprocessor name <taskprocessor-name>
2025-12-04 16:13:03 +00:00
Michal Hajek
3bd4852fa6 manager: fix double free of criteria variable when adding filter
Signed-off-by: Michal Hajek <michal.hajek@daktela.com>

Fixes: #1531
2025-12-04 13:05:44 +00:00
Sean Bright
78ba1edf29 app_stream_echo.c: Check that stream is non-NULL before dereferencing.
Also re-order and rename the arguments of `stream_echo_write_error` to
match those of `ast_write_stream` for consistency.

Resolves: #1427
2025-12-03 13:58:43 +00:00
Sean Bright
abcf456715 abstract_jb.c: Remove redundant timer check per static analysis.
While this check is technically unnecessary, it also was not harmful.

The 2 other items mentioned in the linked issue are false positives
and require no action.

Resolves: #1417
2025-12-03 13:58:25 +00:00
phoneben
8dec33f963 channelstorage_cpp: Fix fallback return value in channelstorage callback
callback returned the last iterated channel when no match existed, causing invalid channel references and potential double frees. Updated to correctly return NULL when there is no match.

Resolves: #1609
2025-12-01 15:33:53 +00:00
George Joseph
724f4cb6e8 ccss: Add option to ccss.conf to globally disable it.
The Call Completion Supplementary Service feature is rarely used but many of
it's functions are called by app_dial and channel.c "just in case".  These
functions lock and unlock the channel just to see if CCSS is enabled on it,
which it isn't 99.99% of the time.

UserNote: A new "enabled" parameter has been added to ccss.conf.  It defaults
to "yes" to preserve backwards compatibility but CCSS is rarely used so
setting "enabled = no" in the "general" section can save some unneeded channel
locking operations and log message spam.  Disabling ccss will also prevent
the func_callcompletion and chan_dahdi modules from loading.

DeveloperNote: A new API ast_is_cc_enabled() has been added.  It should be
used to ensure that CCSS is enabled before making any other ast_cc_* calls.
2025-12-01 14:05:54 +00:00
George Joseph
5bef77ca4a app_directed_pickup.c: Change some log messages from NOTICE to VERBOSE.
UpgradeNote: In an effort to reduce log spam, two normal progress
"pickup attempted" log messages from app_directed_pickup have been changed
from NOTICE to VERBOSE(3).  This puts them on par with other normal
dialplan progress messages.
2025-12-01 14:00:57 +00:00
Sean Bright
346474635f chan_websocket: Fix crash on DTMF_END event.
Resolves: #1604
2025-12-01 13:58:19 +00:00
Joe Garlick
2d11bb044e chan_websocket.c: Tolerate other frame types
Currently, if chan_websocket receives an un supported frame like comfort noise it will exit the websocket. The proposed change is to tolerate the other frames by not sending them down the websocket but instead just ignoring them.

Resolves: #1587
2025-11-19 17:23:19 +00:00
Naveen Albert
006d7f8f01 app_reload: Fix Reload() without arguments.
Calling Reload() without any arguments is supposed to reload
everything (equivalent to a 'core reload'), but actually does
nothing. This is because it was calling ast_module_reload with
an empty string, and the argument needs to explicitly be NULL.

Resolves: #1597
2025-11-19 17:19:49 +00:00
Naveen Albert
d4ff1a10f4 pbx.c: Print new context count when reloading dialplan.
When running "dialplan reload", the number of contexts reported
is initially wrong, as it is the old context count. Running
"dialplan reload" a second time returns the correct number of
contexts that are loaded. This can confuse users into thinking
that the reload didn't work successfully the first time.

This counter is currently only incremented when iterating the
old contexts prior to the context merge; at the very end, get
the current number of elements in the context hash table and
report that instead. This way, the count is correct immediately
whenever a reload occurs.

Resolves: #1599
2025-11-19 17:19:44 +00:00
C. Maj
4f8db2a573 Makefile: Add module-list-* targets.
Convenience wrappers for showing modules at various support levels.

* module-list-core
* module-list-extended
* module-list-deprecated

Resolves: #1572

UserNote: Try "make module-list-deprecated" to see what modules
are on their way out the door.
2025-11-19 13:15:33 +00:00
Naveen Albert
1b78cf03a6 app_disa: Avoid use of removed ResetCDR() option.
Commit a46d5f9b76 removed the deprecated
'e' option to ResetCDR; this now causes DISA() to emit a warning
if attempting to call ResetCDR() with the deprecated option (in
all cases except when the no answer option is provided). Rewrite
the code to do this the current way.

Resolves: #1592
2025-11-17 18:35:52 +00:00
Tinet-mucw
c1d8dead62 core_unreal.c: Use ast instead of p->chan to get the DIALSTATUS variable
After p->chan = NULL, ast still points to the valid channel object,
using ast safely accesses the channel's DIALSTATUS variable before it's fully destroyed

Resolves: #1590
2025-11-17 14:09:03 +00:00
George Joseph
b22a3d4814 ast_coredumper: Fix multiple issues
* Fixed an issue with tarball-coredumps when asterisk was invoked without an
absolute path.

* Fixed an issue with gdb itself segfaulting when trying to get symbols from
separate debuginfo files.  The command line arguments needed to be altered
such that the gdbinit files is loaded before anything else but the
`dump-asterisk` command is run after full initialization.

In the embedded gdbinit script:

* The extract_string_symbol function needed a `char *` cast to work properly.

* The s_strip function needed to be updated to continue to work with the
cpp_map_name_id channel storage backend.

* A new function was added to dump the channels when cpp_map_name_id was
used.

* The Channel object was updated to account for the new channel storage
backends

* The show_locks function was refactored to work correctly.
2025-11-13 20:51:02 +00:00
Daouda Taha
39abb233b6 app_mixmonitor: Add 's' (skip) option to delay recording.
The 's' (skip) option delays MixMonitor recording until the specified number of seconds
(can be fractional) have elapsed since MixMonitor was invoked.

No audio is written to the recording file during this time. If the call ends before this
period, no audio will be saved. This is useful for avoiding early audio such as
announcements, ringback tones, or other non-essential sounds.

UserNote: This change introduces a new 's(<seconds>)' (skip) option to the MixMonitor
application. Example:
  MixMonitor(${UNIQUEID}.wav,s(3))

This skips recording for the first 3 seconds before writing audio to the file.
Existing MixMonitor behavior remains unchanged when the 's' option is not used.
2025-11-13 19:24:32 +00:00
phoneben
0361a8e9d7 stasis: switch stasis show topics temporary container from list - RBtree
switch stasis show topics temporary container from list to RB-tree
minimizing lock time

Resolves: #1585
2025-11-12 22:22:06 +00:00
Sean Bright
62212dec6a app_dtmfstore: Avoid a potential buffer overflow.
Prefer snprintf() so we can readily detect if our output was
truncated.

Resolves: #1421
2025-11-12 22:20:40 +00:00
Sean Bright
b64bd60df3 main: Explicitly mark case statement fallthrough as such.
Resolves: #1442
2025-11-12 22:10:44 +00:00
Sean Bright
6967522869 bridge_softmix: Return early on topology allocation failure.
Resolves: #1446
2025-11-12 22:07:02 +00:00
Sean Bright
c66552c875 bridge_simple: Increase code verbosity for clarity.
There's no actual problem here, but I can see how it might by
confusing.

Resolves: #1444
2025-11-12 22:05:02 +00:00
Kristian F. Høgh
9a2dca7c8c app_queue.c: Only announce to head caller if announce_to_first_user
Only make announcements to head caller if announce_to_first_user is true

Fixes: #1568

UserNote: When announce_to_first_user is false, no announcements are played to the head caller
2025-11-12 21:57:59 +00:00
George Joseph
687874c733 channelstorage: Allow storage driver read locking to be skipped.
After PR #1498 added read locking to channelstorage_cpp_map_name_id, if ARI
channels/externalMedia was called with a custom channel id AND the
cpp_map_name_id channel storage backend is in use, a deadlock can occur when
hanging up the channel. It's actually triggered in
channel.c:__ast_channel_alloc_ap() when it gets a write lock on the
channelstorage driver then subsequently does a lookup for channel uniqueid
which now does a read lock. This is an invalid operation and causes the lock
state to get "bad". When the channels try to hang up, a write lock is
attempted again which hangs and causes the deadlock.

Now instead of the cpp_map_name_id channelstorage driver "get" APIs
automatically performing a read lock, they take a "lock" parameter which
allows a caller who already has a write lock to indicate that the "get" API
must not attempt its own lock.  This prevents the state from getting mesed up.

The ao2_legacy driver uses the ao2 container's recursive mutex so doesn't
have this issue but since it also implements the common channelstorage API,
it needed its "get" implementations updated to take the lock parameter. They
just don't use it.

Resolves: #1578
2025-11-12 21:27:17 +00:00
George Joseph
72548c17ab chan_websocket: Add ability to place a MARK in the media stream.
Also cleaned up a few unused #if blocks, and started sending a few ERROR
events back to the apps.

Resolves: #1574

DeveloperNote: Apps can now send a `MARK_MEDIA` command with an optional
`correlation_id` parameter to chan_websocket which will be placed in the
media frame queue. When that frame is dequeued after all intervening media
has been played to the core, chan_websocket will send a
`MEDIA_MARK_PROCESSED` event to the app with the same correlation_id
(if any).
2025-11-12 21:24:21 +00:00
George Joseph
6b45c0940e chan_websocket: Add capability for JSON control messages and events.
With recent enhancements to chan_websocket, the original plain-text
implementation of control messages and events is now too limiting.  We
probably should have used JSON initially but better late than never.  Going
forward, enhancements that require control message or event changes will
only be done to the JSON variants and the plain-text variants are now
deprecated but not yet removed.

* Added the chan_websocket.conf config file that allows setting which control
message format to use globally: "json" or "plain-text".  "plain-text" is the
default for now to preserve existing behavior.

* Added a dialstring option `f(json|plain-text)` to allow the format to be
overridden on a call-by-call basis.  Again, 'plain-text' is the default for
now to preserve existing behavior.

The JSON for commands sent by the app to Asterisk must be...
`{ "command": "<command>" ... }` where `<command>` is one of `ANSWER`, `HANGUP`,
`START_MEDIA_BUFFERING`, etc.  The `STOP_MEDIA_BUFFERING` command takes an
additional, optional parameter to be returned in the corresponding
`MEDIA_BUFFERING_COMPLETED` event:
`{ "command": "STOP_MEDIA_BUFFERING", "correlation_id": "<correlation id>" }`.

The JSON for events sent from Asterisk to the app will be...
`{ "event": "<event>", "channel_id": "<channel_id>" ... }`.
The `MEDIA_START` event will now look like...

```
{
  "event": "MEDIA_START",
  "connection_id": "media_connection1",
  "channel": "WebSocket/media_connection1/0x5140001a0040",
  "channel_id": "1761245643.1",
  "format": "ulaw",
  "optimal_frame_size": 160,
  "ptime": 20,
  "channel_variables": {
    "DIALEDPEERNUMBER": "media_connection1/c(ulaw)",
    "MEDIA_WEBSOCKET_CONNECTION_ID": "media_connection1",
    "MEDIA_WEBSOCKET_OPTIMAL_FRAME_SIZE": "160"
  }
}
```

Note the addition of the channel variables which can't be supported
with the plain-text formatting.

The documentation will be updated with the exact formats for all commands
and events.

Resolves: #1546
Resolves: #1563

DeveloperNote: The chan_websocket plain-text control and event messages are now
deprecated (but remain the default) in favor of JSON formatted messages.
See https://docs.asterisk.org/Configuration/Channel-Drivers/WebSocket for
more information.

DeveloperNote: A "transport_data" parameter has been added to the
channels/externalMedia ARI endpoint which, for websocket, allows the caller
to specify parameters to be added to the dialstring for the channel.  For
instance, `"transport_data": "f(json)"`.
2025-11-04 19:27:51 +00:00
George Joseph
9f054cc3b1 build: Add menuselect options to facilitate code tracing and coverage
The following options have been added to the menuselect "Compiler Flags"
section...

CODE_COVERAGE: The ability to enable code coverage via the `--enable-coverage`
configure flag has existed for many years but changing it requires
re-running ./configure which is painfully slow.  With this commit, you can
now enable and disable it via menuselect. Setting this option adds the
`-ftest-coverage` and `-fprofile-arcs` flags on the gcc and ld command lines.
It also sets DONT_OPTIMIZE. Note: If you use the `--enable-coverage` configure
flag, you can't turn it off via menuselect so choose one method and stick to
it.

KEEP_FRAME_POINTERS: This option sets `-fno-omit-frame-pointers` on the gcc
command line which can facilitate debugging with 'gdb' and tracing with 'perf'.
Unlike CODE_COVERAGE, this option doesn't depend on optimization being
disabled.  It does however conflict with COMPILE_DOUBLE.
2025-11-04 14:15:54 +00:00
Roman Pertsev
5de54ead31 res_audiosocket: fix temporarily unavailable
Operations on non-blocking sockets may return a resource temporarily unavailable error (EAGAIN or EWOULDBLOCK). This is not a fatal error but a normal condition indicating that the operation would block.

This patch corrects the handling of this case. Instead of incorrectly treating it as a reason to terminate the connection, the code now waits for data to arrive on the socket.
2025-10-29 15:21:42 +00:00
Sean Bright
4fe93c579d safe_asterisk: Resolve a POSIX sh problem and restore globbing behavior.
* Using `==` with the POSIX sh `test` utility is UB.
* Switch back to using globs instead of using `$(find … | sort)`.
* Fix a missing redirect when checking for the OS type.

Resolves: #1554
2025-10-28 15:50:06 +00:00
George Joseph
fc94eebed9 res_stir_shaken: Add STIR_SHAKEN_ATTESTATION dialplan function.
Also...

* Refactored the verification datastore process so instead of having
a separate channel datastore for each verification result, there's only
one channel datastore with a vector of results.

* Refactored some log messages to include channel name and removed
some that would be redundant if a memory allocation failed.

Resolves: #781

UserNote: The STIR_SHAKEN_ATTESTATION dialplan function has been added
which will allow suppressing attestation on a call-by-call basis
regardless of the profile attached to the outgoing endpoint.
2025-10-28 13:56:09 +00:00
Joshua C. Colp
ff56cec9a1 Revert "pjsip: Move from threadpool to taskpool"
This reverts commit bb6b76c2d8.
2025-10-28 12:44:53 +00:00
Tinet-mucw
7a891733b8 iostream.c: Handle TLS handshake attacks in order to resolve the issue of exceeding the maximum number of HTTPS sessions.
The TCP three-way handshake completes, but if the server is under a TLS handshake attack, asterisk will get stuck at SSL_do_handshake().
In this case, a timeout mechanism should be set for the SSL/TLS handshake process to prevent indefinite waiting during the SSL handshake.

Resolves: #1559
2025-10-28 12:44:27 +00:00
George Joseph
75d74ff900 chan_pjsip: Disable SSRC change for WebRTC endpoints.
Commit b333ee3b introduced a fix to chan_pjsip that addressed RTP issues with
blind transfers and some SBCs.  Unfortunately, the fix broke some WebRTC
clients that are sensitive to SSRC changes and non-monotonic timestamps so
the fix is now disabled for endpoints with the "bundle" parameter set to true.

Resolves: #1535
2025-10-27 17:41:13 +00:00
gauravs456
7795cc150b chan_websocket: Add channel_id to MEDIA_START, DRIVER_STATUS and DTMF_END events.
Resolves: #1544
2025-10-23 12:08:41 +00:00
Joshua C. Colp
8d39faaf12 pjsip: Move from threadpool to taskpool
This change moves the PJSIP module from the threadpool API
to the taskpool API. PJSIP-specific implementations for
task usage have been removed and replaced with calls to
the optimized taskpool implementations instead. The need
for a pool of serializers has also been removed as
taskpool inherently provides this. The default settings
have also been changed to be more realistic for common
usage.

UpgradeNote: The threadpool_* options in pjsip.conf have now
been deprecated though they continue to be read and used.
They have been replaced with taskpool options that give greater
control over the underlying taskpool used for PJSIP. An alembic
upgrade script has been added to add these options to realtime
as well.
2025-10-22 16:32:47 +00:00
George Joseph
38d7a99cb3 safe_asterisk: Fix logging and sorting issue.
Re-enabled "TTY=9" which was erroneously disabled as part of a recent
security fix and removed another logging "fix" that was added.

Also added a sort to the "find" that enumerates the scripts to be sourced so
they're sourced in the correct order.

Resolves: #1539
2025-10-22 16:27:22 +00:00
Christoph Moench-Tegeder
d752a4a5df Fix Endianness detection in utils.h for non-Linux
Commit 43bf8a4ded introduced endian
dependend byte-swapping code in include/asterisk/utils.h, where the
endianness was detected using the __BYTE_ORDER macro. This macro
lives in endian.h, which on Linux is included implicitely (by the
network-related headers, I think), but on FreeBSD the headers are
laid out differently and we do not get __BYTE_ORDER the implicit way.

Instead, this makes the usage of endian.h explicit by including it
where we need it, and switches the BYTE_ORDER/*ENDIAN macros to the
POSIX-defined ones (see
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/endian.h.html
for standard compliance). Additionally, this adds a compile-time check
for the endianness-logic: compilation will fail if neither big nor
little endian can be detected.

Fixes: #1536
2025-10-22 16:27:01 +00:00