]> git.ipfire.org Git - thirdparty/asterisk.git/log
thirdparty/asterisk.git
3 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().

(cherry picked from commit f8bc3ddeb9ddac220847bb2e0143fadfb3f80911)

3 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.

(cherry picked from commit bff3fd0fa8b35057e25fd56cb0070d5e80c118c1)

3 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
(cherry picked from commit 6881b6249f43585f8ed1f047b8a8f0a3922394db)

3 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
(cherry picked from commit bcd0e53ef698bd5131ceb8423e0ed4fb0ea41405)

3 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.

(cherry picked from commit 7457d7d215a1496ffd4dcf8a347d0db850330a5b)

3 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.

(cherry picked from commit ade69af6d9ea753e7fb85d964fbedeeff0369e04)

3 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
(cherry picked from commit 8bae6a1d8c8c609168071b68108353bfd537fa80)

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.

(cherry picked from commit 62e73f9bd8d50598ff9a71350ab01f20c988aaf7)

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/

(cherry picked from commit 6bc055416bab24e1b27d9e2d2ff8dfc529ebfafd)

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
(cherry picked from commit ca8adc245422b26c489456b82c6b3a9fdcf74e4d)

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,*,#...).

(cherry picked from commit ea657ec7c7f14995e346a9f263627d89754aac52)

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>
(cherry picked from commit 1c1515fc214a24da3ea602b9b0482468c4729fe2)

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>
(cherry picked from commit e8209bf56b0f20f1df48e797a6fb40f47d922c13)

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
(cherry picked from commit abc8c5c93af939cda304d1fbb47f40db92e68c0a)

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

(cherry picked from commit d6bd26573c98985e2bb26a463f195270f0d56cd7)

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
(cherry picked from commit 03cf8c62ad40531454ac6acd3feafa505ac6bff2)

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
(cherry picked from commit f24729a48d9a63b5fa4b2966b92551c16900f1a8)

4 months agoUpdate for 21.8.0 21.8.0
Asterisk Development Team [Thu, 27 Mar 2025 12:49:43 +0000 (12:49 +0000)] 
Update for 21.8.0

4 months agoUpdate for 21.8.0-rc1 21.8.0-rc1
Asterisk Development Team [Thu, 20 Mar 2025 18:29:26 +0000 (18:29 +0000)] 
Update for 21.8.0-rc1

4 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.

(cherry picked from commit 6921ede7cbcd68046e9f3efe3085ef53f1573fa0)

4 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
(cherry picked from commit bae7dafa1267ca3baf4f2680d4aad1cf9709b3c9)

4 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
(cherry picked from commit 2d57b52e3ddf450307a625dad210e238d1dfa9b3)

4 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

(cherry picked from commit 3a9d7438e05695cb29e169df773f5d3a6debd517)

4 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
(cherry picked from commit c4123901e5c13ab8c4b010bce9e274ceda695850)

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.

(cherry picked from commit f685df5d14674dcfc65a3371cddb18c1fb35edb7)

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
(cherry picked from commit 79458d70ebe96ea2a1f20a52d206515a4ffe6574)

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
(cherry picked from commit 6f447132b23a3f94d9b66f47a850f98d01fc18dc)

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.

(cherry picked from commit f80e2405e64c32898380230c5f5bf38c168814e5)

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.
(cherry picked from commit a47fe8f84f89a3e2fdf125002c090034dccb5d59)

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

(cherry picked from commit 4dc2efc8c32bd15a7eb5d64c75bcedc207bac88b)

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

(cherry picked from commit 16f48f504ed3fceca3fe1d0c260f36bf9492cd31)

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`

(cherry picked from commit 44a27dc13f78537c21cf8593f8fad209fd4e5a11)

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`

(cherry picked from commit 03ec0f2d17d6b572353f1c09b1bc31e3e8e63227)

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
(cherry picked from commit 46c9f7db8e6f529c242d2f8f43294743b8777258)

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`.

(cherry picked from commit 1a7c9e0a041bf14978a1a4659a4bd18be51c66a5)

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
(cherry picked from commit 4a563b6b8d0357202762610642e827db7c21a282)

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

(cherry picked from commit a935133eebd58d7725c3519c87c9f46d1e9d6dec)

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.

(cherry picked from commit e8399bcc537680871a8134c1a2386db0917b83bd)

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

(cherry picked from commit 9822f6fd25d2bc102ed46381d8e89330cf941e7e)

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
(cherry picked from commit 89764215049dc2f8e883b43e70043573fcbe6ed2)

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
(cherry picked from commit 71551013c413189179cc481861c3789c169d107f)

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
(cherry picked from commit 5267c176452e26af81a208e076e2150df1a8537c)

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.

(cherry picked from commit 71eb8a262f53f0a417991232ecff0eb67a3bca6a)

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. :(

(cherry picked from commit 896a488cd569651a41070984524bab64d99b413b)

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.

(cherry picked from commit 2cc2710e5f171cad57a7b5685662ba7545e6da02)

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.

(cherry picked from commit e09b4dd97f6ebb143089d972d14da7f058a50f6d)

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.

(cherry picked from commit 478fbbb8289e1ffa13967bcc7ead10219df45297)

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

(cherry picked from commit 83fe05ea202204666ed27beff35b18d76629f77a)

4 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
(cherry picked from commit f5e066a48b8dade79dab87bb8e2940a818ec1894)

4 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.

(cherry picked from commit f1df1cacf6367310bf3a44788704159968156bd0)

4 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`.

(cherry picked from commit 16bfde8b9b40fe26eedd69ced4066f1520807a9c)

4 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
(cherry picked from commit a78ec5e7bf061ffb20be154eaf2208d2a59dce7d)

4 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.

(cherry picked from commit c22837543190eb23fd8655695fc93f8d311642a3)

4 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.

(cherry picked from commit a84d4cd0b4b154c779a163c27ff70638f2aeb4f4)

4 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).

(cherry picked from commit b4156fecf02ac427a91eb9f6bd49e98b8d6f4fb2)

5 months agoUpdate for 21.7.0 21.7.0
Asterisk Development Team [Thu, 6 Feb 2025 16:50:44 +0000 (16:50 +0000)] 
Update for 21.7.0

6 months agoUpdate for 21.7.0-rc2 21.7.0-rc2
Asterisk Development Team [Thu, 30 Jan 2025 16:24:56 +0000 (16:24 +0000)] 
Update for 21.7.0-rc2

6 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

6 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.

6 months agores_pjsip: Fix startup/reload memory leak in config_auth.
George Joseph [Thu, 23 Jan 2025 21:02:25 +0000 (14:02 -0700)] 
res_pjsip: Fix startup/reload memory leak in config_auth.

An issue in config_auth.c:ast_sip_auth_digest_algorithms_vector_init() was
causing double allocations for the two supported_algorithms vectors to the
tune of 915 bytes.  The leak only happens on startup and when a reload is done
and doesn't get bigger with the number of auth objects defined.

* Pre-initialized the two vectors in config_auth:auth_alloc().
* Removed the allocations in ast_sip_auth_digest_algorithms_vector_init().
* Added a note to the doc for ast_sip_auth_digest_algorithms_vector_init()
  noting that the vector passed in should be initialized and empty.
* Simplified the create_artificial_auth() function in pjsip_distributor.
* Set the vector initialization count to 0 in config_global:global_apply().

6 months agoUpdate for 21.7.0-rc1 21.7.0-rc1
Asterisk Development Team [Thu, 23 Jan 2025 18:39:45 +0000 (18:39 +0000)] 
Update for 21.7.0-rc1

6 months agodocs: Add version information to application and function XML elements
George Joseph [Thu, 23 Jan 2025 16:27:32 +0000 (09:27 -0700)] 
docs: Add version information to application and function XML elements

* Do a git blame on the embedded XML application or function element.

* From the commit hash, grab the summary line.

* Do a git log --grep <summary> to find the cherry-pick commits in all
  branches that match.

* Do a git patch-id to ensure the commits are all related and didn't get
  a false match on the summary.

* Do a git tag --contains <commit> to find the tags that contain each
  commit.

* Weed out all tags not ..0.

* Sort and discard any .0.0 and following tags where the commit
  appeared in an earlier branch.

* The result is a single tag for each branch where the application or function
  was defined.

The applications and functions defined in the following files were done by
hand because the XML was extracted from the C source file relatively recently.
* channels/pjsip/dialplan_functions_doc.xml
* main/logger_doc.xml
* main/manager_doc.xml
* res/res_geolocation/geoloc_doc.xml
* res/res_stir_shaken/stir_shaken_doc.xml

(cherry picked from commit 85a4ab83901ede3aad6d6232ce110b18e3c06aa7)

6 months agodocs: Add version information to manager event instance XML elements
George Joseph [Mon, 20 Jan 2025 18:33:20 +0000 (11:33 -0700)] 
docs: Add version information to manager event instance XML elements

* Do a git blame on the embedded XML managerEvent elements.

* From the commit hash, grab the summary line.

* Do a git log --grep <summary> to find the cherry-pick commits in all
  branches that match.

* Do a git patch-id to ensure the commits are all related and didn't get
  a false match on the summary.

* Do a git tag --contains <commit> to find the tags that contain each
  commit.

* Weed out all tags not ..0.

* Sort and discard any .0.0 and following tags where the commit
  appeared in an earlier branch.

* The result is a single tag for each branch where the application or function
  was defined.

The events defined in res/res_pjsip/pjsip_manager.xml were done by hand
because the XML was extracted from the C source file relatively recently.

Two bugs were fixed along the way...

* The get_documentation awk script was exiting after it processed the first
  DOCUMENTATION block it found in a file.  We have at least 1 source file
  with multiple DOCUMENTATION blocks so only the first one in them was being
  processed.  The awk script was changed to continue searching rather
  than exiting after the first block.

* Fixing the awk script revealed an issue in logger.c where the third
  DOCUMENTATION block contained a XML fragment that consisted only of
  a managerEventInstance element that wasn't wrapped in a managerEvent
  element.  Since logger_doc.xml already existed, the remaining fragments
  in logger.c were moved to it and properly organized.

(cherry picked from commit a47b8e2d4025cbf102c976fcd6df5aa3a51e5fc4)

6 months agoLICENSE: Update company name, email, and address.
Joshua C. Colp [Tue, 21 Jan 2025 22:22:46 +0000 (18:22 -0400)] 
LICENSE: Update company name, email, and address.

(cherry picked from commit ac559b236d7805282dba8bc8e55f210628f87b61)

6 months agores_prometheus.c: Set Content-Type header on /metrics response.
Sean Bright [Tue, 21 Jan 2025 23:37:54 +0000 (18:37 -0500)] 
res_prometheus.c: Set Content-Type header on /metrics response.

This should resolve the Prometheus error:

> Error scraping target: non-compliant scrape target
  sending blank Content-Type and no
  fallback_scrape_protocol specified for target.

Resolves: #1075
(cherry picked from commit fa286641fb39b8aedab19127996d2c13afdb45b7)

6 months agoREADME.md, asterisk.c: Update Copyright Dates
George Joseph [Mon, 20 Jan 2025 19:58:18 +0000 (12:58 -0700)] 
README.md, asterisk.c: Update Copyright Dates

(cherry picked from commit ece2cfc7c182113b5b55415a0203cb8c69634162)

6 months agodocs: Add version information to configObject and configOption XML elements
George Joseph [Thu, 16 Jan 2025 21:54:35 +0000 (14:54 -0700)] 
docs: Add version information to configObject and configOption XML elements

Most of the configObjects and configOptions that are implemented with
ACO or Sorcery now have `<since>/<version>` elements added.  There are
probably some that the script I used didn't catch.  The version tags were
determined by the following...
 * Do a git blame on the API call that created the object or option.
 * From the commit hash, grab the summary line.
 * Do a `git log --grep <summary>` to find the cherry-pick commits in all
   branches that match.
 * Do a `git patch-id` to ensure the commits are all related and didn't get
   a false match on the summary.
 * Do a `git tag --contains <commit>` to find the tags that contain each
   commit.
 * Weed out all tags not <major>.<minor>.0.
 * Sort and discard any <major>.0.0 and following tags where the commit
   appeared in an earlier branch.
 * The result is a single tag for each branch where the API was last touched.

configObjects and configOptions elements implemented with the base
ast_config APIs were just not possible to find due to the non-deterministic
way they are accessed.

Also note that if the API call was on modified after it was added, the
version will be the one it was last modified in.

Final note:  The configObject and configOption elements were introduced in
12.0.0 so options created before then may not have any XML documentation.

(cherry picked from commit a22dc33057fdde04f313feb1d27a3a143de1b738)

6 months agores_pjsip_authenticator_digest: Fix issue with missing auth and DONT_OPTIMIZE
George Joseph [Fri, 17 Jan 2025 16:20:16 +0000 (09:20 -0700)] 
res_pjsip_authenticator_digest: Fix issue with missing auth and DONT_OPTIMIZE

The return code fom digest_check_auth wasn't explicitly being initialized.
The return code also wasn't explicitly set to CHALLENGE when challenges
were sent.  When optimization was turned off (DONT_OPTIMIZE), the compiler
was setting it to "0"(CHALLENGE) which worked fine.  However, with
optimization turned on, it was setting it to "1" (SUCCESS) so if there was
no incoming Authorization header, the function was returning SUCCESS to the
distributor allowing the request to incorrectly succeed.

The return code is now initialized correctly and is now explicitly set
to CHALLENGE when we send challenges.

(cherry picked from commit 317b830c1ea646ab0f875ee11117be0c31ca8441)

6 months agoast_tls_cert: Add option to skip passphrase for CA private key.
Naveen Albert [Tue, 14 Jan 2025 22:49:53 +0000 (17:49 -0500)] 
ast_tls_cert: Add option to skip passphrase for CA private key.

Currently, the ast_tls_cert file is hardcoded to use the -des3 option
for 3DES encryption, and the script needs to be manually modified
to not require a passphrase. Add an option (-e) that disables
encryption of the CA private key so no passphrase is required.

Resolves: #1064
(cherry picked from commit 5438d28bcd3d8229bed7f53b53ff3b7a35f33894)

6 months agochan_iax2: Avoid unnecessarily backlogging non-voice frames.
Naveen Albert [Fri, 10 Jan 2025 01:49:14 +0000 (20:49 -0500)] 
chan_iax2: Avoid unnecessarily backlogging non-voice frames.

Currently, when receiving an unauthenticated call, we keep track
of the negotiated format in the chosenformat, which allows us
to later create the channel using the right format. However,
this was not done for authenticated calls. This meant that in
certain circumstances, if we had not yet received a voice frame
from the peer, only certain other types of frames (e.g. text),
there were no variables containing the appropriate frame.
This led to problems in the jitterbuffer callback where we
unnecessarily bailed out of retrieving a frame from the jitterbuffer.
This was logic intentionally added in commit 73103bdcd5b342ce5dfa32039333ffadad551151
in response to an earlier regression, and while this prevents
crashes, it also backlogs legitimate frames unnecessarily.

The abort logic was initially added because at this point in the
code, we did not have the negotiated format available to us.
However, it should always be available to us as a last resort
in chosenformat, so we now pull it from there if needed. This
allows us to process frames the jitterbuffer even if voicefmt
and peerfmt aren't set and still avoid the crash. The failsafe
logic is retained, but now it shouldn't be triggered anymore.

Resolves: #1054
(cherry picked from commit ea3ac94bbfa0dea90b9516713140349a8a95c8c3)

6 months agoconfig.c: fix #tryinclude being converted to #include on rewrite
Allan Nathanson [Mon, 16 Sep 2024 18:58:59 +0000 (14:58 -0400)] 
config.c: fix #tryinclude being converted to #include on rewrite

Correct an issue in ast_config_text_file_save2() when updating configuration
files with "#tryinclude" statements. The API currently replaces "#tryinclude"
with "#include". The API also creates empty template files if the referenced
files do not exist. This change resolves these problems.

Resolves: https://github.com/asterisk/asterisk/issues/920
(cherry picked from commit 5945703267603d9837f35ef2b726c3504733d929)

6 months agosig_analog: Add Last Number Redial feature.
Naveen Albert [Fri, 10 Nov 2023 13:30:33 +0000 (08:30 -0500)] 
sig_analog: Add Last Number Redial feature.

This adds the Last Number Redial feature to
simple switch.

UserNote: Users can now redial the last number
called if the lastnumredial setting is set to yes.

Resolves: #437
(cherry picked from commit 9ebe0e3d2f1251bfd06af521d15ab82e8f67b3dc)

6 months agodocs: Various XML fixes
George Joseph [Wed, 15 Jan 2025 23:19:27 +0000 (16:19 -0700)] 
docs: Various XML fixes

* channels/pjsip/dialplan_functions_doc.xml: Added xmlns:xi to docs element.

* main/bucket.c: Removed XML completely since the "bucket" and "file" objects
  are internal only with no config file.

* main/named_acl.c: Fixed the configFile element name. It was "named_acl.conf"
  and should have been "acl.conf"

* res/res_geolocation/geoloc_doc.xml: Added xmlns:xi to docs element.

* res/res_http_media_cache.c: Fixed the configFile element name. It was
  "http_media_cache.conf" and should have been "res_http_media_cache.conf".

(cherry picked from commit 3b53152624ff603fc82823ed8f152a1e38507824)

6 months agostrings.c: Improve numeric detection in `ast_strings_match()`.
Sean Bright [Wed, 15 Jan 2025 16:42:29 +0000 (11:42 -0500)] 
strings.c: Improve numeric detection in `ast_strings_match()`.

Essentially, we were treating 1234x1234 and 1234x5678 as 'equal'
because we were able to convert the prefix of each of these strings to
the same number.

Resolves: #1028
(cherry picked from commit 813b774cc1f917f0bf21b80269270e484018b0c0)

6 months agodocs: Enable since/version handling for XML, CLI and ARI documentation
George Joseph [Thu, 9 Jan 2025 22:17:14 +0000 (15:17 -0700)] 
docs: Enable since/version handling for XML, CLI and ARI documentation

* Added the "since" element to the XML configObject and configOption elements
  in appdocsxml.dtd.

* Added the "Since" section to the following CLI output:
  ```
  config show help <module> <object>
  config show help <module> <object> <option>
  core show application <app>
  core show function <func>
  manager show command <command>
  manager show event <event>
  agi show commands topic <topic>
  ```

* Refactored the commands above to output their sections in the same order:
  Synopsis, Since, Description, Syntax, Arguments, SeeAlso

* Refactored the commands above so they all use the same pattern for writing
  the output to the CLI.

* Fixed several memory leaks caused by failure to free temporary output
  buffers.

* Added a "since" array to the mustache template for the top-level resources
  (Channel, Endpoint, etc.) and to the paths/methods underneath them. These
  will be added to the generated markdown if present.
  Example:
  ```
    "resourcePath": "/api-docs/channels.{format}",
    "requiresModules": [
        "res_stasis_answer",
        "res_stasis_playback",
        "res_stasis_recording",
        "res_stasis_snoop"
    ],
    "since": [
        "18.0.0",
        "21.0.0"
    ],
    "apis": [
        {
            "path": "/channels",
            "description": "Active channels",
            "operations": [
                {
                    "httpMethod": "GET",
                    "since": [
                        "18.6.0",
                        "21.8.0"
                    ],
                    "summary": "List all active channels in Asterisk.",
                    "nickname": "list",
                    "responseClass": "List[Channel]"
                },

  ```

NOTE:  No versioning information is actually added in this commit.
Those will be added separately and instructions for adding and maintaining
them will be published on the documentation site at a later date.

(cherry picked from commit 3e28ddce7825776ca5443d8aab632a182ea7346d)

6 months agologger.h: Fix build when AST_DEVMODE is not defined.
Artem Umerov [Mon, 13 Jan 2025 16:28:45 +0000 (19:28 +0300)] 
logger.h: Fix build when AST_DEVMODE is not defined.

Resolves: #1058
(cherry picked from commit ee54dc56ee70cc7b059ca7162e804e4b291b4a42)

6 months agodialplan_functions_doc.xml: Document PJSIP_MEDIA_OFFER's `media` argument.
Sean Bright [Tue, 14 Jan 2025 16:45:15 +0000 (11:45 -0500)] 
dialplan_functions_doc.xml: Document PJSIP_MEDIA_OFFER's `media` argument.

Resolves: #1023
(cherry picked from commit f9f858b55e5aabdff74c020e3ad35c3b72f0d537)

6 months agosamples: Use "asterisk" instead of "postgres" for username
Abdelkader Boudih [Tue, 7 Jan 2025 20:17:56 +0000 (21:17 +0100)] 
samples: Use "asterisk" instead of "postgres" for username

(cherry picked from commit 34f089d4880a8226e3f221b44a7fffd11d524d68)

6 months agomanager: Add `<since>` tags for all AMI actions.
Sean Bright [Thu, 2 Jan 2025 19:38:30 +0000 (14:38 -0500)] 
manager: Add `<since>` tags for all AMI actions.

(cherry picked from commit 7f13966202daa99ce49214a1340988ea4daa6579)

6 months agologger.c fix: malformed JSON template
Steffen Arntz [Wed, 8 Jan 2025 16:57:54 +0000 (17:57 +0100)] 
logger.c fix: malformed JSON template

this typo was mentioned before, but never got fixed.
https://community.asterisk.org/t/logger-cannot-log-long-json-lines-properly/87618/6

(cherry picked from commit ffbe9bf31e187fb6ca7ccd9858584c59330acd34)

6 months agomanager.c: Rename restrictedFile to is_restricted_file.
Sean Bright [Thu, 9 Jan 2025 19:34:39 +0000 (14:34 -0500)] 
manager.c: Rename restrictedFile to is_restricted_file.

Also correct the spelling of 'privileges.'

(cherry picked from commit e7fc33f28292ca57a1fb2161bb22f7ed542fdc9b)

6 months agores_config_pgsql: normalize database connection option with cel and cdr by supporting...
Abdelkader Boudih [Wed, 8 Jan 2025 22:00:39 +0000 (23:00 +0100)] 
res_config_pgsql: normalize database connection option with cel and cdr by supporting new options name

(cherry picked from commit 1ea7d5cae6a577c37f0124d14f327914c3492137)

6 months agores_pjproject: Fix typo (OpenmSSL->OpenSSL)
Stanislav Abramenkov [Fri, 10 Jan 2025 17:12:41 +0000 (19:12 +0200)] 
res_pjproject: Fix typo (OpenmSSL->OpenSSL)

Fix typo (OpenmSSL->OpenSSL) mentioned by bkford in #972

(cherry picked from commit 385e2d504294606348ef816934ba926a1320f7fd)

6 months agoAdd SHA-256 and SHA-512-256 as authentication digest algorithms
George Joseph [Thu, 17 Oct 2024 14:02:08 +0000 (08:02 -0600)] 
Add SHA-256 and SHA-512-256 as authentication digest algorithms

* Refactored pjproject code to support the new algorithms and
added a patch file to third-party/pjproject/patches

* Added new parameters to the pjsip auth object:
  * password_digest = <algorithm>:<digest>
  * supported_algorithms_uac = List of algorithms to support
    when acting as a UAC.
  * supported_algorithms_uas = List of algorithms to support
    when acting as a UAS.
  See the auth object in pjsip.conf.sample for detailed info.

* Updated both res_pjsip_authenticator_digest.c (for UAS) and
res_pjsip_outbound_authentocator_digest.c (UAC) to suport the
new algorithms.

The new algorithms are only available with the bundled version
of pjproject, or an external version > 2.14.1.  OpenSSL version
1.1.1 or greater is required to support SHA-512-256.

Resolves: #948

UserNote: The SHA-256 and SHA-512-256 algorithms are now available
for authentication as both a UAS and a UAC.

(cherry picked from commit 1933548d41b3fba4bc90b3d3c0cc20f142707966)

6 months agoconfig.c: retain leading whitespace before comments
Allan Nathanson [Wed, 30 Oct 2024 20:52:41 +0000 (16:52 -0400)] 
config.c: retain leading whitespace before comments

Configurations loaded with the ast_config_load2() API and later written
out with ast_config_text_file_save2() will have any leading whitespace
stripped away.  The APIs should make reasonable efforts to maintain the
content and formatting of the configuration files.

This change retains any leading whitespace from comment lines that start
with a ";".

Resolves: https://github.com/asterisk/asterisk/issues/970
(cherry picked from commit 4528f5f25a5f4445eec7ebe0a1d9e925b005873b)

6 months agoconfig.c: Fix off-nominal reference leak.
Sean Bright [Tue, 7 Jan 2025 16:34:04 +0000 (11:34 -0500)] 
config.c: Fix off-nominal reference leak.

This was identified and fixed by @Allan-N in #918 but it is an
important fix in its own right.

The fix here is slightly different than Allan's in that we just move
the initialization of the problematic AO2 container to where it is
first used.

Fixes #1046

(cherry picked from commit c7562392b98b8d48f7eb2868442acf553881a563)

6 months agonormalize contrib/ast-db-manage/queue_log.ini.sample
Abdelkader Boudih [Sun, 5 Jan 2025 14:08:24 +0000 (15:08 +0100)] 
normalize contrib/ast-db-manage/queue_log.ini.sample

(cherry picked from commit 3fa488d840311af9d44821a83a8efa0528bd0148)

6 months agoAdd C++ Standard detection to configure and fix a new C++20 compile issue
George Joseph [Fri, 3 Jan 2025 22:38:52 +0000 (15:38 -0700)] 
Add C++ Standard detection to configure and fix a new C++20 compile issue

* The autoconf-archive package contains macros useful for detecting C++
  standard and testing other C++ capabilities but that package was never
  included in the install_prereq script so many existing build environments
  won't have it.  Even if it is installed, older versions won't newer C++
  standards and will actually cause an error if you try to test for that
  version. To make it available for those environments, the
  ax_cxx_compile_stdcxx.m4 macro has copied from the latest release of
  autoconf-archive into the autoconf directory.

* A convenience wrapper(ast_cxx_check_std) around ax_cxx_compile_stdcxx was
  also added so checking the standard version and setting the
  asterisk-specific PBX_ variables becomes a one-liner:
  `AST_CXX_CHECK_STD([std], [force_latest_std])`.
  Calling that with a version of `17` for instance, will set PBX_CXX17
  to 0 or 1 depending on whether the current c++ compiler supports stdc++17.
  HAVE_CXX17 will also be 'defined" or not depending on the result.

* C++ compilers hardly ever default to the latest standard they support.  g++
  version 14 for instance supports up to C++23 but only uses C++17 by default.
  If you want to use C++23, you have to add `-std=gnu++=23` to the g++
  command line.  If you set the second argument of AST_CXX_CHECK_STD to "yes",
  the macro will automatically keep the highest `-std=gnu++` value that
  worked and pass that to the Makefiles.

* The autoconf-archive package was added to install_prereq for future use.

* Updated configure.ac to use AST_CXX_CHECK_STD() to check for C++
  versions 11, 14, 17, 20 and 23.

* Updated configure.ac to accept the `--enable-latest-cxx-std` option which
  will set the second option to AST_CXX_CHECK_STD() to "yes".  The default
  is "no".

* ast_copy_string() in strings.h declares the 'sz' variable as volatile and
  does an `sz--` on it later.  C++20 no longer allows the `++` and `--`
  increment and decrement operators to be used on variables declared as
  volatile however so that was changed to `sz -= 1`.

(cherry picked from commit fb45a473cf7daf255352d6b6e32e8d6f2b4dae4f)

6 months agochan_dahdi: Fix wrong channel state when RINGING recieved.
Naveen Albert [Mon, 16 Dec 2024 13:43:04 +0000 (08:43 -0500)] 
chan_dahdi: Fix wrong channel state when RINGING recieved.

Previously, when AST_CONTROL_RINGING was received by
a DAHDI device, it would set its channel state to
AST_STATE_RINGING. However, an analysis of the codebase
and other channel drivers reveals RINGING corresponds to
physical power ringing, whereas AST_STATE_RING should be
used for audible ringback on the channel. This also ensures
the correct device state is returned by the channel state
to device state conversion.

Since there seems to be confusion in various places regarding
AST_STATE_RING vs. AST_STATE_RINGING, some documentation has
been added or corrected to clarify the actual purposes of these
two channel states, and the associated device state mapping.

An edge case that prompted this fix, but isn't explicitly
addressed here, is that of an incoming call to an FXO port.
The channel state will be "Ring", which maps to a device state
of "In Use", not "Ringing" as would be more intuitive. However,
this is semantic, since technically, Asterisk is treating this
the same as any other incoming call, and so "Ring" is the
semantic state (put another way, Asterisk isn't ringing anything,
like in the cases where channels are in the "Ringing" state).

Since FXO ports don't currently support Call Waiting, a suitable
workaround for the above would be to ignore the device state and
instead check the channel state (e.g. IMPORT(DAHDI/1-1,CHANNEL(state)))
since it will be Ring if the FXO port is idle (but a call is ringing
on it) and Up if the FXO port is actually in use. (In both cases,
the device state would misleadingly be "In Use".)

Resolves: #1029
(cherry picked from commit 9f6f9a60e575211f851ac038bc079c626755e3b9)

6 months agoUpgrade bundled pjproject to 2.15.1
Stanislav Abramenkov [Tue, 3 Dec 2024 20:25:40 +0000 (22:25 +0200)] 
Upgrade bundled pjproject to 2.15.1
Resolves: asterisk#1016

UserNote: Bundled pjproject has been upgraded to 2.15.1. For more
information visit pjproject Github page: https://github.com/pjsip/pjproject/releases/tag/2.15.1

(cherry picked from commit 01da9931686f5edc3994fd76a0c15cfae1ded266)

6 months ago.github: Set exit 0 in CherryPick and Recheck workflow Cleanup steps
George Joseph [Sun, 5 Jan 2025 17:35:22 +0000 (10:35 -0700)] 
.github: Set exit 0 in CherryPick and Recheck workflow Cleanup steps

(cherry picked from commit aff11f717f7bcc8151ff9f4a0c7a2f396e031de8)

6 months agogcc14: Fix issues caught by gcc 14
George Joseph [Fri, 3 Jan 2025 21:02:22 +0000 (14:02 -0700)] 
gcc14: Fix issues caught by gcc 14

* test_message.c: Fix segfaults caused by passing NULL as an sprintf fmt.

(cherry picked from commit 1fbd42936e28631fe182abe6dca584b73c3b018d)

6 months agoHeader fixes for compiling C++ source files
George Joseph [Tue, 31 Dec 2024 18:10:20 +0000 (11:10 -0700)] 
Header fixes for compiling C++ source files

A few tweaks needed to be done to some existing header files to allow them to
be compiled when included from C++ source files.

logger.h had declarations for ast_register_verbose() and
ast_unregister_verbose() which caused C++ issues but those functions were
actually removed from logger.c many years ago so the declarations were just
removed from logger.h.

(cherry picked from commit d5898305fbef06ca10a46f131d1ed2d67415f3f2)

6 months agoAdd ability to pass arguments to unit tests from the CLI
George Joseph [Fri, 27 Dec 2024 15:19:08 +0000 (08:19 -0700)] 
Add ability to pass arguments to unit tests from the CLI

Unit tests can now be passed custom arguments from the command
line.  For example, the following command would run the "mytest" test
in the "/main/mycat" category with the option "myoption=54"

`CLI> test execute category /main/mycat name mytest options myoption=54`

You can also pass options to an entire category...

`CLI> test execute category /main/mycat options myoption=54`

Basically, everything after the "options" keyword is passed verbatim to
the test which must decide what to do with it.

* A new API ast_test_get_cli_args() was created to give the tests access to
the cli_args->argc and cli_args->argv elements.

* Although not needed for the option processing, a new macro
ast_test_validate_cleanup_custom() was added to test.h that allows you
to specify a custom error message instead of just "Condition failed".

* The test_skel.c was updated to demonstrate parsing options and the use
of the ast_test_validate_cleanup_custom() macro.

(cherry picked from commit 6d63b628534178c929a3736ea316654cf6e60849)

6 months agores_pjsip: Add new AOR option "qualify_2xx_only"
Kent [Tue, 3 Dec 2024 14:24:44 +0000 (08:24 -0600)] 
res_pjsip: Add new AOR option "qualify_2xx_only"

Added a new option "qualify_2xx_only" to the res_pjsip AOR qualify
feature to mark a contact as available only if an OPTIONS request
returns a 2XX response. If the option is not specified or is false,
any response to the OPTIONS request marks the contact as available.

UserNote: The pjsip.conf AOR section now has a "qualify_2xx_only"
option that can be set so that only 2XX responses to OPTIONS requests
used to qualify a contact will mark the contact as available.

(cherry picked from commit 85f5a047c121542c3e106c221b51b21ddb36dd15)

6 months ago.github: Change the run name for OnPRStateChangedPriv
George Joseph [Wed, 18 Dec 2024 15:16:51 +0000 (08:16 -0700)] 
.github: Change the run name for OnPRStateChangedPriv

(cherry picked from commit e98887f3dce5920ef066c84010a4496d1321ac7c)

6 months agores_odbc: release threads from potential starvation.
Jaco Kroon [Tue, 10 Dec 2024 19:47:49 +0000 (21:47 +0200)] 
res_odbc: release threads from potential starvation.

Whenever a slot is freed up due to a failed connection, wake up a waiter
before failing.

In the case of a dead connection there could be waiters, for example,
let's say two threads tries to acquire objects at the same time, with
one in the cached connections, one will acquire the dead connection, and
the other will enter into the wait state.  The thread with the dead
connection will clear up the dead connection, and then attempt a
re-acquire (at this point there cannot be cached connections else the
other thread would have received that and tried to clean up), as such,
at this point we're guaranteed that either there are no waiting threads,
or that the maxconnections - connection_cnt threads will attempt to
re-acquire connections, and then either succeed, using those
connections, or failing, and then signalling to release more waiters.

Also fix the pointer log for ODBC handle %p dead which would always
reflect NULL.

Signed-off-by: Jaco Kroon <jaco@uls.co.za>
(cherry picked from commit 89ffbb5de7feed2cefb1427fa4b144b442dc4f2a)

6 months agoapp_queue: indicate the paused state of a dynamically added member in queue_log.
Sperl Viktor [Thu, 5 Dec 2024 16:55:10 +0000 (17:55 +0100)] 
app_queue: indicate the paused state of a dynamically added member in queue_log.

Fixes: #1021
(cherry picked from commit 392558ee59116cf9cb113a3a2369a48b739fccac)

6 months agoAllow C++ source files (as extension .cc) in the main directory
George Joseph [Mon, 9 Dec 2024 19:54:53 +0000 (12:54 -0700)] 
Allow C++ source files (as extension .cc) in the main directory

Although C++ files (as extension .cc) have been handled in the module
directories for many years, the main directory was missing one line in its
Makefile that prevented C++ files from being recognised there.

(cherry picked from commit ab820f612152d85102837e9d2d63c49242e8999e)

6 months agoformat_gsm.c: Added mime type
Alexey Khabulyak [Tue, 3 Dec 2024 09:53:10 +0000 (12:53 +0300)] 
format_gsm.c: Added mime type

Sometimes it's impossible to get a file extension from URL
(eg. http://example.com/gsm/your) so we have to rely on content-type header.
Currenly, asterisk does not support content-type for gsm format(unlike wav).
Added audio/gsm according to https://www.rfc-editor.org/rfc/rfc4856.html

(cherry picked from commit dab6ddc3227bf5b895dfcc3cda05f81229ddac0c)