Commit Graph

34230 Commits

Author SHA1 Message Date
George Joseph
683f3fb387 chan_pjsip: Add technology-specific off-nominal hangup cause to events.
Although the ISDN/Q.850/Q.931 hangup cause code is already part of the ARI
and AMI hangup and channel destroyed events, it can be helpful to know what
the actual channel technology code was if the call was unsuccessful.
For PJSIP, it's the SIP response code.

* A new "tech_hangupcause" field was added to the ast_channel structure along
with ast_channel_tech_hangupcause() and ast_channel_tech_hangupcause_set()
functions.  It should only be set for off-nominal terminations.

* chan_pjsip was modified to set the tech hangup cause in the
chan_pjsip_hangup() and chan_pjsip_session_end() functions.  This is a bit
tricky because these two functions aren't always called in the same order.
The channel that hangs up first will get chan_pjsip_session_end() called
first which will trigger the core to call chan_pjsip_hangup() on itself,
then call chan_pjsip_hangup() on the other channel.  The other channel's
chan_pjsip_session_end() function will get called last.  Unfortunately,
the other channel's HangupRequest events are sent before chan_pjsip has had a
chance to set the tech hangupcause code so the HangupRequest events for that
channel won't have the cause code set.  The ChannelDestroyed and Hangup
events however will have the code set for both channels.

* A new "tech_cause" field was added to the ast_channel_snapshot_hangup
structure. This is a public structure so a bit of refactoring was needed to
preserve ABI compatibility.

* The ARI ChannelHangupRequest and ChannelDestroyed events were modified to
include the "tech_cause" parameter in the JSON for off-nominal terminations.
The parameter is suppressed for nominal termination.

* The AMI SoftHangupRequest, HangupRequest and Hangup events were modified to
include the "TechCause" parameter for off-nominal terminations. Like their ARI
counterparts, the parameter is suppressed for nominal termination.

DeveloperNote: A "tech_cause" parameter has been added to the
ChannelHangupRequest and ChannelDestroyed ARI event messages and a "TechCause"
parameter has been added to the HangupRequest, SoftHangupRequest and Hangup
AMI event messages.  For chan_pjsip, these will be set to the last SIP
response status code for off-nominally terminated calls.  The parameter is
suppressed for nominal termination.
2025-10-20 13:19:18 +00:00
Sven Kube
cb5b22db1f res_audiosocket: add message types for all slin sample rates
Extend audiosocket messages with types 0x11 - 0x18 to create asterisk
frames in slin12, slin16, slin24, slin32, slin44, slin48, slin96, and
slin192 format, enabling the transmission of audio at a higher sample
rates. For audiosocket messages sent by Asterisk, the message kind is
determined by the format of the originating asterisk frame.

UpgradeNote: New audiosocket message types 0x11 - 0x18 has been added
for slin12, slin16, slin24, slin32, slin44, slin48, slin96, and
slin192 audio. External applications using audiosocket may need to be
updated to support these message types if the audiosocket channel is
created with one of these audio formats.
2025-10-17 13:05:26 +00:00
phoneben
7cc1eb3036 res_fax.c: lower FAXOPT read warning to debug level
Reading ${FAXOPT()} before a fax session is common in dialplans to check fax state.
Currently this logs an error even when no fax datastore exists, creating excessive noise.
Change these messages to ast_debug(3, …) so they appear only with debug enabled.

Resolves: #1509
2025-10-14 21:35:06 +00:00
Joshua C. Colp
7477d120fd endpoints: Remove need for stasis subscription.
When an endpoint is created in the core of Asterisk a subscription
was previously created alongside it to monitor any channels being
destroyed that were related to it. This was done by receiving all
channel snapshot updates for every channel and only reacting when
it was indicated that the channel was dead.

This change removes this logic and instead provides an API call
for directly removing a channel from an endpoint. This is called
when channels are destroyed. This operation is fast, so blocking
the calling thread for a short period of time doesn't have any
noticeable impact.
2025-10-14 20:01:56 +00:00
Joshua C. Colp
6944a7d2d7 app_queue: Allow stasis message filtering to work.
The app_queue module subscribes on a per-dialed agent basis to both
the bridge all and channel all topics to keep apprised of things going
on involving them. This subscription has associated state that must
be cleaned up when the subscription ends. This was done by setting
a default router callback that only had logic to handle the case
where the subscription ends. By using the default router callback
all filtering for the subscription was disabled, causing unrelated
messages to get published and handled by it.

This change makes it so that an explicit route is added for the
message type used for the message indicating the subscription has
ended and removes the default router callback. This allows message
filtering to occur on publishing reducing the messages to app_queue
to only those it is interested in.
2025-10-14 19:55:40 +00:00
George Joseph
30c79b817d taskpool: Fix some references to threadpool that should be taskpool.
Resolves: #1478
2025-10-13 15:34:12 +00:00
Anthony Minessale
9a8ba88d31 Update contact information for anthm 2025-10-13 15:07:23 +00:00
George Joseph
54bd620fb1 chan_websocket.c: Change payload references to command instead.
Some of the tests in process_text_message() were still comparing to the
websocket message payload instead of the "command" string.

Resolves: #1525
2025-10-08 15:54:50 +00:00
Naveen Albert
2d0ed083ed func_callerid: Document limitation of DNID fields.
The Dial() application does not propagate DNID fields, which is counter
to the behavior of the other Caller ID fields. This behavior is likely
intentional since the use of Dial theoretically suggests a new dialed
number, but document this caveat to inform users of it.

Resolves: #1519
2025-10-07 18:23:14 +00:00
Naveen Albert
af3da2cfd7 func_channel: Allow R/W of ADSI CPE capability setting.
Allow retrieving and setting the channel's ADSI capability from the
dialplan.

Resolves: #1514

UserNote: CHANNEL(adsicpe) can now be read or written to change
the channels' ADSI CPE capability setting.
2025-10-07 18:22:24 +00:00
Naveen Albert
6e1b25d9ec core_unreal: Preserve ADSI capability when dialing Local channels.
Dial() already preserves the ADSI capability by copying it to the new
channel, but since Local channel pairs consist of two channels, we
also need to copy the capability to the second channel.

Resolves: #1517
2025-10-07 18:19:02 +00:00
Igor Goncharovsky
4f45f21b71 func_hangupcause.c: Add access to Reason headers via HANGUPCAUSE()
As soon as SIP call may end with several Reason headers, we
want to make all of them available through the HAGUPCAUSE() function.
This implementation uses the same ao2 hash for cause codes storage
and adds a flag to make difference between last processed sip
message and content of reason headers.

UserNote: Added a new option to HANGUPCAUSE to access additional
information about hangup reason. Reason headers from pjsip
could be read using 'tech_extended' cause type.
2025-10-07 15:26:56 +00:00
Naveen Albert
129f90e3db sig_analog: Allow '#' to end the inter-digit timeout when dialing.
It is customary to allow # to terminate digit collection immediately
when there would normally be a timeout. However, currently, users are
forced to wait for the timeout to expire when dialing numbers that
are prefixes of other valid matches, and there is no way to end the
timeout early. Customarily, # terminates the timeout, but at the moment,
this is just rejected unless there happens to be a matching extension
ending in #.

Allow # to terminate the timeout in cases where there is no dialplan
match. This ensures that the dialplan is always respected, but if a
valid extension has been dialed that happens to prefix other valid
matches, # can be used to dial it immediately.

Resolves: #1510
2025-10-07 15:16:21 +00:00
Naveen Albert
f3eec24088 func_math: Add DIGIT_SUM function.
Add a function (DIGIT_SUM) which returns the digit sum of a number.

Resolves: #1499

UserNote: The DIGIT_SUM function can be used to return the digit sum of
a number.
2025-10-06 19:26:10 +00:00
Naveen Albert
f647f9dad9 app_sf: Add post-digit timer option to ReceiveSF.
Add a sorely needed option to set a timeout between digits, rather than
for receiving the entire number. This is needed if the number of digits
being sent is unknown by the receiver in advance. Previously, we had
to wait for the entire timer to expire.

Resolves: #1493

UserNote: The 't' option for ReceiveSF now allows for a timer since
the last digit received, in addition to the number-wide timeout.
2025-10-06 19:24:52 +00:00
Naveen Albert
5201adcac9 codec_builtin.c: Adjust some of the quality scores to reflect reality.
Among the lower-quality voice codecs, some of the quality scores did
not make sense relative to each other.

For instance, quality-wise, G.729 > G.723 > PLC10.
However, current scores do not uphold these relationships.

Tweak the scores slightly to reflect more accurate relationships.

Resolves: #1501
2025-10-06 15:46:25 +00:00
Naveen Albert
3269c41f61 res_tonedetect: Fix formatting of XML documentation.
Fix the indentation in the documentation for the variable list.

Resolves: #1507
2025-10-06 15:41:17 +00:00
Naveen Albert
969f282688 res_fax: Add XML documentation for channel variables.
Document the channel variables currently set by SendFAX and ReceiveFAX.

Resolves: #1505
2025-10-06 15:38:55 +00:00
George Joseph
50d2339d70 channelstorage_cpp_map_name_id: Add read locking around retrievals.
When we retrieve a channel from a C++ map, we actually get back a wrapper
object that points to the channel then right after we retrieve it, we bump its
reference count.  There's a tiny chance however that between those two
statements a delete and/or unref might happen which would cause the wrapper
object or the channel itself to become invalid resulting in a SEGV.  To avoid
this we now perform a read lock on the driver around those statements.

Resolves: #1491
2025-10-06 13:50:23 +00:00
Naveen Albert
d8bc249f2e app_dial: Allow fractional seconds for dial timeouts.
Even though Dial() internally uses milliseconds for its dial timeouts,
this capability has been mostly obscured from users as the argument is
only parsed as an integer, thus forcing the use of whole seconds for
timeouts.

Parse it as a decimal instead so that timeouts can now truly have
millisecond precision.

Resolves: #1487

UserNote: The answer and progress dial timeouts now have millisecond
precision, instead of having to be whole numbers.
2025-10-02 16:02:42 +00:00
Naveen Albert
0bf9396aa9 dsp.c: Make minor fixes to debug log messages.
Commit dc8e3eeaaf improved the debug log
messages in dsp.c. This makes two minor corrections to it:

* Properly guard an added log statement in a conditional.
* Don't add one to the hit count if there was no hit (however, we do
  still want to do this for the case where this is one).

Resolves: #1496
2025-10-02 14:44:39 +00:00
Naveen Albert
ed87db3d6b config_options.c: Improve misleading warning.
When running "config show help <module>", if no XML documentation exists
for the specified module, "Module <module> not found." is returned,
which is misleading if the module is loaded but simply has no XML
documentation for its config. Improve the message to clarify that the
module may simply have no config documentation.

Resolves: #1489
2025-10-02 14:43:01 +00:00
Naveen Albert
e92b068e94 func_scramble: Add example to XML documentation.
The previous lack of an example made it ambiguous if the arguments went
inside the function arguments or were part of the right-hand value.

Resolves: #1485
2025-09-30 15:09:37 +00:00
Naveen Albert
f86812d4f0 sig_analog: Eliminate potential timeout with Last Number Redial.
If Last Number Redial is used to redial, ensure that we do not wait
for further digits. This was possible if the number that was last
dialed is a prefix of another possible dialplan match. Since all we
did is copy the number into the extension buffer, if other matches
are now possible, there would thus be a timeout before the call went
through. We now complete redialed calls immediaetly in all cases.

Resolves: #1483
2025-09-30 15:09:06 +00:00
George Joseph
ebd9e80f21 ARI: The bridges play and record APIs now handle sample rates > 8K correctly.
The bridge play and record APIs were forcing the Announcer/Recorder channel
to slin8 which meant that if you played or recorded audio with a sample
rate > 8K, it was downsampled to 8K limiting the bandwidth.

* The /bridges/play REST APIs have a new "announcer_format" parameter that
  allows the caller to explicitly set the format on the "Announcer" channel
  through which the audio is played into the bridge.  If not specified, the
  default depends on how many channels are currently in the bridge.  If
  a single channel is in the bridge, then the Announcer channel's format
  will be set to the same as that channel's.  If multiple channels are in the
  bridge, the channels will be scanned to find the one with the highest
  sample rate and the Announcer channel's format will be set to the slin
  format that has an equal to or greater than sample rate.

* The /bridges/record REST API has a new "recorder_format" parameter that
  allows the caller to explicitly set the format on the "Recorder" channel
  from which audio is retrieved to write to the file.  If not specified,
  the Recorder channel's format will be set to the format that was requested
  to save the audio in.

Resolves: #1479

DeveloperNote: The ARI /bridges/play and /bridges/record REST APIs have new
parameters that allow the caller to specify the format to be used on the
"Announcer" and "Recorder" channels respecitvely.
2025-09-30 13:59:26 +00:00
Max Grobecker
78f2524749 res_pjsip_geolocation: Add support for Geolocation loc-src parameter
This adds support for the Geolocation 'loc-src' parameter to res_pjsip_geolocation.
The already existing config option 'location_source` in res_geolocation is documented to add a 'loc-src' parameter containing a user-defined FQDN to the 'Geolocation:' header,
but that option had no effect as it was not implemented by res_pjsip_geolocation.

If the `location_source` configuration option is not set or invalid, that parameter will not be added (this is already checked by res_geolocation).

This commits adds already documented functionality.
2025-09-30 13:53:36 +00:00
Joshua C. Colp
60c5010e38 sorcery: Move from threadpool to taskpool.
This change moves observer invocation from the use of
a threadpool to a taskpool. The taskpool options have also
been adjusted to ensure that at least one taskprocessor
remains available at all times.
2025-09-30 13:50:29 +00:00
Sven Kube
59ab02f078 stasis_channels.c: Make protocol_id optional to enable blind transfer via ari
When handling SIP transfers via ARI, there is no protocol_id in case of
a blind transfer.

Resolves: #1467
2025-09-23 19:49:56 +00:00
George Joseph
6c62e30267 res_rtp_asterisk.c: Use rtp->dtls in __rtp_sendto when rtcp mux is used.
In __rtp_sendto(), the check for DTLS negotiation completion for rtcp packets
needs to use the rtp->dtls structure instead of rtp->rtcp->dtls when
AST_RTP_INSTANCE_RTCP_MUX is set.

Resolves: #1474
2025-09-23 15:41:44 +00:00
Bastian Triller
f68cfae069 Fix some doxygen, typos and whitespace 2025-09-22 17:39:17 +00:00
Sven Kube
bd156f5f66 stasis_channels.c: Add null check for referred_by in ast_ari_transfer_message_create
When handling SIP transfers via ARI, the `referred_by` field in
`transfer_ari_state` may be null, since SIP REFER requests are not
required to include a `Referred-By` header. Without this check, a null
value caused the transfer to fail and triggered a NOTIFY with a 500
Internal Server Error.
2025-09-22 17:26:42 +00:00
George Joseph
8b68c9554d chan_websocket: Fix codec validation and add passthrough option.
* Fixed an issue in webchan_write() where we weren't detecting equivalent
  codecs properly.
* Added the "p" dialstring option that puts the channel driver in
  "passthrough" mode where it will not attempt to re-frame or re-time
  media coming in over the websocket from the remote app.  This can be used
  for any codec but MUST be used for codecs that use packet headers or whose
  data stream can't be broken up on arbitrary byte boundaries. In this case,
  the remote app is fully responsible for correctly framing and timing media
  sent to Asterisk and the MEDIA text commands that could be sent over the
  websocket are disabled.  Currently, passthrough mode is automatically set
  for the opus, speex and g729 codecs.
* Now calling ast_set_read_format() after ast_channel_set_rawreadformat() to
  ensure proper translation paths are set up when switching between native
  frames and slin silence frames.  This fixes an issue with codec errors
  when transcode_via_sln=yes.

Resolves: #1462
2025-09-22 17:21:34 +00:00
phoneben
edcd4d0411 app_queue: Add NULL pointer checks in app_queue
Add NULL check for word_list before calling word_in_list()
Add NULL checks for channel snapshots from ast_multi_channel_blob_get_channel()

Resolves: #1425
2025-09-22 17:19:15 +00:00
Sean Bright
c88febe23a app_externalivr: Prevent out-of-bounds read during argument processing.
Resolves: #1422
2025-09-22 16:55:43 +00:00
Naveen Albert
131a6730b2 chan_dahdi: Add DAHDI_CHANNEL function.
Add a dialplan function that can be used to get/set properties of
DAHDI channels (as opposed to Asterisk channels). This exposes
properties that were not previously available, allowing for certain
operations to now be performed in the dialplan.

Resolves: #1455

UserNote: The DAHDI_CHANNEL function allows for getting/setting
certain properties about DAHDI channels from the dialplan.
2025-09-22 16:52:26 +00:00
Joshua C. Colp
8adbad81f7 taskpool: Update versions for taskpool stasis options. 2025-09-17 01:24:58 +00:00
Joshua C. Colp
823727501d taskpool: Add taskpool API, switch Stasis to using it.
This change introduces a new API called taskpool. This is a pool
of taskprocessors. It provides the following functionality:

1. Task pushing to a pool of taskprocessors
2. Synchronous tasks
3. Serializers for execution ordering of tasks
4. Growing/shrinking of number of taskprocessors in pool

This functionality already exists through the combination of
threadpool+taskprocessors but through investigating I determined
that this carries substantial overhead for short to medium duration
tasks. The threadpool uses a single queue of work, and for management
of threads it involves additional tasks.

I wrote taskpool to eliminate the extra overhead and management
as much as possible. Instead of a single queue of work each
taskprocessor has its own queue and at push time a selector chooses
the taskprocessor to queue the task to. Each taskprocessor also
has its own thread like normal. This spreads out the tasks immediately
and reduces contention on shared resources.

Using the included efficiency tests the number of tasks that can be
executed per second in a taskpool is 6-12 times more than an equivalent
threadpool+taskprocessor setup.

Stasis has been moved over to using this new API as it is a heavy consumer
of threadpool+taskprocessors and produces a lot of tasks.

UpgradeNote: The threadpool_* options in stasis.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 stasis.

DeveloperNote: The taskpool API has been added for common usage of a
pool of taskprocessors. It is suggested to use this API instead of the
threadpool+taskprocessor approach.
2025-09-16 17:21:23 +00:00
George Joseph
d5504509d4 res_ari: Ensure outbound websocket config has a websocket_client_id.
Added a check to outbound_websocket_apply() that makes sure an outbound
websocket config object in ari.conf has a websocket_client_id parameter.

Resolves: #1457
2025-09-15 13:28:13 +00:00
Naveen Albert
33ec85c3fd app_adsiprog: Fix possible NULL dereference.
get_token can return NULL, but process_token uses this result without
checking for NULL; as elsewhere, check for a NULL result to avoid
possible NULL dereference.

Resolves: #1419
2025-09-11 15:25:34 +00:00
Nathan Monfils
cefef8eacb manager.c: Fix presencestate object leak
ast_presence_state allocates subtype and message. We straightforwardly
need to clean those up.
2025-09-11 15:24:00 +00:00
Sean Bright
a7520dcf26 audiohook.c: Ensure correct AO2 reference is dereffed.
Part of #1440.
2025-09-11 14:47:32 +00:00
Naveen Albert
da58209f75 res_cliexec: Remove unnecessary casts to char*.
Resolves: #1436
2025-09-11 14:19:39 +00:00
Ben Ford
c0f3e46803 rtp_engine.c: Add exception for comfort noise payload.
In a previous commit, a change was made to
ast_rtp_codecs_payload_code_tx_sample_rate to check for differing sample
rates. This ended up returning an invalid payload int for comfort noise.
A check has been added that returns early if the payload is in fact
supposed to be comfort noise.

Fixes: #1340
2025-09-11 14:08:00 +00:00
Naveen Albert
0c04c8d212 pbx_variables.c: Create real channel for "dialplan eval function".
"dialplan eval function" has been using a dummy channel for function
evaluation, much like many of the unit tests. However, sometimes, this
can cause issues for functions that are not expecting dummy channels.
As an example, ast_channel_tech(chan) is NULL on such channels, and
ast_channel_tech(chan)->type consequently results in a NULL dereference.
Normally, functions do not worry about this since channels executing
dialplan aren't dummy channels.

While some functions are better about checking for these sorts of edge
cases, use a real channel with a dummy technology to make this CLI
command inherently safe for any dialplan function that could be evaluated
from the CLI.

Resolves: #1434
2025-09-11 12:31:35 +00:00
Joe Garlick
2de6dc5d7a chan_websocket.c: Add DTMF messages
Added DTMF messages to the chan_websocket feature.

When a user presses DTMF during a call over chan_websocket it will send a message like:
"DTMF_END digit:1"

Resolves: https://github.com/asterisk/asterisk-feature-requests/issues/70
2025-09-08 14:33:56 +00:00
Igor Goncharovsky
63868245c0 app_queue.c: Add new global 'log_unpause_on_reason_change'
In many asterisk-based systems, the pause reason is used to separate
pauses by type,and logically, changing the reason defines two intervals
that should be accounted for separately. The introduction of a new
option allows me to separate the intervals of operator inactivity in
the log by the event of unpausing.

UserNote: Add new global option 'log_unpause_on_reason_change' that
is default disabled. When enabled cause addition of UNPAUSE event on
every re-PAUSE with reason changed.
2025-09-08 14:28:45 +00:00
Igor Goncharovsky
a8afc93ebe app_waitforsilence.c: Use milliseconds to calculate timeout time
The functions WaitForNoise() and WaitForSilence() use the time()
functions to calculate elapsed time, which causes the timer to fire on
a whole second boundary, and the actual function execution time to fire
the timer may be 1 second less than expected. This fix replaces time()
with ast_tvnow().

Fixes: #1401
2025-09-08 14:27:24 +00:00
Artem Umerov
9bc1fc1f2f Fix missing ast_test_flag64 in extconf.c
Fix missing ast_test_flag64 after 43bf8a4ded
2025-09-04 15:10:22 +00:00
Naveen Albert
fc2294308e pbx_builtins: Allow custom tone for WaitExten.
Currently, the 'd' option will play dial tone while waiting
for digits. Allow it to accept an argument for any tone from
indications.conf.

Resolves: #1396

UserNote: The tone used while waiting for digits in WaitExten
can now be overridden by specifying an argument for the 'd'
option.
2025-09-04 15:03:39 +00:00
Naveen Albert
016a53beba res_tonedetect: Add option for TONE_DETECT detection to auto stop.
One of the problems with TONE_DETECT as it was originally written
is that if a tone is detected multiple times, it can trigger
the redirect logic multiple times as well. For example, if we
do an async goto in the dialplan after detecting a tone, because
the detector is still active until explicitly disabled, if we
detect the tone again, we will branch again and start executing
that dialplan a second time. This is rarely ever desired behavior,
and can happen if the detector is not removed quickly enough.

Add a new option, 'e', which automatically disables the detector
once the desired number of matches have been heard. This eliminates
the potential race condition where previously the detector would
need to be disabled immediately, but doing so quickly enough
was not guaranteed. This also allows match criteria to be retained
longer if needed, so the detector does not need to be destroyed
prematurely.

Resolves: #1390

UserNote: The 'e' option for TONE_DETECT now allows detection to
be disabled automatically once the desired number of matches have
been fulfilled, which can help prevent race conditions in the
dialplan, since TONE_DETECT does not need to be disabled after
a hit.
2025-09-03 14:23:40 +00:00