]> git.ipfire.org Git - thirdparty/asterisk.git/log
thirdparty/asterisk.git
4 days agobundled_pjproject: Avoid deadlock between transport and transaction master
Stanislav Abramenkov [Tue, 1 Jul 2025 09:05:48 +0000 (12:05 +0300)] 
bundled_pjproject: Avoid deadlock between transport and transaction

Backport patch from upstream
* Avoid deadlock between transport and transaction
https://github.com/pjsip/pjproject/commit/edde06f261ac

Issue described in
https://github.com/pjsip/pjproject/issues/4442

5 days agoaudiohook.c: Improve frame pairing logic to avoid MixMonitor breakage with mixed...
Michal Hajek [Wed, 21 May 2025 08:28:20 +0000 (10:28 +0200)] 
audiohook.c: Improve frame pairing logic to avoid MixMonitor breakage with mixed codecs

This patch adjusts the read/write synchronization logic in audiohook_read_frame_both()
to better handle calls where participants use different codecs or sample sizes
(e.g., alaw vs G.722). The previous hard threshold of 2 * samples caused MixMonitor
recordings to break or stutter when frames were not aligned between both directions.

The new logic uses a more tolerant limit (1.5 * samples), which prevents audio tearing
without causing excessive buffer overruns. This fix specifically addresses issues
with MixMonitor when recording directly on a channel in a bridge using mixed codecs.

Reported-by: Michal Hajek <michal.hajek@daktela.com>
Resolves: #1276
Resolves: #1279

6 days agochannelstorage_makeopts.xml: Remove errant XML character.
Sean Bright [Mon, 30 Jun 2025 22:00:02 +0000 (18:00 -0400)] 
channelstorage_makeopts.xml: Remove errant XML character.

Resolves: #1282

10 days agoutils.h: Add rounding to float conversion to int.
mkmer [Mon, 24 Mar 2025 01:04:50 +0000 (21:04 -0400)] 
utils.h: Add rounding to float conversion to int.

Quote from an audio engineer NR9V:
There is a minor issue of a small amount of crossover distortion though as a result of `ast_slinear_saturated_multiply_float()` not rounding the float. This could result in some quiet but potentially audible distortion artifacts in lower volume parts of the signal. If you have for example a sign wave function with a max amplitude of just a few samples, all samples between -1 and 1 will be truncated to zero, resulting in the waveform no longer being a sine wave and in harmonic distortion.

Resolves: #1176

10 days agopbx.c: when set flag AST_SOFTHANGUP_ASYNCGOTO, ast_explicit_goto should return -1.
Tinet-mucw [Thu, 19 Jun 2025 02:34:56 +0000 (19:34 -0700)] 
pbx.c: when set flag AST_SOFTHANGUP_ASYNCGOTO, ast_explicit_goto should return -1.

Under certain circumstances the context/extens/prio are set in the ast_async_goto, for example action Redirect.
In the situation that action Redirect is broken by GotoIf this info is changed.
that will causes confusion in dialplan execution.

Resolves: #1273

10 days agores_musiconhold.c: Ensure we're always locked around music state access.
Sean Bright [Tue, 8 Apr 2025 19:54:37 +0000 (15:54 -0400)] 
res_musiconhold.c: Ensure we're always locked around music state access.

10 days agores_musiconhold.c: Annotate when the channel is locked.
Sean Bright [Tue, 8 Apr 2025 19:44:59 +0000 (15:44 -0400)] 
res_musiconhold.c: Annotate when the channel is locked.

10 days agores_musiconhold: Appropriately lock channel during start.
Jaco Kroon [Thu, 19 Dec 2024 14:45:15 +0000 (16:45 +0200)] 
res_musiconhold: Appropriately lock channel during start.

This relates to #829

This doesn't sully solve the Ops issue, but it solves the specific crash
there.  Further PRs to follow.

In the specific crash the generator was still under construction when
moh was being stopped, which then proceeded to close the stream whilst
it was still in use.

Signed-off-by: Jaco Kroon <jaco@uls.co.za>
12 days agores_stir_shaken.so: Handle X5U certificate chains.
George Joseph [Wed, 18 Jun 2025 20:38:08 +0000 (14:38 -0600)] 
res_stir_shaken.so: Handle X5U certificate chains.

The verification process will now load a full certificate chain retrieved
via the X5U URL instead of loading only the end user cert.

* Renamed crypto_load_cert_from_file() and crypto_load_cert_from_memory()
to crypto_load_cert_chain_from_file() and crypto_load_cert_chain_from_memory()
respectively.

* The two load functions now continue to load certs from the file or memory
PEMs and store them in a separate stack of untrusted certs specific to the
current verification context.

* crypto_is_cert_trusted() now uses the stack of untrusted certs that were
extracted from the PEM in addition to any untrusted certs that were passed
in from the configuration (and any CA certs passed in from the config of
course).

Resolves: #1272

UserNote: The STIR/SHAKEN verification process will now load a full
certificate chain retrieved via the X5U URL instead of loading only
the end user cert.

2 weeks agores_stir_shaken: Add "ignore_sip_date_header" config option.
George Joseph [Sun, 15 Jun 2025 20:43:13 +0000 (14:43 -0600)] 
res_stir_shaken: Add "ignore_sip_date_header" config option.

UserNote: A new STIR/SHAKEN verification option "ignore_sip_date_header" has
been added that when set to true, will cause the verification process to
not consider a missing or invalid SIP "Date" header to be a failure.  This
will make the IAT the sole "truth" for Date in the verification process.
The option can be set in the "verification" and "profile" sections of
stir_shaken.conf.

Also fixed a bug in the port match logic.

Resolves: #1251
Resolves: #1271

2 weeks agoapp_record: Add RECORDING_INFO function.
Naveen Albert [Mon, 22 Jan 2024 12:23:47 +0000 (07:23 -0500)] 
app_record: Add RECORDING_INFO function.

Add a function that can be used to retrieve info
about a previous recording, such as its duration.

This is being added as a function to avoid possibly
trampling on dialplan variables, and could be extended
to provide other information in the future.

Resolves: #548

UserNote: The RECORDING_INFO function can now be used
to retrieve the duration of a recording.

3 weeks agoapp_sms.c: Fix sending and receiving SMS messages in protocol 2
Itzanh [Sun, 6 Apr 2025 12:13:21 +0000 (14:13 +0200)] 
app_sms.c: Fix sending and receiving SMS messages in protocol 2

This fixes bugs in SMS messaging to SMS-capable analog phones that prevented app_sms.c from talking to phones using SMS protocol 2.

- Fix MORX message reception (from phone to Asterisk) in SMS protocol 2
- Fix MTTX message transmission (from Asterisk to phone) in SMS protocol 2

One of the bugs caused messages to have random characters and junk appended at the end up to the character limit. Another bug prevented Asterisk from sending messages from Asterisk to the phone at all. A final bug caused the transmission from Asterisk to the phone to take a long time because app_sms.c did not hang up after correctly sending the message, causing the phone to have to time out and hang up in order to complete the message transmission.

This was tested with a Linksys PAP2T and with a GrandStream HT814, sending and receiving messages with Telefónica DOMO Mensajes phones from Telefónica Spain. I had to play with both the network jitter buffer and the dB gain to get it to work. One of my phones required the gain to be set to +3dB for it to work, while another required it to be set to +6dB.

Only MORX and MTTX were tested, I did not test sending and receiving messages to a TelCo SMSC.

3 weeks agoapp_queue: queue rules – Add support for QUEUE_RAISE_PENALTY=rN to raise penalties...
phoneben [Mon, 26 May 2025 20:52:34 +0000 (23:52 +0300)] 
app_queue: queue rules – Add support for QUEUE_RAISE_PENALTY=rN to raise penalties only for members within min/max range

This update adds support for a new QUEUE_RAISE_PENALTY format: rN

When QUEUE_RAISE_PENALTY is set to rN (e.g., r4), only members whose current penalty
is greater than or equal to the defined min_penalty and less than or equal to max_penalty
will have their penalty raised to N.

Members with penalties outside the min/max range remain unchanged.

Example behaviors:

QUEUE_RAISE_PENALTY=4     → Raise all members with penalty < 4 (existing behavior)
QUEUE_RAISE_PENALTY=r4    → Raise only members with penalty in [min_penalty, max_penalty] to 4

Implementation details:

Adds parsing logic to detect the r prefix and sets the raise_respect_min flag

Modifies the raise logic to skip members outside the defined penalty range when the flag is active

UserNote: This change introduces QUEUE_RAISE_PENALTY=rN, allowing selective penalty raises
only for members whose current penalty is within the [min_penalty, max_penalty] range.
Members with lower or higher penalties are unaffected.
This behavior is backward-compatible with existing queue rule configurations.

3 weeks agores_websocket_client: Add more info to the XML documentation.
George Joseph [Thu, 5 Jun 2025 14:06:47 +0000 (08:06 -0600)] 
res_websocket_client:  Add more info to the XML documentation.

Added "see-also" links to chan_websocket and ARI Outbound WebSocket and
added an example configuration for each.

3 weeks agores_odbc: cache_size option to limit the cached connections.
Jaco Kroon [Thu, 12 Dec 2024 22:35:55 +0000 (00:35 +0200)] 
res_odbc: cache_size option to limit the cached connections.

Signed-off-by: Jaco Kroon <jaco@uls.co.za>
UserNote: New cache_size option for res_odbc to on a per class basis limit the
number of cached connections. Please reference the sample configuration
for details.

3 weeks agores_odbc: cache_type option for res_odbc.
Jaco Kroon [Tue, 10 Dec 2024 20:36:02 +0000 (22:36 +0200)] 
res_odbc: cache_type option for res_odbc.

This enables setting cache_type classes to a round-robin queueing system
rather than the historic stack mechanism.

This should result in lower risk of connection drops due to shorter idle
times (the first connection to go onto the stack could in theory never
be used again, ever, but sit there consuming resources, there could be
multiple of these).

And with a queue rather than a stack, dead connections are guaranteed to
be detected and purged eventually.

This should end up better balancing connection_cnt with actual load
over time, assuming the database doesn't keep connections open
excessively long from it's side.

Signed-off-by: Jaco Kroon <jaco@uls.co.za>
UserNote: When using res_odbc it should be noted that back-end
connections to the underlying database can now be configured to re-use
the cached connections in a round-robin manner rather than repeatedly
re-using the same connection.  This helps to keep connections alive, and
to purge dead connections from the system, thus more dynamically
adjusting to actual load.  The downside is that one could keep too many
connections active for a longer time resulting in resource also begin
consumed on the database side.

4 weeks agores_pjsip: Fix empty `ActiveChannels` property in AMI responses.
Sean Bright [Tue, 27 May 2025 16:56:30 +0000 (12:56 -0400)] 
res_pjsip: Fix empty `ActiveChannels` property in AMI responses.

The logic appears to have been reversed since it was introduced in
05cbf8df.

Resolves: #1254

5 weeks agoARI Outbound Websockets
George Joseph [Fri, 28 Mar 2025 12:54:21 +0000 (06:54 -0600)] 
ARI Outbound Websockets

Asterisk can now establish websocket sessions _to_ your ARI applications
as well as accepting websocket sessions _from_ them.
Full details: http://s.asterisk.net/ari-outbound-ws

Code change summary:
* Added an ast_vector_string_join() function,
* Added ApplicationRegistered and ApplicationUnregistered ARI events.
* Converted res/ari/config.c to use sorcery to process ari.conf.
* Added the "outbound-websocket" ARI config object.
* Refactored res/ari/ari_websockets.c to handle outbound websockets.
* Refactored res/ari/cli.c for the sorcery changeover.
* Updated res/res_stasis.c for the sorcery changeover.
* Updated apps/app_stasis.c to allow initiating per-call outbound websockets.
* Added CLI commands to manage ARI websockets.
* Added the new "outbound-websocket" object to ari.conf.sample.
* Moved the ARI XML documentation out of res_ari.c into res/ari/ari_doc.xml

UserNote: Asterisk can now establish websocket sessions _to_ your ARI applications
as well as accepting websocket sessions _from_ them.
Full details: http://s.asterisk.net/ari-outbound-ws

5 weeks agores_websocket_client: Create common utilities for websocket clients.
George Joseph [Fri, 2 May 2025 14:52:54 +0000 (08:52 -0600)] 
res_websocket_client: Create common utilities for websocket clients.

Since multiple Asterisk capabilities now need to create websocket clients
it makes sense to create a common set of utilities rather than making
each of those capabilities implement their own.

* A new configuration file "websocket_client.conf" is used to store common
client parameters in named configuration sections.
* APIs are provided to list and retrieve ast_websocket_client objects created
from the named configurations.
* An API is provided that accepts an ast_websocket_client object, connects
to the remote server with retries and returns an ast_websocket object. TLS is
supported as is basic authentication.
* An observer can be registered to receive notification of loaded or reloaded
client objects.
* An API is provided to compare an existing client object to one just
reloaded and return the fields that were changed. The caller can then decide
what action to take based on which fields changed.

Also as part of thie commit, several sorcery convenience macros were created
to make registering common object fields easier.

UserNote: A new module "res_websocket_client" and config file
"websocket_client.conf" have been added to support several upcoming new
capabilities that need common websocket client configuration.

6 weeks agoasterisk.c: Add option to restrict shell access from remote consoles.
George Joseph [Mon, 19 May 2025 14:16:53 +0000 (08:16 -0600)] 
asterisk.c: Add option to restrict shell access from remote consoles.

UserNote: A new asterisk.conf option 'disable_remote_console_shell' has
been added that, when set, will prevent remote consoles from executing
shell commands using the '!' prefix.

Resolves: #GHSA-c7p6-7mvq-8jq2

6 weeks agores_pjsip_messaging.c: Mask control characters in received From display name
George Joseph [Mon, 24 Mar 2025 20:59:42 +0000 (14:59 -0600)] 
res_pjsip_messaging.c: Mask control characters in received From display name

Incoming SIP MESSAGEs will now have their From header's display name
sanitized by replacing any characters < 32 (space) with a space.

Resolves: #GHSA-2grh-7mhv-fcfw

6 weeks agoframe.c: validate frame data length is less than samples when adjusting volume
mkmer [Mon, 12 May 2025 14:18:19 +0000 (10:18 -0400)] 
frame.c: validate frame data length is less than samples when adjusting volume

Resolves: #1230

6 weeks agores_audiosocket.c: Add retry mechanism for reading data from AudioSocket
Sven Kube [Tue, 13 May 2025 14:01:32 +0000 (16:01 +0200)] 
res_audiosocket.c: Add retry mechanism for reading data from AudioSocket

The added retry mechanism addresses an issue that arises when fragmented TCP
packets are received, each containing only a portion of an AudioSocket packet.
This situation can occur if the external service sending the AudioSocket data
has Nagle's algorithm enabled.

6 weeks agores_audiosocket.c: Set the TCP_NODELAY socket option
Sven Kube [Tue, 13 May 2025 13:37:38 +0000 (15:37 +0200)] 
res_audiosocket.c: Set the TCP_NODELAY socket option

Disable Nagle's algorithm by setting the TCP_NODELAY socket option.
This reduces latency by preventing delays caused by packet buffering.

7 weeks agomenuselect: Fix GTK menu callbacks for Fedora 42 compatibility
Thomas B. Clark [Mon, 12 May 2025 21:46:00 +0000 (17:46 -0400)] 
menuselect: Fix GTK menu callbacks for Fedora 42 compatibility

This patch resolves a build failure in `menuselect_gtk.c` when running
`make menuconfig` on Fedora 42. The new version of GTK introduced stricter
type checking for callback signatures.

Changes include:
- Add wrapper functions to match the expected `void (*)(void)` signature.
- Update `menu_items` array to use these wrappers.

Fixes: #1243
7 weeks agojansson: Upgrade version to jansson 2.14.1
Stanislav Abramenkov [Mon, 24 Mar 2025 13:10:26 +0000 (15:10 +0200)] 
jansson: Upgrade version to jansson 2.14.1

UpgradeNote: jansson has been upgraded to 2.14.1. For more
information visit jansson Github page: https://github.com/akheron/jansson/releases/tag/v2.14.1

Resolves: #1178

7 weeks agopjproject: Increase maximum SDP formats and attribute limits
Joe Searle [Thu, 15 May 2025 13:06:29 +0000 (14:06 +0100)] 
pjproject: Increase maximum SDP formats and attribute limits

Since Chrome 136, using Windows, when initiating a video call the INVITE SDP exceeds the maximum number of allowed attributes, resulting in the INVITE being rejected. This increases the attribute limit and the number of formats allowed when using bundled pjproject.

Fixes: #1240
7 weeks agomanager.c: Invalid ref-counting when purging events
Nathan Monfils [Mon, 5 May 2025 08:47:43 +0000 (10:47 +0200)] 
manager.c: Invalid ref-counting when purging events

We have a use-case where we generate a *lot* of events on the AMI, and
then when doing `manager show eventq` we would see some events which
would linger for hours or days in there. Obviously something was leaking.
Testing allowed us to track down this logic bug in the ref-counting on
the event purge.

Reproducing the bug was not super trivial, we managed to do it in a
production-like load testing environment with multiple AMI consumers.

The race condition itself:

1. something allocates and links `session`
2. `purge_sessions` iterates over that `session` (takes ref)
3. `purge_session` correctly de-referencess that session
4. `purge_session` re-evaluates the while() loop, taking a reference
5. `purge_session` exits (`n_max > 0` is false)
6. whatever allocated the `session` deallocates it, but a reference is
   now lost since we exited the `while` loop before de-referencing.
7. since the destructor is never called, the session->last_ev->usecount
   is never decremented, leading to events lingering in the queue

The impact of this bug does not seem major. The events are small and do
not seem, from our testing, to be causing meaningful additional CPU
usage. Mainly we wanted to fix this issue because we are internally
adding prometheus metrics to the eventq and those leaked events were
causing the metrics to show garbage data.

7 weeks agores_pjsip_nat.c: Do not overwrite transfer host
Mike Bradeen [Thu, 8 May 2025 18:12:33 +0000 (12:12 -0600)] 
res_pjsip_nat.c: Do not overwrite transfer host

When a call is transfered via dialplan behind a NAT, the
host portion of the Contact header in the 302 will no longer
be over-written with the external NAT IP and will retain the
hostname.

Fixes: #1141
7 weeks agochan_pjsip: Serialize INVITE creation on DTMF attended transfer
Mike Bradeen [Mon, 5 May 2025 18:05:15 +0000 (12:05 -0600)] 
chan_pjsip: Serialize INVITE creation on DTMF attended transfer

When a call is transfered via DTMF feature code, the Transfer Target and
Transferer are bridged immediately.  This opens the possibilty of a race
condition between the creation of an INVITE and the bridge induced colp
update that can result in the set caller ID being over-written with the
transferer's default info.

Fixes: #1234
2 months agoAlternate Channel Storage Backends
George Joseph [Tue, 31 Dec 2024 18:27:02 +0000 (11:27 -0700)] 
Alternate Channel Storage Backends

Full details: http://s.asterisk.net/dc679ec3

The previous proof-of-concept showed that the cpp_map_name_id alternate
storage backed performed better than all the others so this final PR
adds only that option.  You still need to enable it in menuselect under
the "Alternate Channel Storage Backends" category.

To select which one is used at runtime, set the "channel_storage_backend"
option in asterisk.conf to one of the values described in
asterisk.conf.sample.  The default remains "ao2_legacy".

UpgradeNote: With this release, you can now select an alternate channel
storage backend based on C++ Maps.  Using the new backend may increase
performance and reduce the chances of deadlocks on heavily loaded systems.
For more information, see http://s.asterisk.net/dc679ec3

2 months agosig_analog: Add Call Waiting Deluxe support.
Naveen Albert [Thu, 24 Aug 2023 14:07:06 +0000 (14:07 +0000)] 
sig_analog: Add Call Waiting Deluxe support.

Adds support for Call Waiting Deluxe options to enhance
the current call waiting feature.

As part of this change, a mechanism is also added that
allows a channel driver to queue an audio file for Dial()
to play, which is necessary for the announcement function.

ASTERISK-30373 #close

Resolves: #271

UserNote: Call Waiting Deluxe can now be enabled for FXS channels
by enabling its corresponding option.

2 months agoapp_sms: Ignore false positive vectorization warning.
Naveen Albert [Fri, 24 Jan 2025 14:35:50 +0000 (09:35 -0500)] 
app_sms: Ignore false positive vectorization warning.

Ignore gcc warning about writing 32 bytes into a region of size 6,
since we check that we don't go out of bounds for each byte.
This is due to a vectorization bug in gcc 15, stemming from
gcc commit 68326d5d1a593dc0bf098c03aac25916168bc5a9.

Resolves: #1088

2 months agolock.h: Add include for string.h when DEBUG_THREADS is defined.
George Joseph [Fri, 2 May 2025 18:19:25 +0000 (12:19 -0600)] 
lock.h: Add include for string.h when DEBUG_THREADS is defined.

When DEBUG_THREADS is defined, lock.h uses strerror(), which is defined
in the libc string.h file, to print warning messages. If the including
source file doesn't include string.h then strerror() won't be found and
and compile errors will be thrown. Since lock.h depends on this, string.h
is now included from there if DEBUG_THREADS is defined.  This way, including
source files don't have to worry about it.

2 months agores_pjsip_caller_id: Also parse URI parameters for ANI2.
Naveen Albert [Sat, 26 Apr 2025 12:33:20 +0000 (08:33 -0400)] 
res_pjsip_caller_id: Also parse URI parameters for ANI2.

If the isup-oli was sent as a URI parameter, rather than a header
parameter, it was not being parsed. Make sure we parse both if
needed so the ANI2 is set regardless of which type of parameter
the isup-oli is sent as.

Resolves: #1220

2 months agofunc_callerid: Always format ANI2 as two digits.
Naveen Albert [Sat, 26 Apr 2025 12:38:45 +0000 (08:38 -0400)] 
func_callerid: Always format ANI2 as two digits.

ANI II is always supposed to be formatted as two digits,
so zero pad when formatting it if necessary.

Resolves: #1222

2 months agoapp_meetme: Remove inaccurate removal version from xmldocs.
Naveen Albert [Sat, 26 Apr 2025 17:10:06 +0000 (13:10 -0400)] 
app_meetme: Remove inaccurate removal version from xmldocs.

app_meetme is deprecated but wasn't removed as planned in 21,
so remove the inaccurate removal version.

Resolves: #1224

2 months agodocs: Fix typos in apps/
Luz Paz [Wed, 9 Apr 2025 13:02:27 +0000 (09:02 -0400)] 
docs: Fix typos in apps/

Found via codespell

2 months agostasis/control.c: Set Hangup Cause to No Answer on Dial timeout
Mike Bradeen [Thu, 17 Apr 2025 15:50:21 +0000 (09:50 -0600)] 
stasis/control.c: Set Hangup Cause to No Answer on Dial timeout

Other Dial operations (dial, app_dial) use Q.850 cause 19 when a dial timeout occurs,
but the Dial command via ARI did not set an explicit reason. This resulted in a
CANCEL with Normal Call Clearing and corresponding ChannelDestroyed.

This change sets the hangup cause to AST_CAUSE_NO_ANSWER to be consistent with the
other operations.

Fixes: #963
UserNote:  A Dial timeout on POST /channels/{channelId}/dial will now result in a
CANCEL and ChannelDestroyed with cause 19 / User alerting, no answer.  Previously
no explicit cause was set, resulting in a cause of 16 / Normal Call Clearing.

2 months agochan_iax2: Minor improvements to documentation and warning messages.
Naveen Albert [Fri, 18 Apr 2025 13:03:10 +0000 (09:03 -0400)] 
chan_iax2: Minor improvements to documentation and warning messages.

* Update Dial() documentation for IAX2 to include syntax for RSA
  public key names.
* Add additional details to a couple warnings to provide more context
  when an undecodable frame is received.

Resolves: #1206

2 months agopbx_ael: unregister AELSub application and CLI commands on module load failure
Andreas Wehrmann [Fri, 18 Apr 2025 08:56:05 +0000 (10:56 +0200)] 
pbx_ael: unregister AELSub application and CLI commands on module load failure

This fixes crashes/hangs I noticed with Asterisk 20.3.0 and 20.13.0 and quickly found out,
that the AEL module doesn't do proper cleanup when it fails to load.
This happens for example when there are syntax errors and AEL fails to compile in which case pbx_load_module()
returns an error but load_module() doesn't then unregister CLI cmds and the application.

2 months agores_pjproject: Fix DTLS client check failing on some platforms
Albrecht Oster [Thu, 10 Apr 2025 21:54:00 +0000 (23:54 +0200)] 
res_pjproject: Fix DTLS client check failing on some platforms

Certain platforms (mainly BSD derivatives) have an additional length
field in `sockaddr_in6` and `sockaddr_in`.
`ast_sockaddr_from_pj_sockaddr()` does not take this field into account
when copying over values from the `pj_sockaddr` into the `ast_sockaddr`.
The resulting `ast_sockaddr` will have an uninitialized value for
`sin6_len`/`sin_len` while the other `ast_sockaddr` (not converted from
a `pj_sockaddr`) to check against in `ast_sockaddr_pj_sockaddr_cmp()`
has the correct length value set.

This has the effect that `ast_sockaddr_cmp()` will always indicate
an address mismatch, because it does a bitwise comparison, and all DTLS
packets are dropped even if addresses and ports match.

`ast_sockaddr_from_pj_sockaddr()` now checks whether the length fields
are available on the current platform and sets the values accordingly.

Resolves: #505

2 months agoPrequisites for ARI Outbound Websockets
George Joseph [Wed, 16 Apr 2025 19:40:52 +0000 (13:40 -0600)] 
Prequisites for ARI Outbound Websockets

stasis:
* Added stasis_app_is_registered().
* Added stasis_app_control_mark_failed().
* Added stasis_app_control_is_failed().
* Fixed res_stasis_device_state so unsubscribe all works properly.
* Modified stasis_app_unregister() to unsubscribe from all event sources.
* Modified stasis_app_exec to return -1 if stasis_app_control_is_failed()
  returns true.

http:
* Added ast_http_create_basic_auth_header().

md5:
* Added define for MD5_DIGEST_LENGTH.

tcptls:
* Added flag to ast_tcptls_session_args to suppress connection log messages
  to give callers more control over logging.

http_websocket:
* Add flag to ast_websocket_client_options to suppress connection log messages
  to give callers more control over logging.
* Added username and password to ast_websocket_client_options to support
  outbound basic authentication.
* Added ast_websocket_result_to_str().

2 months agocontrib: Add systemd service and timer files for malloc trim.
Ben Ford [Wed, 16 Apr 2025 18:45:03 +0000 (13:45 -0500)] 
contrib: Add systemd service and timer files for malloc trim.

Adds two files to the contrib/systemd/ directory that can be installed
to periodically run "malloc trim" on Asterisk. These files do nothing
unless they are explicitly moved to the correct location on the system.
Users who are experiencing Asterisk memory issues can use this service
to potentially help combat the problem. These files can also be
configured to change the start time and interval. See systemd.timer(5)
and systemd.time(7) for more information.

UserNote: Service and timer files for systemd have been added to the
contrib/systemd/ directory. If you are experiencing memory issues,
install these files to have "malloc trim" periodically run on the
system.

2 months agoaction_redirect: remove after_bridge_goto_info
Peter Jannesen [Thu, 13 Mar 2025 21:52:53 +0000 (22:52 +0100)] 
action_redirect: remove after_bridge_goto_info

Under certain circumstances the context/extens/prio are stored in the
after_bridge_goto_info. This info is used when the bridge is broken by
for hangup of the other party. In the situation that the bridge is
broken by an AMI Redirect this info is not used but also not removed.
With the result that when the channel is put back in a bridge and the
bridge is broken the execution continues at the wrong
context/extens/prio.

Resolves: #1144

2 months agochannel: Always provide cause code in ChannelHangupRequest.
Joshua C. Colp [Wed, 16 Apr 2025 09:29:11 +0000 (06:29 -0300)] 
channel: Always provide cause code in ChannelHangupRequest.

When queueing a channel to be hung up a cause code can be
specified in one of two ways:

1. ast_queue_hangup_with_cause
This function takes in a cause code and queues it as part
of the hangup request, which ultimately results in it being
set on the channel.

2. ast_channel_hangupcause_set + ast_queue_hangup
This combination sets the hangup cause on the channel before
queueing the hangup instead of as part of that process.

In the #2 case the ChannelHangupRequest event would not contain
the cause code. For consistency if a cause code has been set
on the channel it will now be added to the event.

Resolves: #1197

2 months agoAdd log-caller-id-name option to log Caller ID Name in queue log
phoneben [Thu, 27 Feb 2025 23:25:50 +0000 (01:25 +0200)] 
Add log-caller-id-name option to log Caller ID Name in queue log

Add log-caller-id-name option to log Caller ID Name in queue log

This patch introduces a new global configuration option, log-caller-id-name,
to queues.conf to control whether the Caller ID name is logged when a call enters a queue.

When log-caller-id-name=yes, the Caller ID name is logged
as parameter 4 in the queue log, provided it’s allowed by the
existing log_restricted_caller_id rules. If log-caller-id-name=no (the default),
the Caller ID name is omitted from the logs.

Fixes: #1091
UserNote: This patch adds a global configuration option, log-caller-id-name, to queues.conf
to control whether the Caller ID name is logged as parameter 4 when a call enters a queue.
When log-caller-id-name=yes, the Caller ID name is included in the queue log,
Any '|' characters in the caller ID name will be replaced with '_'.
(provided it’s allowed by the existing log_restricted_caller_id rules).
When log-caller-id-name=no (the default), the Caller ID name is omitted.

2 months agoasterisk.c: Add "pre-init" and "pre-module" capability to cli.conf.
George Joseph [Thu, 10 Apr 2025 13:59:34 +0000 (07:59 -0600)] 
asterisk.c: Add "pre-init" and "pre-module" capability to cli.conf.

Commands in the "[startup_commands]" section of cli.conf have historically run
after all core and module initialization has been completed and just before
"Asterisk Ready" is printed on the console. This meant that if you
wanted to debug initialization of a specific module, your only option
was to turn on debug for everything by setting "debug" in asterisk.conf.

This commit introduces options to allow you to run CLI commands earlier in
the asterisk startup process.

A command with a value of "pre-init" will run just after logger initialization
but before most core, and all module, initialization.

A command with a value of "pre-module" will run just after all core
initialization but before all module initialization.

A command with a value of "fully-booted" (or "yes" for backwards
compatibility) will run as they always have been...after all
initialization and just before "Asterisk Ready" is printed on the console.

This means you could do this...

```
[startup_commands]
core set debug 3 res_pjsip.so = pre-module
core set debug 0 res_pjsip.so = fully-booted
```

This would turn debugging on for res_pjsip.so to catch any module
initialization debug messages then turn it off again after the module is
loaded.

UserNote: In cli.conf, you can now define startup commands that run before
core initialization and before module initialization.

2 months agoapp_confbridge: Prevent crash when publishing channel-less event.
Sean Bright [Mon, 7 Apr 2025 21:05:28 +0000 (17:05 -0400)] 
app_confbridge: Prevent crash when publishing channel-less event.

Resolves: #1190

2 months agochannel: Deprecate `ast_moh_cleanup(...)`.
Sean Bright [Tue, 8 Apr 2025 20:08:42 +0000 (16:08 -0400)] 
channel: Deprecate `ast_moh_cleanup(...)`.

We don't want anyone calling it but the channel destructor.

3 months agoari_websockets: Fix frack if ARI config fails to load.
George Joseph [Wed, 2 Apr 2025 14:44:00 +0000 (08:44 -0600)] 
ari_websockets: Fix frack if ARI config fails to load.

ari_ws_session_registry_dtor() wasn't checking that the container was valid
before running ao2_callback on it to shutdown registered sessions.

3 months agoARI: REST over Websocket
George Joseph [Wed, 12 Mar 2025 21:58:51 +0000 (15:58 -0600)] 
ARI: REST over Websocket

This commit adds the ability to make ARI REST requests over the same
websocket used to receive events.

For full details on how to use the new capability, visit...

https://docs.asterisk.org/Configuration/Interfaces/Asterisk-REST-Interface-ARI/ARI-REST-over-WebSocket/

Changes:

* Added utilities to http.c:
  * ast_get_http_method_from_string().
  * ast_http_parse_post_form().
* Added utilities to json.c:
  * ast_json_nvp_array_to_ast_variables().
  * ast_variables_to_json_nvp_array().
* Added definitions for new events to carry REST responses.
* Created res/ari/ari_websocket_requests.c to house the new request handlers.
* Moved non-event specific code out of res/ari/resource_events.c into
  res/ari/ari_websockets.c
* Refactored res/res_ari.c to move non-http code out of ast_ari_callback()
  (which is http specific) and into ast_ari_invoke() so it can be shared
  between both the http and websocket transports.

UpgradeNote: This commit adds the ability to make ARI REST requests over the same
websocket used to receive events.
See https://docs.asterisk.org/Configuration/Interfaces/Asterisk-REST-Interface-ARI/ARI-REST-over-WebSocket/

3 months agoaudiohook.c: Add ability to adjust volume with float
mkmer [Tue, 18 Mar 2025 11:51:06 +0000 (07:51 -0400)] 
audiohook.c: Add ability to adjust volume with float

Add the capability to audiohook for float type volume adjustments.  This allows for adjustments to volume smaller than 6dB.  With INT adjustments, the first step is 2 which converts to ~6dB (or 1/2 volume / double volume depending on adjustment sign). 3dB is a typical adjustment level which can now be accommodated with an adjustment value of 1.41.

This is accomplished by the following:
  Convert internal variables to type float.
  Always use ast_frame_adjust_volume_float() for adjustments.
  Cast int to float in original functions ast_audiohook_volume_set(), and ast_volume_adjust().
  Cast float to int in ast_audiohook_volume_get()
  Add functions ast_audiohook_volume_get_float, ast_audiohook_volume_set_float, and ast_audiohook_volume_adjust_float.

This update maintains 100% backward compatibility.

Resolves: #1171

3 months agoaudiosocket: added support for DTMF frames
Florent CHAUVEAU [Fri, 28 Feb 2025 07:47:18 +0000 (08:47 +0100)] 
audiosocket: added support for DTMF frames

Updated the AudioSocket protocol to allow sending DTMF frames.
AST_FRAME_DTMF frames are now forwarded to the server, in addition to
AST_FRAME_AUDIO frames. A new payload type AST_AUDIOSOCKET_KIND_DTMF
with value 0x03 was added to the protocol. The payload is a 1-byte
ascii representing the DTMF digit (0-9,*,#...).

UserNote: The AudioSocket protocol now forwards DTMF frames with
payload type 0x03. The payload is a 1-byte ascii representing the DTMF
digit (0-9,*,#...).

3 months agoasterisk/channel.h: fix documentation for 'ast_waitfor_nandfds()'
Norm Harrison [Tue, 4 Apr 2023 03:39:09 +0000 (22:39 -0500)] 
asterisk/channel.h: fix documentation for 'ast_waitfor_nandfds()'

Co-authored-by: Florent CHAUVEAU <florentch@pm.me>
3 months agoaudiosocket: fix timeout, fix dialplan app exit, server address in logs
Norm Harrison [Tue, 4 Apr 2023 02:36:11 +0000 (21:36 -0500)] 
audiosocket: fix timeout, fix dialplan app exit, server address in logs

- Correct wait timeout logic in the dialplan application.
- Include server address in log messages for better traceability.
- Allow dialplan app to exit gracefully on hangup messages and socket closure.
- Optimize I/O by reducing redundant read()/write() operations.

Co-authored-by: Florent CHAUVEAU <florentch@pm.me>
3 months agochan_pjsip: Add the same details as PJSIPShowContacts to the CLI via 'pjsip show...
Mark Murawski [Mon, 24 Mar 2025 01:05:55 +0000 (21:05 -0400)] 
chan_pjsip:  Add the same details as PJSIPShowContacts to the CLI via 'pjsip show contact'

CLI 'pjsip show contact' does not show enough information.
One must telnet to AMI or write a script to ask Asterisk for example what the User-Agent is on a Contact
This feature adds the same details as PJSIPShowContacts to the CLI

Resolves: #643

3 months agoUpdate config.guess and config.sub
Zhai Liangliang [Wed, 26 Mar 2025 06:44:34 +0000 (14:44 +0800)] 
Update config.guess and config.sub

3 months agochan_pjsip: set correct Endpoint Device State on multiple channels
Alexei Gradinari [Tue, 25 Mar 2025 21:24:29 +0000 (17:24 -0400)] 
chan_pjsip: set correct Endpoint Device State on multiple channels

1. When one channel is placed on hold, the device state is set to ONHOLD
without checking other channels states.
In case of AST_CONTROL_HOLD set the device state as AST_DEVICE_UNKNOWN
to calculate aggregate device state of all active channels.

2. The current implementation incorrectly classifies channels in use.
The only channels that has the states: UP, RING and BUSY are considered as "in use".
A channel should be considered "in use" if its state is anything other than
DOWN or RESERVED.

3. Currently, if the number of channels "in use" is greater than device_state_busy_at,
the system does not set the state to BUSY. Instead, it incorrectly assigns an aggregate
device state.
The endpoint device state should be BUSY if the number of channels "in use" is greater
than or equal to device_state_busy_at.

Fixes: #1181
3 months agofile.c: missing "custom" sound files should not generate warning logs
Allan Nathanson [Tue, 18 Mar 2025 23:54:48 +0000 (19:54 -0400)] 
file.c: missing "custom" sound files should not generate warning logs

With `sounds_search_custom_dir = yes` we first look to see if a sound file
is present in the "custom" sound directory before looking in the standard
sound directories.  We should not be issuing a WARNING log message if a
sound cannot be found in the "custom" directory.

Resolves: https://github.com/asterisk/asterisk/issues/1170

3 months agodocumentation: Update Gosub, Goto, and add new documentationtype.
Ben Ford [Fri, 14 Mar 2025 22:05:30 +0000 (17:05 -0500)] 
documentation: Update Gosub, Goto, and add new documentationtype.

Gosub and Goto were not displaying their syntax correctly on the docs
site. This change adds a new way to specify an optional context, an
optional extension, and a required priority that the xml stylesheet can
parse without having to know which optional parameters come in which
order. In Asterisk, it looks like this:

  parameter name="context" documentationtype="dialplan_context"
  parameter name="extension" documentationtype="dialplan_extension"
  parameter name="priority" documentationtype="dialplan_priority" required="true"

The stylesheet will ignore the context and extension parameters, but for
priority, it will automatically inject the following:

  [[context,]extension,]priority

This is the correct oder for applications such as Gosub and Goto.

3 months agores_config_curl.c: Remove unnecessary warnings.
Sean Bright [Mon, 17 Mar 2025 14:30:46 +0000 (10:30 -0400)] 
res_config_curl.c: Remove unnecessary warnings.

Resolves: #1164

3 months agoREADME.md: Updates and Fixes
George Joseph [Wed, 5 Mar 2025 19:21:45 +0000 (12:21 -0700)] 
README.md: Updates and Fixes

* Outdated information has been removed.
* New links added.
* Placeholder added for link to change logs.

Going forward, the release process will create HTML versions of the README
and change log and will update the link in the README to the current
change log for the branch...

* In the development branches, the link will always point to the current
  release on GitHub.
* In the "releases/*" branches and the tarballs, the link will point to the
  ChangeLogs/ChangeLog-<version>.html file in the source directory.
* On the downloads website, the link will point to the
  ChangeLog-<version>.html file in the same directory.

Resolves: #1131

3 months agores_rtp_asterisk.c: Don't truncate spec-compliant `ice-ufrag` or `ice-pwd`.
Sean Bright [Fri, 7 Mar 2025 16:32:00 +0000 (11:32 -0500)] 
res_rtp_asterisk.c: Don't truncate spec-compliant `ice-ufrag` or `ice-pwd`.

RFC 8839[1] indicates that the `ice-ufrag` and `ice-pwd` attributes
can be up to 256 bytes long. While we don't generate values of that
size, we should be able to accomodate them without truncating.

1. https://www.rfc-editor.org/rfc/rfc8839#name-ice-ufrag-and-ice-pwd-attri

3 months agofix: Correct default flag for tcp_keepalive_enable option
Joshua Elson [Fri, 7 Mar 2025 00:52:26 +0000 (17:52 -0700)] 
fix: Correct default flag for tcp_keepalive_enable option

Resolves an issue where the tcp_keepalive_enable option was not properly enabled in the sample configuration due to an incorrect default flag setting.

Fixes: #1149
3 months agoconfig.c: Fix inconsistent pointer logic in ast_variable_update.
Naveen Albert [Fri, 7 Mar 2025 01:53:50 +0000 (20:53 -0500)] 
config.c: Fix inconsistent pointer logic in ast_variable_update.

Commit 3cab4e7ab4a3ae483430d5f5e8fa167d02a8128c introduced a
regression by causing the wrong pointers to be used in certain
(more complex) cases. We now take care to ensure the exact
same pointers are used as before that commit, and simplify
by eliminating the unnecessary second for loop.

Resolves: #1147

4 months agodocs: AMI documentation fixes.
Sean Bright [Tue, 18 Feb 2025 16:21:55 +0000 (11:21 -0500)] 
docs: AMI documentation fixes.

Most of this patch is adding missing PJSIP-related event
documentation, but the one functional change was adding a sorcery
to-string handler for endpoint's `redirect_method` which was not
showing up in the AMI event details or `pjsip show endpoint
<endpoint>` output.

The rest of the changes are summarized below:

* app_agent_pool.c: Typo fix Epoche -> Epoch.
* stasis_bridges.c: Add missing AttendedTransfer properties.
* stasis_channels.c: Add missing AgentLogoff properties.
* pjsip_manager.xml:
  - Add missing AorList properties.
  - Add missing AorDetail properties.
  - Add missing ContactList properties.
  - Add missing ContactStatusDetail properties.
  - Add missing EventDetail properties.
  - Add missing AuthList properties.
  - Add missing AuthDetail properties.
  - Add missing TransportDetail properties.
  - Add missing EndpointList properties.
  - Add missing IdentifyDetail properties.
* res_pjsip_registrar.c: Add missing InboundRegistrationDetail documentation.
* res_pjsip_pubsub.c:
  - Add missing ResourceListDetail documentation.
  - Add missing InboundSubscriptionDetail documentation.
  - Add missing OutboundSubscriptionDetail documentation.
* res_pjsip_outbound_registration.c: Add missing OutboundRegistrationDetail documentation.

4 months agoconfig.c: #include of non-existent file should not crash
Allan Nathanson [Mon, 3 Mar 2025 14:53:02 +0000 (09:53 -0500)] 
config.c: #include of non-existent file should not crash

Corrects a segmentation fault when a configuration file has a #include
statement that referenced a file that does not exist.

Resolves: https://github.com/asterisk/asterisk/issues/1139

4 months agomanager.c: Check for restricted file in action_createconfig.
George Joseph [Mon, 3 Mar 2025 21:07:43 +0000 (14:07 -0700)] 
manager.c: Check for restricted file in action_createconfig.

The `CreateConfig` manager action now ensures that a config file can
only be created in the AST_CONFIG_DIR unless `live_dangerously` is set.

Resolves: #1122

4 months agoswagger_model.py: Fix invalid escape sequence in get_list_parameter_type().
George Joseph [Tue, 4 Mar 2025 14:29:22 +0000 (07:29 -0700)] 
swagger_model.py: Fix invalid escape sequence in get_list_parameter_type().

Recent python versions complain when backslashes in strings create invalid
escape sequences.  This causes issues for strings used as regex patterns like
`'^List\[(.*)\]$'` where you want the regex parser to treat `[` and `]`
as literals.  Double-backslashing is one way to fix it but simply converting
the string to a raw string `re.match(r'^List\[(.*)\]$', text)` is easier
and less error prone.

4 months agoRevert "res_rtp_asterisk.c: Set Mark on rtp when timestamp skew is too big"
Maximilian Fridrich [Fri, 28 Feb 2025 07:43:44 +0000 (08:43 +0100)] 
Revert "res_rtp_asterisk.c: Set Mark on rtp when timestamp skew is too big"

This reverts commit f30ad96b3f467739c38ff415e80bffc4afff1da7.

The original change was not RFC compliant and caused issues because it
set the RTP marker bit in cases when it shouldn't be set. See the
linked issue #1135 for a detailed explanation.

Fixes: #1135.
4 months agores_rtp_asterisk.c: Use correct timeout value for T.140 RED timer.
Sean Bright [Mon, 24 Feb 2025 21:49:24 +0000 (16:49 -0500)] 
res_rtp_asterisk.c: Use correct timeout value for T.140 RED timer.

Found while reviewing #1128

4 months agodocs: Fix typos in cdr/ 1092/head
Luz Paz [Wed, 12 Feb 2025 15:15:10 +0000 (10:15 -0500)] 
docs: Fix typos in cdr/
Found via codespell

4 months agodocs: Fix various typos in channels/
Luz Paz [Tue, 4 Feb 2025 11:44:31 +0000 (06:44 -0500)] 
docs: Fix various typos in channels/
Found via `codespell -q 3 -S "./CREDITS,*.po" -L abd,asent,atleast,cachable,childrens,contentn,crypted,dne,durationm,enew,exten,inout,leapyear,mye,nd,oclock,offsetp,ot,parm,parms,preceeding,pris,ptd,requestor,re-use,re-used,re-uses,ser,siz,slanguage,slin,thirdparty,varn,varns,ues`

4 months agodocs: Fix various typos in main/
Luz Paz [Tue, 4 Feb 2025 10:53:17 +0000 (05:53 -0500)] 
docs: Fix various typos in main/
Found via `codespell -q 3 -S "./CREDITS" -L abd,asent,atleast,childrens,contentn,crypted,dne,durationm,exten,inout,leapyear,nd,oclock,offsetp,ot,parm,parms,requestor,ser,slanguage,slin,thirdparty,varn,varns,ues`

4 months agobridging: Fix multiple bridging issues causing SEGVs and FRACKs.
George Joseph [Wed, 22 Jan 2025 20:52:33 +0000 (13:52 -0700)] 
bridging: Fix multiple bridging issues causing SEGVs and FRACKs.

Issues:

* The bridging core allowed multiple bridges to be created with the same
  unique bridgeId at the same time.  Only the last bridge created with the
  duplicate name was actually saved to the core bridges container.

* The bridging core was creating a stasis topic for the bridge and saving it
  in the bridge->topic field but not increasing its reference count.  In the
  case where two bridges were created with the same uniqueid (which is also
  the topic name), the second bridge would get the _existing_ topic the first
  bridge created.  When the first bridge was destroyed, it would take the
  topic with it so when the second bridge attempted to publish a message to
  it it either FRACKed or SEGVd.

* The bridge destructor, which also destroys the bridge topic, is run from the
  bridge manager thread not the caller's thread.  This makes it possible for
  an ARI developer to create a new one with the same uniqueid believing the
  old one was destroyed when, in fact, the old one's destructor hadn't
  completed. This could cause the new bridge to get the old one's topic just
  before the topic was destroyed.  When the new bridge attempted to publish
  a message on that topic, asterisk could either FRACK or SEGV.

* The ARI bridges resource also allowed multiple bridges to be created with
  the same uniqueid but it kept the duplicate bridges in its app_bridges
  container.  This created a situation where if you added two bridges with
  the same "bridge1" uniqueid, all operations on "bridge1" were performed on
  the first bridge created and the second was basically orphaned.  If you
  attempted to delete what you thought was the second bridge, you actually
  deleted the first one created.

Changes:

* A new API `ast_bridge_topic_exists(uniqueid)` was created to determine if
  a topic already exists for a bridge.

* `bridge_base_init()` in bridge.c and `ast_ari_bridges_create()` in
  resource_bridges.c now call `ast_bridge_topic_exists(uniqueid)` to check
  if a bridge with the requested uniqueid already exists and will fail if it
  does.

* `bridge_register()` in bridges.c now checks the core bridges container to
  make sure a bridge doesn't already exist with the requested uniqueid.
  Although most callers of `bridge_register()` will have already called
  `bridge_base_init()`, which will now fail on duplicate bridges, there
  is no guarantee of this so we must check again.

* The core bridges container allocation was changed to reject duplicate
  uniqueids instead of silently replacing an existing one. This is a "belt
  and suspenders" check.

* A global mutex was added to bridge.c to prevent concurrent calls to
  `bridge_base_init()` and `bridge_register()`.

* Even though you can no longer create multiple bridges with the same uniqueid
  at the same time, it's still possible that the bridge topic might be
  destroyed while a second bridge with the same uniqueid was trying to use
  it. To address this, the bridging core now increments the reference count
  on bridge->topic when a bridge is created and decrements it when the
  bridge is destroyed.

* `bridge_create_common()` in res_stasis.c now checks the stasis app_bridges
  container to make sure a bridge with the requested uniqueid doesn't already
  exist.  This may seem like overkill but there are so many entrypoints to
  bridge creation that we need to be safe and catch issues as soon in the
  process as possible.

* The stasis app_bridges container allocation was changed to reject duplicate
  uniqueids instead of adding them. This is a "belt and suspenders" check.

* The `bridge show all` CLI command now shows the bridge name as well as the
  bridge id.

* Response code 409 "Conflict" was added as a possible response from the ARI
  bridge create resources to signal that a bridge with the requested uniqueid
  already exists.

* Additional debugging was added to multiple bridging and stasis files.

Resolves: #211

4 months ago.github: Change concurrency group ids so they're unique.
George Joseph [Thu, 20 Feb 2025 17:40:04 +0000 (10:40 -0700)] 
.github: Change concurrency group ids so they're unique.

GitHub strikes again.  Apparently the github.ref context variable only
contains the PR number if the workflow is triggered by "pull_request" so
since we just changed the trigger to "pull_request_target" the variable
no longer contains the PR number and is therefore not unique and can't be
used as a concurrency group id.  We now use
`github.triggering_actor-github.head_ref`.

4 months agobridge_channel: don't set cause code on channel during bridge delete if already set
Mike Bradeen [Tue, 18 Feb 2025 22:17:07 +0000 (15:17 -0700)] 
bridge_channel: don't set cause code on channel during bridge delete if already set

Due to a potential race condition via ARI when hanging up a channel hangup with cause
while also deleting a bridge containing that channel, the bridge delete can over-write
the hangup cause code resulting in Normal Call Clearing instead of the set value.

With this change, bridge deletion will only set the hangup code if it hasn't been
previously set.

Resolves: #1124

4 months ago.github: Refactor Releaser to use reusable workflow
George Joseph [Sun, 16 Feb 2025 23:30:00 +0000 (16:30 -0700)] 
.github: Refactor Releaser to use reusable workflow

4 months ago.github: Change branch of reusable workflows to main.
George Joseph [Sun, 16 Feb 2025 23:24:27 +0000 (16:24 -0700)] 
.github: Change branch of reusable workflows to main.

4 months ago.github: Refactor to use pull_request_target trigger.
George Joseph [Thu, 13 Feb 2025 20:22:31 +0000 (13:22 -0700)] 
.github: Refactor to use pull_request_target trigger.

After careful review, we believe we can now use the "pull_request_target"
workflow trigger instead of "pull_request" which required a separate
privliged workflow to add labels and comments to PRs when they are submitted
or updated.  This allows us to greatly streamline our workflows and remove
unneeded ones.

* The OnPRChanged workflow was...
  * Renamed to OnPRCheck
  * Changed to trigger on pull_request_target and the "recheckpr" label.
  * Changed to simply call reusable workflows in asterisk-ci-actions.
  * Changed to use better concurrency groups.
* The OnPRCPCheck and OnPRMergeApproved workflows were also...
  * Changed to simply call reusable workflows in asterisk-ci-actions.
  * Changed to use better concurrency groups.
* The NightlyTest and CreateDocs were also tweaked

4 months agores_config_pgsql: Fix regression that removed dbname config.
George Joseph [Tue, 11 Feb 2025 18:35:14 +0000 (11:35 -0700)] 
res_config_pgsql: Fix regression that removed dbname config.

A recent commit accidentally removed the code that sets dbname.
This commit adds it back in.

Resolves: #1119

4 months agores_stir_shaken: Allow missing or anonymous CID to continue to the dialplan.
George Joseph [Wed, 5 Feb 2025 17:33:10 +0000 (10:33 -0700)] 
res_stir_shaken: Allow missing or anonymous CID to continue to the dialplan.

The verification check for missing or anonymous callerid was happening before
the endpoint's profile was retrieved which meant that the failure_action
parameter wasn't available.  Therefore, if verification was enabled and there
was no callerid or it was "anonymous", the call was immediately terminated
instead of giving the dialplan the ability to decide what to do with the call.

* The callerid check now happens after the verification context is created and
  the endpoint's stir_shaken_profile is available.

* The check now processes the callerid failure just as it does for other
  verification failures and respects the failure_action parameter.  If set
  to "continue" or "continue_return_reason", `STIR_SHAKEN(0,verify_result)`
  in the dialplan will return "invalid_or_no_callerid".

* If the endpoint's failure_action is "reject_request", the call will be
  rejected with `433 "Anonymity Disallowed"`.

* If the endpoint's failure_action is "continue_return_reason", the call will
  continue but a `Reason: STIR; cause=433; text="Anonymity Disallowed"`
  header will be added to the next provisional or final response.

Resolves: #1112

4 months agoresource_channels.c: Fix memory leak in ast_ari_channels_external_media.
George Joseph [Tue, 4 Feb 2025 20:00:16 +0000 (13:00 -0700)] 
resource_channels.c: Fix memory leak in ast_ari_channels_external_media.

Between ast_ari_channels_external_media(), external_media_rtp_udp(),
and external_media_audiosocket_tcp(), the `variables` structure being passed
around wasn't being cleaned up properly when there was a failure.

* In ast_ari_channels_external_media(), the `variables` structure is now
  defined with RAII_VAR to ensure it always gets cleaned up.

* The ast_variables_destroy() call was removed from external_media_rtp_udp().

* The ast_variables_destroy() call was removed from
  external_media_audiosocket_tcp(), its `endpoint` allocation was changed to
  to use ast_asprintf() as external_media_rtp_udp() does, and it now
  returns an error on failure.

* ast_ari_channels_external_media() now checks the new return code from
  external_media_audiosocket_tcp() and sets the appropriate error response.

Resolves: #1109

4 months agoari/pjsip: Make it possible to control transfers through ARI
Holger Hans Peter Freyther [Sat, 15 Jun 2024 08:01:58 +0000 (16:01 +0800)] 
ari/pjsip: Make it possible to control transfers through ARI

Introduce a ChannelTransfer event and the ability to notify progress to
ARI. Implement emitting this event from the PJSIP channel instead of
handling the transfer in Asterisk when configured.

Introduce a dialplan function to the PJSIP channel to switch between the
"core" and "ari-only" behavior.

UserNote: Call transfers on the PJSIP channel can now be controlled by
ARI. This can be enabled by using the PJSIP_TRANSFER_HANDLING(ari-only)
dialplan function.

4 months ago.github: Remove concurrency check in on-labelled workflows.
George Joseph [Tue, 11 Feb 2025 20:59:17 +0000 (13:59 -0700)] 
.github: Remove concurrency check in on-labelled workflows.

Apparently you can't use `${{ github.event.number }}` in a concurrency
block in a job that calls a reusable workflow. :(

4 months agochannel.c: Remove dead AST_GENERATOR_FD code.
Sean Bright [Thu, 6 Feb 2025 16:35:27 +0000 (11:35 -0500)] 
channel.c: Remove dead AST_GENERATOR_FD code.

Nothing ever sets the `AST_GENERATOR_FD`, so this block of code will
never execute. It also is the only place where the `generate` callback
is called with the channel lock held which made it difficult to reason
about the thread safety of `ast_generator`s.

In passing, also note that `AST_AGENT_FD` isn't used either.

4 months ago.github: Move PRChanged,PRChangedPriv,PRCPCheck,PRReCheck,PRMerge logic.
George Joseph [Tue, 11 Feb 2025 15:40:14 +0000 (08:40 -0700)] 
.github: Move PRChanged,PRChangedPriv,PRCPCheck,PRReCheck,PRMerge logic.

Moved to asterisk-ci-actions reusable workflows.

4 months ago.github: OnPRCherryPickTest,OnPRStateChanged,OnPRRecheck: Add job summaries.
George Joseph [Sat, 8 Feb 2025 21:21:17 +0000 (14:21 -0700)] 
.github: OnPRCherryPickTest,OnPRStateChanged,OnPRRecheck: Add job summaries.

...and refactor environment variables.

4 months ago.github: Clean up CreateDocs
George Joseph [Mon, 10 Feb 2025 18:44:18 +0000 (11:44 -0700)] 
.github: Clean up CreateDocs

5 months agofunc_strings.c: Prevent SEGV in HASH single-argument mode.
George Joseph [Thu, 30 Jan 2025 15:49:33 +0000 (08:49 -0700)] 
func_strings.c: Prevent SEGV in HASH single-argument mode.

When in single-argument mode (very rarely used), a malformation of a column
name (also very rare) could cause a NULL to be returned when retrieving the
channel variable for that column.  Passing that to strncat causes a SEGV.  We
now check for the NULL and print a warning message.

Resolves: #1101

5 months agoutils: Remove libdb and astdb conversion scripts.
Sean Bright [Wed, 29 Jan 2025 16:45:54 +0000 (11:45 -0500)] 
utils: Remove libdb and astdb conversion scripts.

These were included with Asterisk 10 when we switched astdb from libdb
to sqlite3.

5 months agodocs: Add version information to AGI command XML elements.
George Joseph [Fri, 24 Jan 2025 20:55:47 +0000 (13:55 -0700)] 
docs: Add version information to AGI command XML elements.

This process was a bit different than the others because everything
is in the same file, there's an array that contains the command
names and their handler functions, and the last command was created
over 15 years ago.

* Dump a `git blame` of res/res_agi.c from BEFORE the handle_* prototypes
  were changed.
* Create a command <> handler function xref by parsing the the agi_command
  array.
* For each entry, grep the function definition line "static int handle_*"
  from the git blame output and capture the commit.  This will be the
  commit the command was created in.
* Do a `git tag --contains <commit> | sort -V | head -1` to get the
  tag the function was created in.
* Add a single since/version element to the command XML.  Multiple versions
  aren't supported here because the branching and tagging scheme changed
  several times in the 2000's.

5 months agodocs: Fix minor typo in MixMonitor AMI action
Jeremy Lainé [Tue, 28 Jan 2025 15:25:32 +0000 (16:25 +0100)] 
docs: Fix minor typo in MixMonitor AMI action

The `Options` argument was erroneously documented as lowercase
`options`.

5 months agoutils: Disable old style definition warnings for libdb.
Naveen Albert [Fri, 24 Jan 2025 01:08:23 +0000 (20:08 -0500)] 
utils: Disable old style definition warnings for libdb.

Newer versions of gcc now warn about old style definitions, such
as those in libdb, which causes compilation failure with DEVMODE
enabled. Ignore these warnings for libdb.

Resolves: #1085

5 months agortp.conf.sample: Correct stunaddr example.
fabriziopicconi [Wed, 25 Sep 2024 09:54:01 +0000 (11:54 +0200)] 
rtp.conf.sample: Correct stunaddr example.

5 months agodocs: Add version information to ARI resources and methods.
George Joseph [Mon, 27 Jan 2025 15:30:40 +0000 (08:30 -0700)] 
docs: Add version information to ARI resources and methods.

* Dump a git blame of each file in rest-api/api-docs.

* Get the commit for each "resourcePath" and "httpMethod" entry.

* Find the tags for each commit (same as other processes).

* Insert a "since" array after each "resourcePath" and "httpMethod" entry.

5 months agores_pjsip_authenticator_digest: Make correct error messages appear again.
George Joseph [Tue, 28 Jan 2025 16:14:34 +0000 (09:14 -0700)] 
res_pjsip_authenticator_digest: Make correct error messages appear again.

When an incoming request can't be matched to an endpoint, the "artificial"
auth object is used to create a challenge to return in a 401 response and we
emit a "No matching endpoint found" log message. If the client then responds
with an Authorization header but the request still can't be matched to an
endpoint, the verification will fail and, as before, we'll create a challenge
to return in a 401 response and we emit a "No matching endpoint found" log
message.  HOWEVER, because there WAS an Authorization header and it failed
verification, we should have also been emitting a "Failed to authenticate"
log message but weren't because there was a check that short-circuited that
it if the artificial auth was used.  Since many admins use the "Failed to
authenticate" message with log parsers like fail2ban, those attempts were not
being recognized as suspicious.

Changes:

* digest_check_auth() now always emits the "Failed to authenticate" log
  message if verification of an Authorization header failed even if the
  artificial auth was used.

* The verification logic was refactored to be clearer about the handling
  of the return codes from verify().

* Comments were added clarify what return codes digest_check_auth() should
  return to the distributor and the implications of changing them.

Resolves: #1095

5 months agoalembic: Database updates required.
George Joseph [Tue, 28 Jan 2025 16:51:42 +0000 (09:51 -0700)] 
alembic: Database updates required.

This commit doesn't actually change anything.  It just adds the following
upgrade notes that were omitted from the original commits.

Resolves: #1097

UpgradeNote: Two commits in this release...
'Add SHA-256 and SHA-512-256 as authentication digest algorithms'
'res_pjsip: Add new AOR option "qualify_2xx_only"'
...have modified alembic scripts for the following database tables: ps_aors,
ps_contacts, ps_auths, ps_globals. If you don't use the scripts to update
your database, reads from those tables will succeeed but inserts into the
ps_contacts table by res_pjsip_registrar will fail.

5 months agodocs: Indent <since> tags.
Sean Bright [Thu, 23 Jan 2025 21:35:58 +0000 (16:35 -0500)] 
docs: Indent <since> tags.

Also updates the 'since' of applications/functions that existed before
XML documentation was introduced (1.6.2.0).