Compare commits

...

606 Commits

Author SHA1 Message Date
George Joseph a7e4c193fc .github: Add PAT to PRSubmitActions/Add Reviewers 2024-03-06 09:25:43 -07:00
George Joseph 18f3c355f7 .github: Remove timeout-minutes from gatetests 2024-03-05 15:19:43 -07:00
George Joseph f841ae8e62 .github: Pass only single GATETEST_COMMAND to AsteriskGateComposite 2024-03-05 11:24:22 -07:00
George Joseph 386cdef149 Rename dialplan_functions.xml to dialplan_functions_doc.xml
When using COMPILE_DOUBLE, dialplan_functions.xml is mistaken
for the source for an embedded XML document and gets compiled
to dialplan_functions.o.  This causes dialplan_functions.c to
be ignored making its functions unavailable and causing chan_pjsip
to fail to load.
2024-02-26 16:20:41 -07:00
Sean Bright b4ecf5eaf1 openssl: Supress deprecation warnings from OpenSSL 3.0
There is work going on to update our OpenSSL usage to avoid the
deprecated functions but in the meantime make it possible to compile
in devmode.

Change-Id: Ib082eb8b3751f0185d8aa8fe127da664c93f0726
2024-02-26 16:20:30 -07:00
George Joseph 031703c596 .github: Add force_cherry_pick option to Releaser 2024-02-20 06:58:36 -07:00
George Joseph 7d65b0ad80 .github: Remove start_version from Releaser 2024-02-20 06:55:29 -07:00
Mike Bradeen e0be8be337 app_chanspy: Add 'D' option for dual-channel audio
Adds the 'D' option to app chanspy that causes the input and output
frames of the spied channel to be interleaved in the spy output frame.
This allows the input and output of the spied channel to be decoded
separately by the receiver.

If the 'o' option is also set, the 'D' option is ignored as the
audio being spied is inherently one direction.

Fixes: #569

UserNote: The ChanSpy application now accepts the 'D' option which
will interleave the spied audio within the outgoing frames. The
purpose of this is to allow the audio to be read as a Dual channel
stream with separate incoming and outgoing audio. Setting both the
'o' option and the 'D' option and results in the 'D' option being
ignored.
2024-02-06 17:21:23 +00:00
George Joseph be9b5bf0a9 .github: Update github-script to v7 and fix a rest bug
Need to update the github-script to v7 to squash deprecation
warnings.

Also fixed the API name for github.rest.pulls.requestReviewers.
2024-02-05 08:36:29 -07:00
Naveen Albert 3ff081e581 manager.c: Fix regression due to using wrong free function.
Commit 424be34563 introduced
a regression by calling ast_free on memory allocated by
realpath. This causes Asterisk to abort when executing this
function. Since the memory is allocated by glibc, it should
be freed using ast_std_free.

Resolves: #513
2024-01-02 12:07:02 +00:00
George Joseph a4f9d885a7 res_rtp_asterisk: Fix regression issues with DTLS client check
* Since ICE candidates are used for the check and pjproject is
  required to use ICE, res_rtp_asterisk was failing to compile
  when pjproject wasn't available.  The check is now wrapped
  with an #ifdef HAVE_PJPROJECT.

* The rtp->ice_active_remote_candidates container was being
  used to check the address on incoming packets but that
  container doesn't contain peer reflexive candidates discovered
  during negotiation. This was causing the check to fail
  where it shouldn't.  We now check against pjproject's
  real_ice->rcand array which will contain those candidates.

* Also fixed a bug in ast_sockaddr_from_pj_sockaddr() where
  we weren't zeroing out sin->sin_zero before returning.  This
  was causing ast_sockaddr_cmp() to always return false when
  one of the inputs was converted from a pj_sockaddr, even
  if both inputs had the same address and port.

Resolves: #500
Resolves: #503
Resolves: #505
2023-12-20 14:02:29 +00:00
George Joseph 85fc4ce712 doc: Remove obsolete CHANGES-staging directrory
This should have been removed after the last release but
was missed.
2023-12-15 20:04:48 +00:00
Gitea 6b4f9ab005 res_pjsip_header_funcs: Duplicate new header value, don't copy.
When updating an existing header the 'update' code incorrectly
just copied the new value into the existing buffer. If the
new value exceeded the available buffer size memory outside
of the buffer would be written into, potentially causing
a crash.

This change makes it so that the 'update' now duplicates
the new header value instead of copying it into the existing
buffer.
2023-12-14 18:48:42 +00:00
George Joseph 2b66362173 res_rtp_asterisk.c: Check DTLS packets against ICE candidate list
When ICE is in use, we can prevent a possible DOS attack by allowing
DTLS protocol messages (client hello, etc) only from sources that
are in the active remote candidates list.

Resolves: GHSA-hxj9-xwr8-w8pq
2023-12-14 18:48:14 +00:00
Ben Ford 705cd2845d manager.c: Prevent path traversal with GetConfig.
When using AMI GetConfig, it was possible to access files outside of the
Asterisk configuration directory by using filenames with ".." and "./"
even while live_dangerously was not enabled. This change resolves the
full path and ensures we are still in the configuration directory before
attempting to access the file.
2023-12-14 18:47:33 +00:00
Mike Bradeen c7050787f3 res_pjsip: disable raw bad packet logging
Add patch to split the log level for invalid packets received on the signaling port.
    The warning regarding the packet will move to level 2 so that it can still be displayed,
    while the raw packet will be at level 4.
2023-12-14 18:47:21 +00:00
George Joseph 0f20f39db8 MergeApproved.yml: Remove unneeded concurrency
The concurrency parameter on the MergeAndCherryPick job has
been rmeoved.  It was a hold-over from earlier days.
2023-12-06 14:29:24 -07:00
George Joseph c53cd1c82d SECURITY.md: Update with correct documentation URL 2023-11-09 11:46:33 -07:00
George Joseph 8e012faf9e chan_pjsip: Add PJSIPHangup dialplan app and manager action
See UserNote below.

Exposed the existing Hangup AMI action in manager.c so we can use
all of it's channel search and AMI protocol handling without
duplicating that code in dialplan_functions.c.

Added a lookup function to res_pjsip.c that takes in the
string represenation of the pjsip_status_code enum and returns
the actual status code.  I.E.  ast_sip_str2rc("DECLINE") returns
603.  This allows the caller to specify PJSIPHangup(decline) in
the dialplan, just like Hangup(call_rejected).

Also extracted the XML documentation to its own file since it was
almost as large as the code itself.

UserNote: A new dialplan app PJSIPHangup and AMI action allows you
to hang up an unanswered incoming PJSIP call with a specific SIP
response code in the 400 -> 699 range.
2023-11-07 10:42:12 -07:00
Mark Murawski 81c400a1c2 Remove files that are no longer updated
Fixes: #360
2023-11-01 08:27:45 -06:00
Mike Bradeen db5767f19d res_speech: allow speech to translate input channel
* Allow res_speech to translate the input channel if the
  format is translatable to a format suppored by the
  speech provider.

Resolves: #129

UserNote: res_speech now supports translation of an input channel
to a format supported by the speech provider, provided a translation
path is available between the source format and provider capabilites.
2023-10-30 11:52:08 +00:00
George Joseph 05d26994af .github: PRSubmitActions: Fix adding reviewers to PR 2023-10-19 09:57:20 -06:00
George Joseph cd640dc67b .github: New PR Submit workflows
The workflows that get triggered when PRs are submitted or updated
have been replaced with ones that are more secure and have
a higher level of parallelism.
2023-10-17 12:34:19 -06:00
George Joseph 5eb676bab5 .github: New PR Submit workflows
The workflows that get triggered when PRs are submitted or updated
have been replaced with ones that are more secure and have
a higher level of parallelism.
2023-10-17 12:32:14 -06:00
Mike Bradeen 5342562892 res_stasis: signal when new command is queued
res_statsis's app loop sleeps for up to .2s waiting on input
to a channel before re-checking the command queue. This can
cause delays between channel setup and bridge.

This change is to send a SIGURG on the sleeping thread when
a new command is enqueued. This exits the sleeping thread out
of the ast_waitfor() call triggering the new command being
processed on the channel immediately.

Resolves: #362

UserNote: Call setup times should be significantly improved
when using ARI.
2023-10-10 17:18:03 +00:00
George Joseph 20b06e7bb5 logger.h: Add ability to change the prefix on SCOPE_TRACE output
You can now define the _TRACE_PREFIX_ macro to change the
default trace line prefix of "file:line function" to
something else.  Full documentation in logger.h.
2023-10-09 15:36:51 +00:00
George Joseph d0a1c2b026 .github: Fix job prereqs in PROpenedUpdated 2023-10-09 08:50:02 -06:00
George Joseph 825d3b981a .github: Block PR tests until approved 2023-10-09 08:49:58 -06:00
George Joseph 733ab35848 Add libjwt to third-party
The current STIR/SHAKEN implementation is not currently usable due
to encryption issues. Rather than trying to futz with OpenSSL and
the the current code, we can take advantage of the existing
capabilities of libjwt but we first need to add it to the
third-party infrastructure already in place for jansson and
pjproject.

A few tweaks were also made to the third-party infrastructure as
a whole.  The jansson "dest" install directory was renamed "dist"
to better match convention, and the third-party Makefile was updated
to clean all product directories not just the ones currently in
use.

Resolves: #349
2023-10-05 11:52:12 -06:00
Mike Bradeen 7369de127a res_pjsip: update qualify_timeout documentation with DNS note
The documentation on qualify_timeout does not explicitly state that the timeout
includes any time required to perform any needed DNS queries on the endpoint.

If the OPTIONS response is delayed due to the DNS query, it can still render an
endpoint as Unreachable if the net time is enough for qualify_timeout to expire.

Resolves: #352
2023-10-05 16:59:03 +00:00
George Joseph 04183eb246 lock.c: Separate DETECT_DEADLOCKS from DEBUG_THREADS
Previously, DETECT_DEADLOCKS depended on DEBUG_THREADS.
Unfortunately, DEBUG_THREADS adds a lot of lock tracking overhead
to all of the lock lifecycle calls whereas DETECT_DEADLOCKS just
causes the lock calls to loop over trylock in 200us intervals until
the lock is obtained and spits out log messages if it takes more
than 5 seconds.  From a code perspective, the only reason they were
tied together was for logging.  So... The ifdefs in lock.c were
refactored to allow DETECT_DEADLOCKS to be enabled without
also enabling DEBUG_THREADS.

Resolves: #321

UserNote: You no longer need to select DEBUG_THREADS to use
DETECT_DEADLOCKS.  This removes a significant amount of overhead
if you just want to detect possible deadlocks vs needing full
lock tracing.
2023-09-22 14:34:43 +00:00
Mike Bradeen 5c58a6fd56 cel: add publish user event helper
Add a wrapper function around ast_cel_publish_event that
packs event and extras into a blob before publishing

Resolves:#330
2023-09-21 14:47:18 +00:00
George Joseph 7b42ebb90d file.c: Add ability to search custom dir for sounds
To better co-exist with sounds files that may be managed by
packages, custom sound files may now be placed in
AST_DATA_DIR/sounds/custom instead of the standard
AST_DATA_DIR/sounds/<lang> directory.  If the new
"sounds_search_custom_dir" option in asterisk.conf is set
to "true", asterisk will search the custom directory for sounds
files before searching the standard directory.  For performance
reasons, the "sounds_search_custom_dir" defaults to "false".

Resolves: #315

UserNote: A new option "sounds_search_custom_dir" has been added to
asterisk.conf that allows asterisk to search
AST_DATA_DIR/sounds/custom for sounds files before searching the
standard AST_DATA_DIR/sounds/<lang> directory.
2023-09-20 19:15:03 +00:00
George Joseph 8d506370f5 make_buildopts_h, et. al. Allow adding all cflags to buildopts.h
The previous behavior of make_buildopts_h was to not add the
non-ABI-breaking MENUSELECT_CFLAGS like DETECT_DEADLOCKS,
REF_DEBUG, etc. to the buildopts.h file because "it caused
ccache to invalidate files and extended compile times". They're
only defined by passing them on the gcc command line with '-D'
options.   In practice, including them in the include file rarely
causes any impact because the only time ccache cares is if you
actually change an option so the hit occurrs only once after
you change it.

OK so why would we want to include them?  Many IDEs follow the
include files to resolve defines and if the options aren't in an
include file, it can cause the IDE to mark blocks of "ifdeffed"
code as unused when they're really not.

So...

* Added a new menuselect compile option ADD_CFLAGS_TO_BUILDOPTS_H
  which tells make_buildopts_h to include the non-ABI-breaking
  flags in buildopts.h as well as the ABI-breaking ones. The default
  is disabled to preserve current behavior.  As before though,
  only the ABI-breaking flags appear in AST_BUILDOPTS and only
  those are used to calculate AST_BUILDOPT_SUM.
  A new AST_BUILDOPT_ALL define was created to capture all of the
  flags.

* make_version_c was streamlined to use buildopts.h and also to
  create asterisk_build_opts_all[] and ast_get_build_opts_all(void)

* "core show settings" now shows both AST_BUILDOPTS and
  AST_BUILDOPTS_ALL.

UserNote: The "Build Options" entry in the "core show settings"
CLI command has been renamed to "ABI related Build Options" and
a new entry named "All Build Options" has been added that shows
both breaking and non-breaking options.
2023-09-14 17:58:22 +00:00
Mike Bradeen cf623753a9 func_periodic_hook: Add hangup step to avoid timeout
func_periodic_hook does not hangup after playback, relying on hangup
which keeps the channel alive longer than necessary.

Resolves: #325
2023-09-13 17:36:41 +00:00
George Joseph 2e59f9fd6a func_periodic_hook: Don't truncate channel name
func_periodic_hook was truncating long channel names which
causes issues when you need to run other dialplan functions/apps
on the channel.

Resolves: #319
2023-09-13 15:17:55 +00:00
George Joseph 4e43b9d308 safe_asterisk: Change directory permissions to 755
If the safe_asterisk script detects that the /var/lib/asterisk
directory doesn't exist, it now creates it with 755 permissions
instead of 770.  safe_asterisk needing to create that directory
should be extremely rare though because it's normally created
by 'make install' which already sets the permissions to 755.

Resolves: #316
2023-09-13 15:17:17 +00:00
Joshua C. Colp 405a08aaed variables: Add additional variable dialplan functions.
Using the Set dialplan application does not actually
delete channel or global variables. Instead the
variables are set to an empty value.

This change adds two dialplan functions,
GLOBAL_DELETE and DELETE which can be used to
delete global and channel variables instead
of just setting them to empty.

There is also no ability within the dialplan to
determine if a global or channel variable has
actually been set or not.

This change also adds two dialplan functions,
GLOBAL_EXISTS and VARIABLE_EXISTS which can be
used to determine if a global or channel variable
has been set or not.

Resolves: #289

UserNote: Four new dialplan functions have been added.
GLOBAL_DELETE and DELETE have been added which allows
the deletion of global and channel variables.
GLOBAL_EXISTS and VARIABLE_EXISTS have been added
which checks whether a global or channel variable has
been set.
2023-09-07 11:27:59 +00:00
George Joseph 3d01cbaae9 ari-stubs: Fix more local anchor references
Also allow CreateDocs job to be run manually with default branches.
2023-09-05 13:36:23 -06:00
George Joseph 2f1d12b7dc ari-stubs: Fix more local anchor references
Also allow CreateDocs job to be run manually with default branches.
2023-09-05 13:05:53 -06:00
George Joseph e54d867f25 ari-stubs: Fix broken documentation anchors
All of the links that reference page anchors with capital letters in
the ids (#Something) have been changed to lower case to match the
anchors that are generated by mkdocs.
2023-09-05 09:55:56 -06:00
George Joseph d2172582f7 rest-api: Updates for new documentation site
The new documentation site uses traditional markdown instead
of the Confluence flavored version.  This required changes in
the mustache templates and the python that generates the files.
2023-08-31 08:22:07 -06:00
George Joseph 56e592248d .github: Update workflow-application-token-action to v2 2023-08-31 07:26:12 -06:00
Mike Bradeen 8f5fb2af23 app_voicemail: Fix for loop declarations
Resolve for loop initial declarations added in cli changes.

Resolves: #275
2023-08-30 13:05:27 +00:00
George Joseph bebf843253 download_externals: Fix a few version related issues
* Fixed issue with the script not parsing the new tag format for
  certified releases.  The format changed from certified/18.9-cert5
  to certified-18.9-cert5.

* Fixed issue where the asterisk version wasn't being considered
  when looking for cached versions.

Resolves: #263
2023-08-22 13:32:16 +00:00
George Joseph 87773dc11f Remove .lastclean and .version from source control
Historically these were checked in for certified releases but
since the move to github and the unified release process,
they are no longer needed and cause issues.
2023-08-22 11:34:16 +00:00
George Joseph a95f98f8bb .github: Use generic releaser 2023-08-15 13:13:16 -06:00
Joshua C. Colp c83c14ba2d manager: Tolerate stasis messages with no channel snapshot.
In some cases I have yet to determine some stasis messages may
be created without a channel snapshot. This change adds some
tolerance to this scenario, preventing a crash from occurring.
2023-08-11 13:29:03 +00:00
Joshua C. Colp b37b28e071 audiohook: Unlock channel in mute if no audiohooks present.
In the case where mute was called on a channel that had no
audiohooks the code was not unlocking the channel, resulting
in a deadlock.

Resolves: #233
2023-08-09 14:50:02 +00:00
Joshua C. Colp 82c0971e6e app_queue: Add support for applying caller priority change immediately.
The app_queue module provides both an AMI action and a CLI command
to change the priority of a caller in a queue. Up to now this change
of priority has only been reflected to new callers into the queue.

This change adds an "immediate" option to both the AMI action and
CLI command which immediately applies the priority change respective
to the other callers already in the queue. This can allow, for example,
a caller to be placed at the head of the queue immediately if their
priority is sufficient.

Resolves: #202

UserNote: The 'queue priority caller' CLI command and
'QueueChangePriorityCaller' AMI action now have an 'immediate'
argument which allows the caller priority change to be reflected
immediately, causing the position of a caller to move within the
queue depending on the priorities of the other callers.
2023-07-18 13:03:01 +00:00
George Joseph 8aba4a4f88 .github: Fix cherry-pick reminder issues 2023-07-17 09:26:56 -06:00
George Joseph e46f7892a6 app.h: Move declaration of ast_getdata_result before its first use
The ast_app_getdata() and ast_app_getdata_terminator() declarations
in app.h were changed recently to return enum ast_getdata_result
(which is how they were defined in app.c).  The existing
declaration of ast_getdata_result in app.h was about 1000 lines
after those functions however so under certain circumstances,
a "use before declaration" error was thrown by the compiler.
The declaration of the enum was therefore moved to before those
functions.

Resolves: #200
2023-07-12 17:44:47 +00:00
George Joseph 7c84bf40e0 doc: Remove obsolete CHANGES-staging and UPGRADE-staging 2023-07-12 17:41:45 +00:00
Sean Bright 836f0bed18 res_geolocation: Ensure required 'location_info' is present.
Fixes #189
2023-07-12 17:39:07 +00:00
Mike Bradeen 4929a2c419 Adds manager actions to allow move/remove/forward individual messages
in a particular mailbox folder. The forward command can be used
to copy a message within a mailbox or to another mailbox. Also adds
a VoicemailBoxSummarry, required to retrieve message ID's.

Resolves: #181

UserNote: The following manager actions have been added

VoicemailBoxSummary - Generate message list for a given mailbox

VoicemailRemove - Remove a message from a mailbox folder

VoicemailMove - Move a message from one folder to another within a mailbox

VoicemailForward - Copy a message from one folder in one mailbox
to another folder in another or the same mailbox.
2023-07-12 17:37:36 +00:00
Mike Bradeen 8f8413b494 app_voicemail: add CLI commands for message manipulation
Adds CLI commands to allow move/remove/forward individual messages
from a particular mailbox folder. The forward command can be used
to copy a message within a mailbox or to another mailbox. Also adds
a show mailbox, required to retrieve message ID's.

Resolves: #170

UserNote: The following CLI commands have been added to app_voicemail

voicemail show mailbox <mailbox> <context>
Show contents of mailbox <mailbox>@<context>

voicemail remove <mailbox> <context> <from_folder> <messageid>
Remove message <messageid> from <from_folder> in mailbox <mailbox>@<context>

voicemail move <mailbox> <context> <from_folder> <messageid> <to_folder>
Move message <messageid> in mailbox <mailbox>&<context> from <from_folder> to <to_folder>

voicemail forward <from_mailbox> <from_context> <from_folder> <messageid> <to_mailbox> <to_context> <to_folder>
Forward message <messageid> in mailbox <mailbox>@<context> <from_folder> to
mailbox <mailbox>@<context> <to_folder>
2023-07-12 17:36:55 +00:00
George Joseph 3bb5cef959 .github: Minor tweak to Asterisk Releaser 2023-07-12 06:49:25 -06:00
George Joseph e1e294a5e3 .github: Suppress cherry-pick reminder for some situations
In PROpenedOrUpdated, the cherry-pick reminder will now be
suppressed if there are already valid 'cherry-pick-to' comments
in the PR or the PR contained a 'cherry-pick-to: none' comment.
2023-07-11 06:35:39 -06:00
Sean Bright 2291ea7a6b apply_patches: Use globbing instead of file/sort.
This accomplishes the same thing as a `find ... | sort` but with the
added benefit of clarity and avoiding a call to a subshell.

Additionally drop the -s option from call to patch as it is not POSIX.
2023-07-07 15:12:08 +00:00
George Joseph 6dc6d11671 apply_patches: Sort patch list before applying
The apply_patches script wasn't sorting the list of patches in
the "patches" directory before applying them. This left the list
in an indeterminate order. In most cases, the list is actually
sorted but rarely, they can be out of order and cause dependent
patches to fail to apply.

We now sort the list but the "sort" program wasn't in the
configure scripts so we needed to add that and regenerate
the scripts as well.

Resolves: #193
2023-07-06 14:04:16 +00:00
George Joseph 452e0d7258 bundled_pjproject: Backport security fixes from pjproject 2.13.1
Merge-pull-request-from-GHSA-9pfh-r8x4-w26w.patch
Merge-pull-request-from-GHSA-cxwq-5g9x-x7fr.patch
Locking-fix-so-that-SSL_shutdown-and-SSL_write-are-n.patch
Don-t-call-SSL_shutdown-when-receiving-SSL_ERROR_SYS.patch

Resolves: #188
2023-07-05 10:05:50 -06:00
George Joseph 15ecfab8d1 .github: Updates for AsteriskReleaser 2023-06-30 07:02:24 -06:00
Mike Bradeen f5f09246e2 res_musiconhold: avoid moh state access on unlocked chan
Move channel unlock to after moh state access to avoid
potential unlocked access to state.

Resolves: #133
2023-06-29 15:15:12 +00:00
Mike Bradeen 2822bb3977 utils: add lock timestamps for DEBUG_THREADS
Adds last locked and unlocked timestamps as well as a
counter for the number of times the lock has been
attempted (vs locked/unlocked) to debug output printed
using the DEBUG_THREADS option.

Resolves: #110
2023-06-29 15:13:52 +00:00
George Joseph e52ad19715 .github: Back out triggering PROpenedOrUpdated by label 2023-06-29 09:07:06 -06:00
George Joseph a44ac70801 .github: Move publish docs to new file CreateDocs.yml 2023-06-27 12:18:51 -06:00
George Joseph a41f911ba3 .github: Remove result check from PROpenUpdateGateTests 2023-06-27 05:18:14 -06:00
George Joseph 8c49e751b8 .github: Fix use of 'contains' 2023-06-26 08:45:42 -06:00
George Joseph f6a323be8d .github: Add recheck label test to additional jobs 2023-06-26 07:46:23 -06:00
George Joseph 523474a2f3 .github: Fix recheck label typos 2023-06-26 07:22:09 -06:00
George Joseph 036951e21a .github: Fix recheck label manipulation 2023-06-26 07:11:58 -06:00
George Joseph efa4b02a0d .github: Allow PR submit checks to be re-run by label 2023-06-26 07:08:07 -06:00
Ben Ford 8c76507b9f res_pjsip_session: Added new function calls to avoid ABI issues.
Added two new functions (ast_sip_session_get_dialog and
ast_sip_session_get_pjsip_inv_state) that retrieve the dialog and the
pjsip_inv_state respectively from the pjsip_inv_session on the
ast_sip_session struct. This is due to pjproject adding a new field to
the pjsip_inv_session struct that caused crashes when trying to access
fields that were no longer where they were expected to be if a module
was compiled against a different version of pjproject.

Resolves: #145
2023-06-13 17:57:32 +00:00
George Joseph 7dfc190e23 test_statis_endpoints: Fix channel_messages test again 2023-06-12 08:37:56 -06:00
George Joseph 653aee2f13 test_stasis_endpoints.c: Make channel_messages more stable
The channel_messages test was assuming that stasis would return
messages in a specific order.  This is an incorrect assumption as
message ordering was never guaranteed.  This was causing the test
to fail occasionally.  We now test all the messages for the
required message types instead of testing one by one.

Resolves: #158
2023-06-09 23:28:12 +00:00
George Joseph 8b93cd97e8 build: Fix a few gcc 13 issues
* gcc 13 is now catching when a function is declared as returning
  an enum but defined as returning an int or vice versa.  Fixed
  a few in app.h, loader.c, stasis_message.c.

* gcc 13 is also now (incorrectly) complaining of dangling pointers
  when assigning a pointer to a local char array to a char *. Had
  to change that to an ast_alloca.

Resolves: #155
2023-06-09 19:03:24 +00:00
George Joseph 2645b68a08 .github: Rework for merge approval 2023-06-08 13:34:50 -06:00
Ben Ford 1f32a01485 AMI: Add CoreShowChannelMap action.
Adds a new AMI action (CoreShowChannelMap) that takes in a channel name
and provides a list of all channels that are connected to that channel,
following local channel connections as well.

Resolves: #104

UserNote: New AMI action CoreShowChannelMap has been added.
2023-06-05 18:30:42 +00:00
George Joseph 1216508654 .github: Fix issues with cherry-pick-reminder 2023-06-05 10:38:31 -06:00
Mike Bradeen 5bfe94461a indications: logging changes
Increase verbosity to indicate failure due to missing country
and to specify default on CLI dump

Resolves: #89
2023-06-05 13:31:57 +00:00
George Joseph 6c43294975 .github Ignore error when adding reviewrs to PR 2023-06-05 07:16:44 -06:00
George Joseph 7c5f7fffb3 .github: Update field descriptions for AsteriskReleaser 2023-05-26 08:52:03 -06:00
George Joseph 0c173be750 .github: Change title of AsteriskReleaser job 2023-05-23 08:05:06 -06:00
George Joseph 1077728ddc .github: Don't add cherry-pick reminder if it's already present 2023-05-22 12:55:06 -06:00
George Joseph 57e3390a81 .github: Fix quoting in PROpenedOrUpdated 2023-05-16 16:12:05 -06:00
George Joseph 6d71d8eea5 .github: Add cherry-pick reminder to new PRs 2023-05-15 09:38:03 -06:00
Sean Bright e73e5f7ed4
core: Cleanup gerrit and JIRA references. (#40) (#61)
* Remove .gitreview and switch to pulling the main asterisk branch
  version from configure.ac instead.

* Replace references to JIRA with GitHub.

* Other minor cleanup found along the way.

Resolves: #39
2023-05-10 06:17:10 -06:00
Joshua C. Colp 10b40dad53 .github: Tweak improvement issue type language. 2023-05-09 10:47:43 -03:00
Gitea a74ef79ce2 .github: Tweak new feature language, and move feature requests elsewhere. 2023-05-09 10:43:58 -03:00
Joshua C. Colp 3ef4c8a72c .github: Fix staleness check to only run on certain labels. 2023-05-09 06:18:33 -03:00
George Joseph 493c2debf8 .github: Add AsteriskReleaser 2023-05-08 11:01:57 -06:00
Mike Bradeen 61f4399082 cel: add local optimization begin event
The current AST_CEL_LOCAL_OPTIMIZE event is and has been
triggered on a local optimization end to serve as a flag
indicating the event occurred.  This change adds a second
AST_CEL_LOCAL_OPTIMIZE_BEGIN event for further detail.

Resolves: #52

UpgradeNote: The existing AST_CEL_LOCAL_OPTIMIZE can continue
to be used as-is and the AST_CEL_LOCAL_OPTIMIZE_BEGIN event
can be ignored if desired.

UserNote: The new AST_CEL_LOCAL_OPTIMIZE_BEGIN can be used
by itself or in conert with the existing
AST_CEL_LOCAL_OPTIMIZE to book-end local channel optimizaion.
2023-05-04 14:53:07 +00:00
George Joseph b9ad757aab .github: Fix CherryPickTest to only run when it should
Fixed CherryPickTest so it triggers only on the
"cherry-pick-test" label instead of all labels.
2023-05-03 09:30:55 -06:00
George Joseph e95eba5894 .github: Fix reference to CHERRY_PICK_TESTING_IN_PROGRESS 2023-05-02 14:10:15 -06:00
George Joseph 4b982965e9 .github: Remove separate set labels step from new PR 2023-05-02 12:11:48 -06:00
George Joseph bcfaea4a8b .github: Refactor CP progress and add new PR test progress 2023-05-02 12:05:13 -06:00
George Joseph 8900c3f7a7 .github: Add cherry-pick test progress labels 2023-05-02 08:58:33 -06:00
George Joseph 04668ea95b .github: Update issue templates 2023-05-01 09:38:03 -06:00
George Joseph d566b3e413 .github: Remove unnecessary parameter in CherryPickTest 2023-05-01 06:52:32 -06:00
George Joseph f09894cddf Initial GitHub PRs 2023-04-28 12:31:57 -06:00
George Joseph a7f6e3d674 Initial GitHub Issue Templates 2023-04-28 11:32:01 -06:00
George Joseph fe9c904a65 test.c: Fix counting of tests and add 2 new tests
The unit test XML output was counting all registered tests as "run"
even when only a subset were actually requested to be run and
the "failures" attribute was missing.

* The "tests" attribute of the "testsuite" element in the
  output XML now reflects only the tests actually requested
  to be executed instead of all the tests registered.

* The "failures" attribute was added to the "testsuite"
  element.

Also added 2 new unit tests that just pass and fail to be
used for CI testing.

Change-Id: Ia137814b5aeb0e1a44c75034bd3615c26021da69
2023-04-10 08:53:46 -06:00
Mike Bradeen 0af1da68f1 res_mixmonitor: MixMonitorMute by MixMonitor ID
While it is possible to create multiple mixmonitor instances
on a channel, it was not previously possible to mute individual
instances.

This change includes the ability to specify the MixMonitorID
when calling the manager action: MixMonitorMute.  This will
allow an individual MixMonitor instance to be muted via id.
This id can be stored as a channel variable using the 'i'
MixMonitor option.

As part of this change, if no MixMonitorID is specified in
the manager action MixMonitorMute, Asterisk will set the mute
flag on all MixMonitor spy-type audiohooks on the channel.
This is done via the new audiohook function:
ast_audiohook_set_mute_all.

ASTERISK-30464

Change-Id: Ibba8c7e750577aa1595a24b23316ef445245be98
2023-03-20 09:23:47 -05:00
Mike Bradeen d5f3db3e73 format_sln: add .slin as supported file extension
Adds '.slin' to existing supported file extensions:
.sln and .raw

ASTERISK-30465

Change-Id: Ice848addc03a64c8404b87cb5d3b13399c57e496
2023-03-20 09:06:01 -05:00
Mike Bradeen 450345386f bridge_builtin_features: add beep via touch variable
Add periodic beep option to one-touch recording by setting
the touch variable TOUCH_MONITOR_BEEP or
TOUCH_MIXMONITOR_BEEP to the desired interval in seconds.

If the interval is less than 5 seconds, a minimum of 5
seconds will be imposed.  If the interval is set to an
invalid value, it will default to 15 seconds.

A new test event PERIODIC_HOOK_ENABLED was added to the
func_periodic_hook hook_on function to indicate when
a hook is started.  This is so we can test that the touch
variable starts the hook as expected.

ASTERISK-30446

Change-Id: I800e494a789ba7a930bbdcd717e89d86040d6661
2023-03-16 15:44:27 -06:00
Mike Bradeen 1a649af1b1 cli: increase channel column width
For 'core show channels', the Channel name field is increased
to 64 characters and the Location name field is increased to
32 characters.

For 'core show channels verbose', the Channel name field is
increased to 80 characters, the Context is increased to 24
characters and the Extension is increased to 24 characters.

ASTERISK-30455

Change-Id: Ibec3742ce360ffc93bc56e9984c2a21dabc4d5e1
2023-03-13 14:51:04 -06:00
Mike Bradeen 7952316bf1 app_senddtmf: Add option to answer target channel.
Adds a new option to SendDTMF() which will answer the specified
channel if it is not already up. If no channel is specified, the
current channel will be answered instead.

ASTERISK-30422

Change-Id: Iddcbd501fcdf9fef0f453b7a8115a90b11f1d085
(cherry picked from commit f015d3e0cc)
2023-02-28 03:57:46 -06:00
Mike Bradeen 9e6a70b586 app_directory: Add a 'skip call' option.
Adds 's' option to skip calling the extension and instead set the
extension as DIRECTORY_EXTEN channel variable.

ASTERISK-30405

Change-Id: Ib9d9db1ba5b7524594c640461b4aa8f752db8299
2023-02-28 03:57:24 -06:00
Mike Bradeen 4bf3f6c04e app_read: Add an option to return terminator on empty digits.
Adds 'e' option to allow Read() to return the terminator as the
dialed digits in the case where only the terminator is entered.

ie; if "#" is entered, return "#" if the 'e' option is set and ""
if it is not.

ASTERISK-30411

Change-Id: I49f3221824330a193a20c660f99da0f1fc2cbbc5
2023-02-27 12:15:57 -06:00
Mike Bradeen d334e0cf89 app_directory: add ability to specify configuration file
Adds option to app_directory to specify a filename from which to
read configuration instead of voicemail.conf ie;

same => n,Directory(,,c(directory.conf))

This configuration should contain a list of extensions using the
voicemail.conf format, ie;

2020=2020,Dog Dog,,,,attach=no|saycid=no|envelope=no|delete=no

ASTERISK-30404

Change-Id: Id58ccb1344ad1e563fa10db12f172fbd104a9d13
(cherry picked from commit ef6901e137)
2023-01-30 10:52:34 -06:00
Asterisk Development Team 8a6ee89571 Update for certified/18.9-cert4 2023-01-19 06:33:44 -05:00
George Joseph dda609c9df res_pjsip_transport_websocket: Add remote port to transport
When Asterisk receives a new websocket conenction, it creates a new
pjsip transport for it and copies connection data into it.  The
transport manager then uses the remote IP address and port on the
transport to create a monitor for each connection.  However, the
remote port wasn't being copied, only the IP address which meant
that the transport manager was creating only 1 monitoring entry for
all websocket connections from the same IP address. Therefore, if
one of those connections failed, it deleted the transport taking
all the the connections from that same IP address with it.

* We now copy the remote port into the created transport and the
  transport manager behaves correctly.

ASTERISK-30369

Change-Id: Ib506d40897ea6286455ac0be4dfbb0ed43b727e1
2022-12-23 05:32:04 -07:00
Joshua C. Colp c20750bbaf res_pjsip_transport_websocket: Also set the remote name.
As part of PJSIP 2.11 a behavior change was done to require
a matching remote hostname on an established transport for
secure transports. Since the Websocket transport is considered
a secure transport this caused the existing connection to not
be found and used.

We now set the remote hostname and the transport can be found.

ASTERISK-30065

Change-Id: Ia1cdef33e1411f927985b4b852c95e163c080e94
2022-12-23 05:31:55 -07:00
Alexandre Fournier 646a9a7ec6 res_geoloc: fix NULL pointer dereference bug
The `ast_geoloc_datastore_add_eprofile` function does not return 0 on
success, it returns the size of the underlying datastore. This means
that the datastore will be freed and its pointer set to NULL when no
error occured at all.

ASTERISK-30346

Change-Id: Iea9b209bd1244cc57b903b9496cb680c356e4bb9
2022-12-13 10:32:27 -05:00
Asterisk Development Team 1196d4b5d3 Update for certified/18.9-cert3 2022-12-01 15:11:36 -05:00
Asterisk Development Team 4e9c0bc880 Update CHANGES and UPGRADE.txt for certified/18.9-cert3 2022-12-01 14:54:03 -05:00
Asterisk Development Team 28a23f6595 Update for certified/18.9-cert3 2022-12-01 13:52:55 -06:00
Mike Bradeen de142180a3 ooh323c: not checking for IE minimum length
When decoding q.931 encoded calling/called number
now checking for length being less than minimum required.

ASTERISK-30103

Change-Id: I3dcfce0f35eca258dc450f87c92d4d7af402c2e7
2022-12-01 11:55:57 -06:00
Mike Bradeen 2285ffd5eb manager: prevent file access outside of config dir
Add live_dangerously flag to manager and use this flag to
determine if a configuation file outside of AST_CONFIG_DIR
should be read.

ASTERISK-30176

Change-Id: I46b26af4047433b49ae5c8a85cb8cda806a07404
2022-12-01 11:54:17 -06:00
Ben Ford 9d74efa30f pjproject: 2.13 security fixes
Backports two security fixes (c4d3498 and 450baca) from pjproject 2.13.
The first one was modified due to merge conflicts specifically with
certified.

ASTERISK-30338

Change-Id: I86fdc003d5d22cb66e7cc6dc3313a8194f27eb69
2022-12-01 11:53:36 -06:00
George Joseph dd76b53ca6 pjsip_transport_events: Fix possible use after free on transport
It was possible for a module that registered for transport monitor
events to pass in a pjsip_transport that had already been freed.
This caused pjsip_transport_events to crash when looking up the
monitor for the transport.  The fix is a two pronged approach.

1. We now increment the reference count on pjsip_transports when we
create monitors for them, then decrement the count when the
transport is going to be destroyed.

2. There are now APIs to register and unregister monitor callbacks
by "transport key" which is a string concatenation of the remote ip
address and port.  This way the module needing to monitor the
transport doesn't have to hold on to the transport object itself to
unregister.  It just has to save the transport_key.

* Added the pjsip_transport reference increment and decrement.

* Changed the internal transport monitor container key from the
  transport->obj_name (which may not be unique anyway) to the
  transport_key.

* Added a helper macro AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR() that
  fills a buffer with the transport_key using a passed-in
  pjsip_transport.

* Added the following functions:
  ast_sip_transport_monitor_register_key
  ast_sip_transport_monitor_register_replace_key
  ast_sip_transport_monitor_unregister_key
  and marked their non-key counterparts as deprecated.

* Updated res_pjsip_pubsub and res_pjsip_outbound_register to use
  the new "key" monitor functions.

NOTE: res_pjsip_registrar also uses the transport monitor
functionality but doesn't have a persistent object other than
contact to store a transport key.  At this time, it continues to
use the non-key monitor functions.

ASTERISK-30244

Change-Id: I1a20baf2a8643c272dcf819871d6c395f148f00b
2022-12-01 11:10:27 -06:00
Jaco Kroon ed798d30f8 Build system: Avoid executable stack.
Found in res_geolocation, but I believe others may have similar issues,
thus not linking to a specific issue.

Essentially gcc doesn't mark the stack for being non-executable unless
it's compiling the source, this informs ld via gcc to mark the object as
not requiring an executable stack (which a binary blob obviously
doesn't).

ASTERISK-30321

Change-Id: I71bcc2fd1fe0c82a28b3257405d6f2b566fd9bfc
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2022-11-21 08:30:56 -06:00
Joshua C. Colp e50b2bfad9 res_agi: Respect "transmit_silence" option for "RECORD FILE".
The "RECORD FILE" command in res_agi has its own
implementation for actually doing the recording. This
has resulted in it not actually obeying the option
"transmit_silence" when recording.

This change causes it to now send silence if the
option is enabled.

ASTERISK-30314

Change-Id: Ib3a85601ff35d1b904f836691bad8a4b7e957174
2022-11-16 06:45:40 -05:00
Mike Bradeen 1a72025c35 res_pjsip: prevent crash on websocket disconnect
When a websocket (or potentially any stateful connection) is quickly
created then destroyed, it is possible that the qualify thread will
destroy the transaction before the initialzing thread is finished
with it.

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

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

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

ASTERISK-28689

Change-Id: Id050fded2247a04d8f0fc5b8a2cf3e5482cb8cee
2022-10-31 10:10:14 -05:00
Mike Bradeen f107e4fd87 audiohook: add directional awareness
Add enum to allow setting optional direction. If set to only one
direction, only feed matching-direction frames to the associated
slin factory.

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

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

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

ASTERISK-30252

Change-Id: If8716bad334562a5d812be4eeb2a92e4f3be28eb
2022-10-10 09:57:17 -05:00
George Joseph 6e842ae100 res_geolocation: Update wiki documentation
Also added a note to the geolocation.conf.sample file
and added a README to the res/res_geolocation/wiki
directory.

Change-Id: I89c3c5db8c0701b33127993622d5e4f904bddfbc
2022-10-03 06:29:50 -05:00
Asterisk Development Team 3167634a5b Update for certified/18.9-cert2 2022-09-28 07:57:59 -05:00
Asterisk Development Team e21d1e7695 Update CHANGES and UPGRADE.txt for certified/18.9-cert2 2022-09-28 07:47:42 -05:00
Naveen Albert 29495aafce res_pjsip_geolocation: Change some notices to debugs.
If geolocation is not in use for an endpoint, the NOTICE
log level is currently spammed with messages about this,
even though nothing is wrong and these messages provide
no real value. These log messages are therefore changed
to debugs.

ASTERISK-30241 #close

Change-Id: I656b355d812f67cc0f0fdf09b00b0e1458598bb4
2022-09-26 13:18:35 -05:00
George Joseph 002272ad8b res_geolocation: Fix issues exposed by compiling with -O2
Fixed "may be used uninitialized" errors in geoloc_config.c.

ASTERISK-30234

Change-Id: I1ea336bf7abbc16fa59b75720f0db8f1d960b3d4
2022-09-16 08:43:14 -06:00
Mike Bradeen fc2f8368e5 res_pjsip: Add user=phone on From and PAID for usereqphone=yes
Adding user=phone to local-side uri's when user_eq_phone=yes is set for
an endpoint. Previously this would only add the header to the To and R-URI.

ASTERISK-30178

Change-Id: Id3bfb5d225d762e7d2668c023fe09e4541ae8600
2022-09-14 06:54:51 -05:00
George Joseph 3196ba7fcb res_geolocation: Fix segfault when there's an empty element
Fixed a segfault caused by var_list_from_loc_info() encountering
an empty location info element.

Fixed an issue in ast_strsep() where a value with only whitespace
wasn't being preserved.

Fixed an issue in ast_variable_list_from_quoted_string() where
an empty value was considered a failure.

ASTERISK-30215
Reported by: Dan Cropp

Change-Id: Ieca64e061a6d9298f0196c694b60d986ef82613a
2022-09-13 09:50:59 -05:00
George Joseph aeb465fdf1 res_geolocation: Add two new options to GEOLOC_PROFILE
Added an 'a' option to the GEOLOC_PROFILE function to allow
variable lists like location_info_refinement to be appended
to instead of replacing the entire list.

Added an 'r' option to the GEOLOC_PROFILE function to resolve all
variables before a read operation and after a Set operation.

Added a few missing parameters to the ones allowed for writing
with GEOLOC_PROFILE.

Fixed a bug where calling GEOLOC_PROFILE to read a parameter
might actually update the profile object.

Cleaned up XML documentation a bit.

ASTERISK-30190

Change-Id: I75f541db43345509a2e86225bfa4cf8e242e5b6c
2022-09-10 11:42:27 -06:00
George Joseph 22fc2b58d2 res_geolocation: Allow location parameters on the profile object
You can now specify the location object's format, location_info,
method, location_source and confidence parameters directly on
a profile object for simple scenarios where the location
information isn't common with any other profiles.  This is
mutually exclusive with setting location_reference on the
profile.

Updated appdocsxml.dtd to allow xi:include in a configObject
element.  This makes it easier to link to complete configOptions
in another object.  This is used to add the above fields to the
profile object without having to maintain the option descriptions
in two places.

ASTERISK-30185

Change-Id: Ifd5f05be0a76f0a6ad49fa28d17c394027677569
2022-09-10 11:42:27 -06:00
George Joseph d6f6a30a49 res_geolocation: Add profile parameter suppress_empty_ca_elements
Added profile parameter "suppress_empty_ca_elements" that
will cause Civic Address elements that are empty to be
suppressed from the outgoing PIDF-LO document.

Fixed a possible SEGV if a sub-parameter value didn't have a
value.

ASTERISK-30177

Change-Id: I924ccc5aa2f45110a3155b22e53dfaf3ef2092dd
2022-09-10 11:42:24 -06:00
George Joseph e9ae638978 res_geolocation: Add built-in profiles
The trigger to perform outgoing geolocation processing is the
presence of a geoloc_outgoing_call_profile on an endpoint. This
is intentional so as to not leak location information to
destinations that shouldn't receive it.   In a totally dynamic
configuration scenario however, there may not be any profiles
defined in geolocation.conf.  This makes it impossible to do
outgoing processing without defining a "dummy" profile in the
config file.

This commit adds 4 built-in profiles:
  "<prefer_config>"
  "<discard_config>"
  "<prefer_incoming>"
  "<discard_incoming>"
The profiles are empty except for having their precedence
set and can be set on an endpoint to allow processing without
entries in geolocation.conf.  "<discard_config>" is actually the
best one to use in this situation.

ASTERISK-30182

Change-Id: I1819ccfa404ce59802a3a07ad1cabed60fb9480a
2022-09-10 11:41:07 -06:00
George Joseph 1bb1d3b5ef res_geolocation: Address user issues, remove complexity, plug leaks
* Added processing for the 'confidence' element.
* Added documentation to some APIs.
* removed a lot of complex code related to the very-off-nominal
  case of needing to process multiple location info sources.
* Create a new 'ast_geoloc_eprofile_to_pidf' API that just takes
  one eprofile instead of a datastore of multiples.
* Plugged a huge leak in XML processing that arose from
  insufficient documentation by the libxml/libxslt authors.
* Refactored stylesheets to be more efficient.
* Renamed 'profile_action' to 'profile_precedence' to better
  reflect it's purpose.
* Added the config option for 'allow_routing_use' which
  sets the value of the 'Geolocation-Routing' header.
* Removed the GeolocProfileCreate and GeolocProfileDelete
  dialplan apps.
* Changed the GEOLOC_PROFILE dialplan function as follows:
  * Removed the 'profile' argument.
  * Automatically create a profile if it doesn't exist.
  * Delete a profile if 'inheritable' is set to no.
* Fixed various bugs and leaks
* Updated Asterisk WiKi documentation.

ASTERISK-30167

Change-Id: If38c23f26228e96165be161c2f5e849cb8e16fa0
2022-09-10 11:32:44 -06:00
George Joseph f08a172893 Geolocation: Wiki Documentation
Change-Id: I68ba22db0a69d9e2eabcc2141b48a2395f7f1a23
2022-09-10 12:22:12 -05:00
Mike Bradeen a7c71b1b71 alembic: add missing ps_endpoints columns
The following required columns were missing,
now added to the ps_endpoints table:

incoming_call_offer_pref
outgoing_call_offer_pref
stir_shaken_profile

ASTERISK-29453

Change-Id: I5cf565edf30195844d6acbc1e1de8c5f0d837568
2022-09-09 11:35:09 -05:00
Mike Bradeen b10cfb34e9 CI: Fixing path issue on venv check
ASTERISK-26826

Change-Id: I07388d16f74452cebc9c981f99044eb6b77df792
2022-08-31 15:56:12 -05:00
Mike Bradeen 7b7ba8cbd1 CI: use Python3 virtual environment
Requires Python3 testsuite changes

ASTERISK-26826

Change-Id: I92ec7dec751ad455503a584d6e860db88c56d6bc
2022-08-30 11:38:06 -06:00
George Joseph 5e3a2dd5b0 pjsip_config.xml: Fix omissions caused by wrong cherry-pick order
When cherry-picking geolocation prerequisites to the certified/18.9
branch, the commit that moved res_pjsip documentation to separate
XML files was cherry-picked after other that assumed it was
already there.  This caused a few configuration options to be
dropped from the XML and prevented res_stir_shaken and some
pjsip transports to fail to load.

Those entries are now in their correct spots in pjsip_config.xml.

A housekeeping change was also made to both pjsip_config.xml and
pjsip_manager.xml to add stylesheet and namespace info.

Change-Id: I0ea2eb191e006673f4fa3caafb2edbc92b3e1214
2022-07-14 05:13:19 -06:00
George Joseph 336209b319 geoloc_eprofile.c: Fix setting of loc_src in set_loc_src()
line 196:    loc_src = '\0';
should have been
line 196:    *loc_src = '\0';

The issue was caught by the gcc optimizer complaining that
loc_src had a zero length because the pointer itself was being
set to NULL instead of the _contents_ of the pointer being set
to the NULL terminator.

ASTERISK-30138
Reported-by: Sean Bright

Change-Id: Id247be113cc8510f043ca053d5b4f5f3d32acd29
2022-07-13 13:43:53 -05:00
George Joseph b17e95a792 Geolocation: chan_pjsip Capability Preview
This commit adds res_pjsip_geolocation which gives chan_pjsip
the ability to use the core geolocation capabilities.

This commit message is intentionally short because this isn't
a simple capability.  See the documentation at
https://wiki.asterisk.org/wiki/display/AST/Geolocation
for more information.

THE CAPABILITIES IMPLEMENTED HERE MAY CHANGE BASED ON
USER FEEDBACK!

ASTERISK-30128

Change-Id: Ie2e2bcd87243c2cfabc43eb823d4427c7086f4d9
2022-07-12 06:20:21 -06:00
George Joseph 547e3590ef Geolocation: Core Capability Preview
This commit adds res_geolocation which creates the core capabilities
to manipulate Geolocation information on SIP INVITEs.

An upcoming commit will add res_pjsip_geolocation which will
allow the capabilities to be used with the pjsip channel driver.

This commit message is intentionally short because this isn't
a simple capability.  See the documentation at
https://wiki.asterisk.org/wiki/display/AST/Geolocation
for more information.

THE CAPABILITIES IMPLEMENTED HERE MAY CHANGE BASED ON
USER FEEDBACK!

ASTERISK-30127

Change-Id: Ibfde963121b1ecf57fd98ee7060c4f0808416303
2022-07-12 06:20:21 -06:00
George Joseph cc26b1d52b Geolocation: Base Asterisk Prereqs
* Added ast_variable_list_from_quoted_string()
  Parse a quoted string into an ast_variable list.

* Added ast_str_substitute_variables_full2()
  Perform variable/function/expression substitution on an ast_str.

* Added ast_strsep_quoted()
  Like ast_strsep except you can specify a specific quote character.
  Also added unit test.

* Added ast_xml_find_child_element()
  Find a direct child element by name.

* Added ast_xml_doc_dump_memory()
  Dump the specified document to a buffer

* ast_datastore_free() now checks for a NULL datastore
  before attempting to destroy it.

Change-Id: I5dcefed2f5f93a109e8b489e18d80d42e45244ec
2022-07-12 06:20:21 -06:00
George Joseph 4e604f03a7 xml.c, config,c: Add stylesheets and variable list string parsing
Added functions to open, close, and apply XML Stylesheets
to XML documents.  Although the presence of libxslt was already
being checked by configure, it was only happening if xmldoc was
enabled.  Now it's checked regardless.

Added ability to parse a string consisting of comma separated
name/value pairs into an ast_variable list.  The reverse of
ast_variable_list_join().

Change-Id: I1e1d149be22165a1fb8e88e2903a36bba1a6cf2e
2022-07-12 06:20:21 -06:00
George Joseph 157a9e64c1 core: Config and XML tweaks needed for geolocation
Added:

Replace a variable in a list:
int ast_variable_list_replace_variable(struct ast_variable **head,
    struct ast_variable *old, struct ast_variable *new);
Added test as well.

Create a "name=value" string from a variable list:
'name1="val1",name2="val2"', etc.
struct ast_str *ast_variable_list_join(
    const struct ast_variable *head, const char *item_separator,
    const char *name_value_separator, const char *quote_char,
    struct ast_str **str);
Added test as well.

Allow the name of an XML element to be changed.
void ast_xml_set_name(struct ast_xml_node *node, const char *name);

Change-Id: I330a5f63dc0c218e0d8dfc0745948d2812141ccb
2022-07-12 06:20:21 -06:00
George Joseph 4afe2355be res_pjsip: Add utils for checking media types
Added two new functions to assist checking media types...

* ast_sip_are_media_types_equal compares two pjsip_media_types.
* ast_sip_is_media_type_in tests if one media type is in a list
  of others.

Added static definitions for commonly used media types to
res_pjsip.h.

Changed several modules to use the new functions and static
definitions.

ASTERISK_29813
(not ready to close)

Change-Id: Ief77675235bd3bf00a6b095d4673fd878d0801b9
2022-07-12 06:20:21 -06:00
George Joseph 2ff2ccedc6 bundled_pjproject: Add more support for multipart bodies
Adding upstream patch for pull request...
https://github.com/pjsip/pjproject/pull/2920
---------------------------------------------------------------

sip_inv:  Additional multipart support (#2919)

sip_inv.c:inv_check_sdp_in_incoming_msg() deals with multipart
message bodies in rdata correctly. In the case where early media is
involved though, the existing sdp has to be retrieved from the last
tdata sent in this transaction. This, however, always assumes that
the sdp sent is in a non-multipart body. While there's a function
to retrieve the sdp from multipart and non-multpart rdata bodies,
no similar function for tdata exists.  So...

* The existing pjsip_rdata_get_sdp_info2 was refactored to
  find the sdp in any body, multipart or non-multipart, and
  from either an rdata or tdata.  The new function is
  pjsip_get_sdp_info.  This new function detects whether the
  pjsip_msg->body->data is the text representation of the sdp
  from an rdata or an existing pjmedia_sdp_session object
  from a tdata, or whether pjsip_msg->body is a multipart
  body containing either of the two sdp formats.

* The exsting pjsip_rdata_get_sdp_info and pjsip_rdata_get_sdp_info2
  functions are now wrappers that get the body and Content-Type
  header from the rdata and call pjsip_get_sdp_info.

* Two new wrappers named pjsip_tdata_get_sdp_info and
  pjsip_tdata_get_sdp_info2 have been created that get the body
  from the tdata and call pjsip_get_sdp_info.

* inv_offer_answer_test.c was updated to test multipart scenarios.

ASTERISK-29804

Change-Id: I483c7c3d413280c9e247a96ad581278347f9c71b
2022-07-12 06:20:21 -06:00
George Joseph 23bc002815 bundled_pjproject: Add additional multipart search utils
Added the following APIs:
pjsip_multipart_find_part_by_header()
pjsip_multipart_find_part_by_header_str()
pjsip_multipart_find_part_by_cid_str()
pjsip_multipart_find_part_by_cid_uri()

Change-Id: I6aee3dcf59eb171f93aae0f0564ff907262ef40d
2022-07-12 06:20:21 -06:00
George Joseph d3d5253155 bundled_pjproject: Create generic pjsip_hdr_find functions
pjsip_msg_find_hdr(), pjsip_msg_find_hdr_by_name(), and
pjsip_msg_find_hdr_by_names() require a pjsip_msg to be passed in
so if you need to search a header list that's not in a pjsip_msg,
you have to do it yourself.  This commit adds generic versions of
those 3 functions that take in the actual header list head instead
of a pjsip_msg so if you need to search a list of headers in
something like a pjsip_multipart_part, you can do so easily.

Change-Id: I6f2c127170eafda48e5e0d5d4d187bcd52b4df07
2022-07-12 06:20:21 -06:00
George Joseph 39b9607d4d Makefile: Allow XML documentation to exist outside source files
Moved the xmldoc build logic from the top-level Makefile into
its own script "make_xml_documentation" in the build_tools
directory.

Created a new utility script "get_sourceable_makeopts", also in
the build_tools directory, that dumps the top-level "makeopts"
file in a format that can be "sourced" from shell sscripts.
This allows scripts to easily get the values of common make
build variables such as the location of the GREP, SED, AWK, etc.
utilities as well as the AST* and library *_LIB and *_INCLUDE
variables.

Besides moving logic out of the Makefile, some optimizations
were done like removing "third-party" from the list of
subdirectories to be searched for documentation and changing some
assignments from "=" to ":=" so they're only evaluated once.
The speed increase is noticeable.

The makeopts.in file was updated to include the paths to
REALPATH and DIRNAME.  The ./conifgure script was setting them
but makeopts.in wasn't including them.

So...

With this change, you can now place documentation in any"c"
source file AND you can now place it in a separate XML file
altogether.  The following are examples of valid locations:

res/res_pjsip.c
    Using the existing /*** DOCUMENTATION ***/ fragment.

res/res_pjsip/pjsip_configuration.c
    Using the existing /*** DOCUMENTATION ***/ fragment.

res/res_pjsip/pjsip_doc.xml
    A fully-formed XML file.  The "configInfo", "manager",
    "managerEvent", etc. elements that would be in the "c"
    file DOCUMENTATION fragment should be wrapped in proper
    XML.  Example for "somemodule.xml":

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE docs SYSTEM "appdocsxml.dtd">
    <docs>
        <configInfo>
        ...
        </configInfo>
    </docs>

It's the "appdocsxml.dtd" that tells make_xml_documentation
that this is a documentation XML file and not some other XML file.
It also allows many XML-capable editors to do formatting and
validation.

Other than the ".xml" suffix, the name of the file is not
significant.

As a start... This change also moves the documentation that was
in res_pjsip.c to 2 new XML files in res/res_pjsip:
pjsip_config.xml and pjsip_manager.xml.  This cut the number of
lines in res_pjsip.c in half. :)

Change-Id: I486c16c0b5a44d7a8870008e10c941fb19b71ade
2022-07-12 05:57:21 -06:00
Naveen Albert bdcaf87bf2 documentation: Adds missing default attributes.
The configObject tag contains a default attribute which
allows the default value to be specified, if applicable.
This allows for the default value to show up specially on
the wiki in a way that is clear to users.

There are a couple places in the tree where default values
are included in the description as opposed to as attributes,
which means these can't be parsed specially for the wiki.
These are changed to use the attribute instead of being
included in the text description.

ASTERISK-29898 #close

Change-Id: I9d7ea08f50075f41459ea7b76654906b674ec755
2022-07-12 05:55:50 -06:00
Sean Bright 65a63e534a res_pjsip.c: Correct minor typos in 'realm' documentation.
Change-Id: I886936b808def5540d40071321e72f6bfa19063a
2022-07-12 05:53:57 -06:00
Kevin Harwell 2074cf07f6 res_pjsip: allow TLS verification of wildcard cert-bearing servers
Rightly the use of wildcards in certificates is disallowed in accordance
with RFC5922. However, RFC2818 does make some allowances with regards to
their use when using subject alt names with DNS name types.

As such this patch creates a new setting for TLS transports called
'allow_wildcard_certs', which when it and 'verify_server' are both enabled
allows DNS name types, as well as the common name that start with '*.'
to match as a wildcard.

For instance: *.example.com
will match for: foo.example.com

Partial matching is not allowed, e.g. f*.example.com, foo.*.com, etc...
And the starting wildcard only matches for a single level.

For instance: *.example.com
will NOT match for: foo.bar.example.com

The new setting is disabled by default.

ASTERISK-30072 #close

Change-Id: If0be3fdab2e09c2a66bb54824fca406ebaac3da4
2022-06-15 15:41:31 -05:00
George Joseph 8d4a298cd4 GCC12: Fixes for 18+. state_id_by_topic comparing wrong value
GCC 12 caught an issue in state_id_by_topic where we were
checking a pointer for NULL instead of the contents of
the pointer for '\0'.

ASTERISK-30044

Change-Id: Ia0b04d4fff45c92acb7f07132a33622fa341148e
2022-05-09 08:32:17 -05:00
George Joseph c0612ccc28 GCC12: Fixes for 16+
Most issues were in stringfields and had to do with comparing
a pointer to an constant/interned string with NULL.  Since the
string was a constant, a pointer to it could never be NULL so
the comparison was always "true".  gcc now complains about that.

There were also a few issues where determining if there was
enough space for a memcpy or s(n)printf which were fixed
by defining some of the involved variables as "volatile".

There were also a few other miscellaneous fixes.

ASTERISK-30044

Change-Id: Ia081ca1bcfb329df6487c4660aaf1944309eb570
2022-05-04 13:30:35 -05:00
Asterisk Development Team 184c95dc01 Update for certified/18.9-cert1 2022-04-28 07:44:31 -05:00
Ben Ford f3b0b4f099 res_pjsip_stir_shaken.c: Fix enabled when not configured.
There was an issue with the conditional where STIR/SHAKEN would be
enabled even when not configured. It has been changed to ensure that if
a profile does not exist and stir_shaken is not set in pjsip.conf, then
the conditional will return from the function without performing
STIR/SHAKEN operations.

ASTERISK-30024

Change-Id: I41286a3d35b033ccbfbe4129427a62cb793a86e6
(cherry picked from commit 40f4268f2d)
2022-04-26 11:54:15 -05:00
Ben Ford 46f5a9c1ae AST-2022-002 - res_stir_shaken/curl: Add ACL checks for Identity header.
Adds a new configuration option, stir_shaken_profile, in pjsip.conf that
can be specified on a per endpoint basis. This option will reference a
stir_shaken_profile that can be configured in stir_shaken.conf. The type
of this option must be 'profile'. The stir_shaken option can be
specified on this object with the same values as before (attest, verify,
on), but it cannot be off since having the profile itself implies wanting
STIR/SHAKEN support. You can also specify an ACL from acl.conf (along
with permit and deny lines in the object itself) that will be used to
limit what interfaces Asterisk will attempt to retrieve information from
when reading the Identity header.

ASTERISK-29476

Change-Id: I87fa61f78a9ea0cd42530691a30da3c781842406
2022-04-14 17:15:00 -05:00
Ben Ford 4e2d36ebdb AST-2022-001 - res_stir_shaken/curl: Limit file size and check start.
Put checks in place to limit how much we will actually download, as well
as a check for the data we receive at the start to ensure it begins with
what we would expect a certificate to begin with.

ASTERISK-29872

Change-Id: Ifd3c6b8bd52b8b6192a04166ccce4fc8a8000b46
2022-04-14 16:57:07 -05:00
Joshua C. Colp 77adb9998f func_odbc: Add SQL_ESC_BACKSLASHES dialplan function.
Some databases depending on their configuration using backslashes
for escaping. When combined with the use of ' this can result in
a broken func_odbc query.

This change adds a SQL_ESC_BACKSLASHES dialplan function which can
be used to escape the backslashes.

This is done as a dialplan function instead of being always done
as some databases do not require this, and always doing it would
result in incorrect data being put into the database.

ASTERISK-29838

Change-Id: I152bf34899b96ddb09cca3e767254d8d78f0c83d
2022-04-14 12:09:13 -05:00
Kevin Harwell b369ac56e3 AST-2022-006: pjproject - unconstrained malformed multipart SIP message
ASTERISK-29945 #close

Change-Id: Ic58957afc453195d53c2bd25c905df3d91d1abe6
2022-03-04 12:48:32 -06:00
Kevin Harwell 4db5e3a498 AST-2022-005: pjproject - undefined behavior after freeing a dialog set
ASTERISK-29945 #close

Change-Id: Ia8ce6d82b115c82c1138747c72a0adcaa42b718c
2022-03-04 12:45:09 -06:00
Kevin Harwell c22deb51c3 AST-2022-004: pjproject - possible integer underflow on STUN message
ASTERISK-29945 #close

Change-Id: I721cd254e4f8aa6d3a97a37529cca53519694c54
2022-03-04 12:37:13 -06:00
Asterisk Development Team b211cb932a Update for certified/18.9-cert1-rc1 2022-01-21 12:26:53 -05:00
Mike Bradeen fefe1cac3a Asterisk Certified 18.9 Preparation
* Updated .gitreview default branch to certified/18.9
* Updated .version to certified/18.9
* Set all extended support modules to be disabled by default
* fixed MODULEINFO order introduced by default script on wiki

Change-Id: Id12804325c31b1112b6c559fa97c8a6401c051b3
2022-01-17 12:17:44 -07:00
Sean Bright 059eca1546 say.c: Prevent erroneous failures with 'say' family of functions.
A regression was introduced in ASTERISK~29531 that caused 'say'
functions to fail with file lists that would previously have
succeeded. This caused affected channels to hang up where previously
they would have continued.

We now explicitly check for the empty string to restore the previous
behavior.

ASTERISK-29859 #close

Change-Id: Ia2e5769868e2792313c2d7c07996efe009c6f8d5
(cherry picked from commit 3fd47840c9)
2022-01-17 12:46:28 -06:00
Sean Bright 5274bfdc07 say.c: Honor requests for DTMF interruption.
SayAlpha, SayAlphaCase, SayDigits, SayMoney, SayNumber, SayOrdinal,
and SayPhonetic all claim to allow DTMF interruption if the
SAY_DTMF_INTERRUPT channel variable is set to a truthy value, but we
are failing to break out of a given 'say' application if DTMF actually
occurs.

ASTERISK-29816 #close

Change-Id: I6a96e0130560831d2cb45164919862b9bcb6287e
(cherry picked from commit 4fe94bab09)
2022-01-17 12:45:36 -06:00
Joshua C. Colp c1129fdd8c bridge: Unlock channel during Local peer check.
It's not safe to keep the channel locked while locking
the peer Local channel, as it can result in a deadlock.

This change unlocks it during this time but keeps the
bridge locked to ensure nothing changes about the bridge.

ASTERISK-29821

Change-Id: Ib68eb7037e5a479bcc2aceee77337cdde1fbdde6
(cherry picked from commit d83a46869e)
2022-01-13 13:11:33 -06:00
Asterisk Development Team 85601849c6 Update for 18.9.0 2021-12-09 11:44:54 -05:00
Asterisk Development Team 82637aaa18 Update for 18.9.0-rc1 2021-12-02 13:26:18 -05:00
Asterisk Development Team 868d2d5e53 Update CHANGES and UPGRADE.txt for 18.9.0 2021-12-02 12:59:24 -05:00
Alexander Traud f946b92553 progdocs: Fix for Doxygen, the hidden parts.
ASTERISK-29779

Change-Id: If338163488498f65fa7248b60e80299c0a928e4b
2021-12-02 10:38:23 -06:00
Alexander Traud 751bbf4b97 progdocs: Fix grouping for latest Doxygen.
Since Doxygen 1.8.16, a special comment block is required. Otherwise
(pure C comment), the group command is ignored. Additionally, several
unbalanced group commands were fixed.

ASTERISK-29732

Change-Id: I4687857b9d56e6f44fd440b73af156691660202e
2021-12-02 10:25:52 -06:00
Naveen Albert bcb7aee723 documentation: Standardize examples
Most examples in the XML documentation use the
example tag to demonstrate examples, which gets
parsed specially in the Wiki to make it easier
to follow for users.

This fixes a few modules to use the example
tag instead of vanilla para tags to bring them
in line with the standard syntax.

ASTERISK-29777 #close

Change-Id: I9acb6cc5faf1d220e73c6dd28592371d768d279b
2021-11-30 11:49:43 -05:00
Sean Bright 04ac4fe509 config.c: Prevent UB in ast_realtime_require_field.
A backend's implementation of the realtime 'require' function may call
va_arg() and then fail, leaving the va_list in an undefined
state. Pass a copy of the va_list instead.

ASTERISK-29771 #close

Change-Id: I555565a72af84e96d49f62fe8cb66ba5a78461f4
2021-11-30 09:48:07 -06:00
Naveen Albert 70cdb0f9a8 app_voicemail: Refactor email generation functions
Refactors generic functions used for email generation
into utils.c so that they can be used by multiple
modules, including app_voicemail and app_minivm,
to avoid code duplication.

ASTERISK-29715 #close

Change-Id: I1de0ed3483623e9599711129edc817c45ad237ee
2021-11-30 09:40:14 -06:00
Alexander Traud b290bb1251 stir/shaken: Avoid a compiler extension of GCC.
ASTERISK-29776

Change-Id: I86e5eca66fb775a5744af0c929fb269e70575a73
2021-11-29 09:48:09 -06:00
Alexander Traud 858c9e1d80 chan_misdn: Fix for Doxygen.
ASTERISK-29764

Change-Id: I6e5466cce03e25695c5c7d8b68c305184dcf5375
2021-11-29 09:04:26 -06:00
Alexander Traud 422f5389f6 progdocs: Remove outdated references in doxyref.h.
ASTERISK-29773

Change-Id: Ica93160d9158cc0e80c5fda829b80d1b49a6b9b9
2021-11-29 08:53:58 -06:00
Alexander Traud 31e385bebb xmldoc: Fix for Doxygen.
ASTERISK-29765

Change-Id: I654ba0debe8351038d4433716434a09370f04c9d
2021-11-29 08:49:55 -06:00
Jaco Kroon 89237be105 logger: use __FUNCTION__ instead of __PRETTY_FUNCTION__
This avoids a few long-name overflows, at the cost of less instructive
names in the case of C++ (specifically overloaded functions and class
methods).  This in turn is offset against the fact that we're logging
the filename and line numbers in any case.

Change-Id: I54101a0bb5f8cb9ef63ec12c5e0d4c8edafff9ed
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-11-22 02:12:13 -05:00
Mike Bradeen ea941032ff astobj2.c: Fix core when ref_log enabled
In the AO2_ALLOC_OPT_LOCK_NOLOCK case the referenced obj
structure is freed, but is then referenced later if ref_log is
enabled. The change is to store the obj->priv_data.options value
locally and reference it instead of the value from the freed obj

ASTERISK-29730

Change-Id: I60cc5dc1f5a4330e7ad56976fc38a42de0ab6072
2021-11-19 09:54:18 -06:00
Alexander Traud 3f86c95cf5 channels: Fix for Doxygen.
ASTERISK-29762

Change-Id: Ia8811ac12b93ff8c18164699c6fbc604cb0a23f7
2021-11-19 09:09:45 -06:00
Joshua C. Colp 7d4e37a180 bridge: Deny full Local channel pair in bridge.
Local channels are made up of two pairs - the 1 and 2
sides. When a frame goes in one side, it comes out the
other. Back and forth. When both halves are in a
bridge this creates an infinite loop of frames.

This change makes it so that bridging no longer
allows both of these sides to exist in the same
bridge.

ASTERISK-29748

Change-Id: I29928b6de87cd9be996a77daccefd7c360fef651
2021-11-19 08:42:30 -06:00
Naveen Albert ca2e13e18f res_tonedetect: Add call progress tone detection
Makes basic call progress tone detection available
in a tech-agnostic manner with the addition of the
ToneScan application. This can determine if the channel
has encountered a busy signal, SIT tones, dial tone,
modem, fax machine, etc. A few basic async progress
tone detect options are also added to the TONE_DETECT
function.

ASTERISK-29720 #close

Change-Id: Ia02437e0450473031e294798b8cb421fb8f24e90
2021-11-19 08:10:52 -06:00
Boris P. Korzun 70b14f3eda rtp_engine: Add type field for JSON RTCP Report stasis messages
ASTERISK-29727 #close

Change-Id: I2eca8aeb591cb63ac2238d08eab662367453cb82
2021-11-19 07:09:58 -06:00
Alexander Traud 783b775946 odbc: Fix for Doxygen.
ASTERISK-29754

Change-Id: Ia09eb68d283d201d9a6fbeccfc0efe83fe0502a5
2021-11-18 17:04:31 -06:00
Alexander Traud c549eda0a7 parking: Fix for Doxygen.
ASTERISK-29753

Change-Id: I7a61974584f6169502e6860fc711919fe7bbfaa7
2021-11-18 16:25:23 -06:00
Alexander Traud b4eebfa191 ari-stubs: Avoid 'is' as comparism with an literal.
Python 3.9.7 gave a syntax warning.

Change-Id: I3e3a982fe720726bc0015bcdb0e638a626ec89d4
2021-11-18 16:24:26 -06:00
Alexander Traud b5962fe528 frame: Fix for Doxygen.
ASTERISK-29755

Change-Id: I8240013ec3db0669c0acf67e26bf6c9cbb5b72af
2021-11-18 16:13:03 -06:00
Alexander Traud 5b5a9ea4f0 res_ari: Fix for Doxygen.
ASTERISK-29756

Change-Id: I2f1c1eea1c902492b77b74de9950f20ebbb7e758
2021-11-18 16:02:22 -06:00
Alexander Traud e27b91d542 channel: Fix for Doxygen.
ASTERISK-29751

Change-Id: Ie04da5029c57ebee44733bdf05013156abe80176
2021-11-18 14:48:34 -06:00
Alexander Traud 53610679bf BuildSystem: Consistently allow 'ye' even for Jansson.
Furthermore, consistently use not 'No' but ':' for non-existent file
paths. Finally, use the same pattern for checking file paths:
  a)  = ":"
  b) != "x:"

Change-Id: I0c80c76d2cc98b0e5c859131290f4e3141a1a544
2021-11-18 14:28:37 -06:00
Alexander Traud 6988386234 stasis: Fix for Doxygen.
ASTERISK-29750

Change-Id: Iea50173e785b2e9d49bc24c0af7111cfd96d44a9
2021-11-18 13:25:54 -06:00
Alexander Traud e7d5db1471 app: Fix for Doxygen.
ASTERISK-29752

Change-Id: If40cbd01d47a6cfd620b18206dedb8460216c8af
2021-11-18 13:15:00 -06:00
Alexander Traud 31c26fcbc6 res_xmpp: Fix for Doxygen.
ASTERISK-29749

Change-Id: I7885793b63bdeaa883e76edb899bbba9660eb1c5
2021-11-18 13:00:51 -06:00
Alexander Traud 026c6d51b1 addons: Fix for Doxygen.
ASTERISK-29742

Change-Id: Ie752cb9638ced1ebe3a55d710c6c18ef6bd0aafc
2021-11-18 12:47:24 -06:00
Alexander Traud bae495601a res_pjsip: Fix for Doxygen.
ASTERISK-29747

Change-Id: Ic7a1e9453f805a6264fe86c96b7d18b87b376084
2021-11-18 12:46:12 -06:00
Alexander Traud cb043633d4 chan_iax2: Fix for Doxygen.
ASTERISK-29737

Change-Id: I282003cc553989fd5c19ceeac9e478fa4ee06cec
2021-11-18 11:55:31 -06:00
Alexander Traud 42055f4a65 bridges: Fix for Doxygen.
ASTERISK-29743

Change-Id: I6e1bbbaa5875e19994a328ab40a5d429c6010e8b
2021-11-18 11:18:58 -06:00
Alexander Traud 1a9df88d98 tests: Fix for Doxygen.
ASTERISK-29741

Change-Id: I012d72b237bda2ef2d0f86307dfc6dc7add4b54b
2021-11-18 10:38:40 -06:00
Alexander Traud 09bac49a01 apps: Fix for Doxygen.
ASTERISK-29740

Change-Id: Icb6fbcfea0a5f1c82caa5001902b6a786adbf307
2021-11-18 10:38:16 -06:00
Alexander Traud 44a9c16e9c progdocs: Avoid 'name' with Doxygen \file.
Fixes four misuses of the parameter 'name'. Additionally, for
consistency and to avoid such an issue in future, those few other
places, which used '\file name', were changed just to '\file'. Then,
Doxygen uses the name of the current file.

ASTERISK-29733

Change-Id: I0c18b4c863c6988b138c77448057349a9ee7052d
2021-11-18 09:20:10 -06:00
Alexander Traud d08792ceba bridge_channel: Fix for Doxygen.
ASTERISK-29736

Change-Id: Ia5370289e6526001a6b52754b533bcea1a9d7e5c
2021-11-18 09:19:16 -06:00
Alexander Traud 57b4956a8a progdocs: Avoid multiple use of section labels.
ASTERISK-29735

Change-Id: I56935e73f7bd1d4ae2721d11040f4835da64b810
2021-11-18 09:17:27 -06:00
Alexander Traud 23b16c5372 progdocs: Use Doxygen \example correctly.
ASTERISK-29734

Change-Id: I83b51e85cd71867645ab3a8a820f8fd1f065abd2
2021-11-18 08:20:45 -06:00
Josh Soref 4bc3dc6543 bridges: Spelling fixes
Correct typos of the following word families:

multiplication
potentially
iteration
interaction
virtual
synthesis
convolve
initializes
overlap

ASTERISK-29714

Change-Id: Ia40f1aca8f2996ab407c6ed9d24cb10a67c6684b
(cherry picked from commit 2a8fb4695e)
2021-11-17 04:37:40 -06:00
Naveen Albert 721026ff37 app_morsecode: Fix deadlock
Fixes a deadlock in app_morsecode caused by locking
the channel twice when reading variables from the
channel. The duplicate lock is simply removed.

ASTERISK-29744 #close

Change-Id: I204000701f123361d7f85e0498fedc90243c75e4
2021-11-16 18:42:02 -06:00
Naveen Albert 1cd2584b27 res_pjsip_callerid: Fix OLI parsing
Fix parsing of ANI2/OLI information, since it was previously
parsing the user, when it should have been parsing other_param.

Also improves the parsing by using pjproject native functions
rather than trying to parse the parameters ourselves like
chan_sip did. A previous attempt at this caused a crash, but
this works correctly now.

ASTERISK-29703 #close

Change-Id: I8f3c79032d9ea1a21d16f8e11f22bd8d887738a1
2021-11-16 15:45:26 -06:00
Naveen Albert 3c4b7cef64 app_read: Fix custom terminator functionality regression
Currently, when the t option is specified with no arguments,
the # character is still treated as a terminator, even though
no character should be treated as a terminator.

This is because a previous regression fix was modified to
remove the use of NULL as a default altogether. However,
NULL and an empty string actually refer to different
arrangements and should be treated differently. NULL is the
default terminator (#), while an empty string removes the
terminator altogether. This is the behavior being used by
the rest of the core.

Additionally, since S_OR catches empty strings as well as
NULL (not intended), this is changed to a ternary operator
instead, which fixes the behavior.

ASTERISK-29705 #close

Change-Id: I9b6b72196dd04f5b1e0ab5aa1b0adf627725e086
2021-11-16 07:15:54 -05:00
Josh Soref 59715a073b utils: Spelling fixes
Correct typos of the following word families:

command-line
immediately
extensions
momentarily
mustn't
numbered
bytes
caching

ASTERISK-29714

Change-Id: I8b2b125c5d4d2f9e87a58515c97468ad47ca44f8
2021-11-16 05:42:40 -06:00
Josh Soref 3685e55673 pbx: Spelling fixes
Correct typos of the following word families:

process
populate
with
africa
accessing
contexts
exercise
university
organizations
withhold
maintaining
independent
rotation
ignore
eventname

ASTERISK-29714

Change-Id: I90eacc5bc3dcf75a9c898cfb85164f37dec08345
2021-11-16 05:41:19 -06:00
Josh Soref 4cf87f6175 rest-api-templates: Spelling fixes
Correct typos of the following word families:

overwritten
descendants

ASTERISK-29714

Change-Id: I2307e35887a3437e50317a4b86f0893f25f9fd3b
2021-11-16 05:39:42 -06:00
Josh Soref c1b21bee6d channels: Spelling fixes
Correct typos of the following word families:

appease
permanently
overriding
residue
silliness
extension
channels
globally
reference
japanese
group
coordinate
registry
information
inconvenience
attempts
cadence
payloads
presence
provisioning
mimics
behavior
width
natively
syslabel
not owning
unquelch
mostly
constants
interesting
active
unequipped
brodmann
commanding
backlogged
without
bitstream
firmware
maintain
exclusive
practically
structs
appearance
range
retransmission
indication
provisional
associating
always
whether
cyrillic
distinctive
components
reinitialized
initialized
capability
switches
occurring
happened
outbound

ASTERISK-29714

Change-Id: Ife52ee89cd2170b684fa651ca72b1cb911a57339
2021-11-16 05:37:45 -06:00
Josh Soref 4fc59ccc92 tests: Spelling fixes
Correct typos of the following word families:

mounting
jitterbuffer
thrashing
original
manipulating
entries
actual
possibility
tasks
options
positives
taskprocessor
other
dynamic
declarative

ASTERISK-29714

Change-Id: I6b94659d045eec5d8d020fce2e9b6e2f593dfeb6
2021-11-16 05:37:26 -06:00
Josh Soref c3978efef6 Makefile: Spelling fixes
Correct typos of the following word families:

libraries
install
overwrite

ASTERISK-29714

Change-Id: I6488814f79186d6c23dfd7b7f9bba0a046126174
2021-11-16 05:36:55 -06:00
Josh Soref 2a8b651b7e contrib: Spelling fixes
Correct typos of the following word families:

standard
increase
comments
valgrind
promiscuous
editing
libtonezone
storage
aggressive
whitespace
russellbryant
consecutive
peternixon

ASTERISK-29714

Change-Id: I9cafbf41b579c9c0c84c81719d2c4f900beec245
2021-11-16 05:36:24 -06:00
Josh Soref 3ac7afe09c formats: Spelling fixes
Correct typos of the following word families:

truncate

ASTERISK-29714

Change-Id: I6507760c72b919873cff7cac22b3781036cd4955
2021-11-16 05:35:56 -06:00
Josh Soref 49ef881eb4 addons: Spelling fixes
Correct typos of the following word families:

definition
listener
fastcopy
logical
registration
classify
documentation
explicitly
dialed
endpoint
elements
arithmetic
might
prepend
byte
terminal
inquiry
skipping
aliases
calling
absent
authentication
transmit
their
ericsson
disconnecting
redir
items
client
adapter
transmitter
existing
satisfies
pointer
interval
supplied

ASTERISK-29714

Change-Id: I8548438246f7b718d88e0b9e0a1eb384bbec88e4
2021-11-16 05:34:37 -06:00
Josh Soref 70af726dcd agi: Spelling fixes
Correct typos of the following word families:

pretend
speech

ASTERISK-29714

Change-Id: I7d0527c329cda07552247ea11b2d7db207a3d87d
2021-11-16 05:34:03 -06:00
Josh Soref c0fafa1863 funcs: Spelling fixes
Correct typos of the following word families:

effectively
emitted
expect
anthony

ASTERISK-29714

Change-Id: Ic16f9ec855bb6d14ec8e170b90af9a36b06d488a
2021-11-15 20:39:10 -06:00
Josh Soref 8fb9588e8c build_tools: Spelling fixes
Correct typos of the following word families:

binutils

ASTERISK-29714

Change-Id: I2f676ab48cd50edc400c43307cb53679e4c09b97
2021-11-15 20:21:27 -06:00
Josh Soref 7a59a9365a menuselect: Spelling fixes
Correct typos of the following word families:

dependency
unless
random
dependencies
delimited
randomly
modules

ASTERISK-29714

Change-Id: I3920603a8dc7c0a1852d2f885e06b1144692d40e
2021-11-15 19:24:48 -06:00
Josh Soref b13acf3ae6 include: Spelling fixes
Correct typos of the following word families:

activities
forward
occurs
unprepared
association
compress
extracted
doubly
callback
prometheus
underlying
keyframe
continue
convenience
calculates
ignorepattern
determine
subscribers
subsystem
synthetic
applies
example
manager
established
result
microseconds
occurrences
unsuccessful
accommodates
related
signifying
unsubscribe
greater
fastforward
itself
unregistering
using
translator
sorcery
implementation
serializers
asynchronous
unknowingly
initialization
determining
category
these
persistent
propagate
outputted
string
allocated
decremented
second
cacheability
destructor
impaired
decrypted
relies
signaling
based
suspended
retrieved
functions
search
auth
considered

ASTERISK-29714

Change-Id: I542ce887a16603f886a915920d5710d4a0a1358d
2021-11-15 19:09:58 -06:00
Josh Soref 135d51e55e doc: Spelling fixes
Correct typos of the following word families:

transparent
roughly

ASTERISK-29714

Change-Id: I2b90c68dfde4aa3f0d58f64f8187465336acb1b3
2021-11-15 17:35:00 -06:00
Josh Soref ae83d927d8 configs: Spelling fixes
Correct typos of the following word families:

password
excludes
undesirable
checksums
through
screening
interpreting
database
causes
initiation
member
busydetect
defined
severely
throughput
recognized
counter
require
indefinitely
accounts

ASTERISK-29714

Change-Id: Ie8f2a7b274a162dd627ee6a2165f5e8a3876527e
2021-11-15 16:21:18 -06:00
Josh Soref dcf492e7b6 res: Spelling fixes
Correct typos of the following word families:

identifying
structures
actcount
initializer
attributes
statement
enough
locking
declaration
userevent
provides
unregister
session
execute
searches
verification
suppressed
prepared
passwords
recipients
event
because
brief
unidentified
redundancy
character
the
module
reload
operation
backslashes
accurate
incorrect
collision
initializing
instance
interpreted
buddies
omitted
manually
requires
queries
generator
scheduler
configuration has
owner
resource
performed
masquerade
apparently
routable

ASTERISK-29714

Change-Id: I88485116d2c59b776aa2e1f8b4ce8239a21decda
2021-11-15 15:41:51 -06:00
Josh Soref ccfebc3cfc codecs: Spelling fixes
Correct typos of the following word families:

voiced
denumerator
codeword
upsampling
constructed
residual
subroutine
conditional
quantizing
courtesy
number

ASTERISK-29714

Change-Id: I471fb8086a5277d8f05047fedee22cfa97a4252d
2021-11-15 15:28:51 -06:00
Josh Soref 4019a93edf main: Spelling fixes
Correct typos of the following word families:

analysis
nuisance
converting
although
transaction
desctitle
acquire
update
evaluate
thousand
this
dissolved
management
integrity
reconstructed
decrement
further on
irrelevant
currently
constancy
anyway
unconstrained
featuregroups
right
larger
evaluated
encumbered
languages
digits
authoritative
framing
blindxfer
tolerate
traverser
exclamation
perform
permissions
rearrangement
performing
processing
declension
happily
duplicate
compound
hundred
returns
elicit
allocate
actually
paths
inheritance
atxferdropcall
earlier
synchronization
multiplier
acknowledge
across
against
thousands
joyous
manipulators
guaranteed
emulating
soundfile

ASTERISK-29714

Change-Id: I926ba4b11e9f6dd3fdd93170ab1f9b997910be70
2021-11-15 15:28:45 -06:00
Josh Soref 998ad0e179 CREDITS: Spelling fixes
Correct typos of the following word families:

contributors

ASTERISK-29714

Change-Id: I6f46dae8bf8125a21ce8ff318380b2b412d9d2f9
2021-11-15 15:28:18 -06:00
Josh Soref e7b1dcf769 apps: Spelling fixes
Correct typos of the following word families:

simultaneously
administrator
directforward
attachfmt
dailplan
automatically
applicable
nouns
explicit
outside
sponsored
attachment
audio
spied
doesn't
counting
encoded
implements
recursively
emailaddress
arguments
queuerules
members
priority
output
advanced
silencethreshold
brazilian
debugging
argument
meadmin
formatting
integrated
sneakiness

ASTERISK-29714

Change-Id: Ie5ecaec91c00b26309da4e51cfc0991a5bb7d092
2021-11-15 14:39:42 -06:00
Josh Soref 0150c3b698 UPGRADE.txt: Spelling fixes
Correct typos of the following word families:

themselves
support
received

ASTERISK-29714

Change-Id: Ibd0a7996d5801c754d3d44fba31fe788a13dba95
2021-11-15 14:35:48 -06:00
Josh Soref 42d1c134f7 CHANGES: Spelling fixes
Correct typos of the following word families:

issuing
execution
bridging
alert
respective
unlikely
confbridge
offered
negotiation
announced
engineer
systems
inherited
passthrough
functionality
supporting
conflicts
semantically
monitor
specify
specifiable

ASTERISK-29714

Change-Id: Ia6b1cf634f52c5f7b1b8769dc54dae78106ed98c
2021-11-15 10:32:38 -05:00
George Joseph 301647788e CI: Rename 'master' node to 'built-in'
Jenkins renamed the 'master' node to 'built-in' in version
2.319 so we have to adjust as well.

Change-Id: Ice663c3a66d0eedf76e8e5fe530328455991ec25
2021-11-09 09:13:25 -06:00
Alexander Traud 608e52c939 BuildSystem: In POSIX sh, == in place of = is undefined.
ASTERISK-29724

Change-Id: I59aa0e52effdc16992f3a736ccf73430a6ef135b
2021-11-08 13:42:26 -06:00
Naveen Albert 36c5f5e5fa sig_analog: Fix truncated buffer copy
Fixes compiler warning caused by a truncated copy of the ANI2 into a
buffer of size 10. This could prevent the null terminator from being
copied if the copy value exceeds the size of the buffer. This increases
the buffer size to 101 to ensure there is no way for truncation to occur.

ASTERISK-29702 #close

Change-Id: Ief9052212952840fa44de6463b8699fdb3e163d0
2021-11-08 13:14:22 -06:00
Sean Bright e63461b008 pbx.c: Don't remove dashes from hints on reload.
When reloading dialplan, hints created dynamically would lose any dash
characters. Now we ignore those dashes if we are dealing with a hint
during a reload.

ASTERISK-28040 #close

Change-Id: I95e48f5a268efa3c6840ab69798525d3dce91636
2021-11-08 13:13:09 -06:00
Naveen Albert 92857e70b6 app_voicemail: Fix phantom voicemail bug on rerecord
If users are able to press # for options while leaving
a message and then press 3 to rerecord the message, if
the caller hangs up during the rerecord prompt but before
Asterisk starts recording a message, then an "empty"
voicemail gets processed whereby an email gets sent out
notifying the user of a 0:00 duration message. The file
doesn't actually exist, so playback will fail since there
was no message to begin with.

This adds a check after the streaming of the rerecord
announcement to see if the caller has hung up. If so,
we bail out early so that we can clean up properly.

ASTERISK-29391 #close

Change-Id: Id965d72759a2fd3b39afb76fec08aaebebe75c31
2021-11-08 11:28:21 -06:00
Naveen Albert bea08a563b chan_iax2: Allow both secret and outkey at dial time
Historically, the dial syntax for IAX2 has held that
an outkey (used only for RSA authenticated calls)
and a secret (used only for plain text and MD5 authenticated
calls, historically) were mutually exclusive, and thus
the same position in the dial string was used for both
values.

Now that encryption is possible with RSA authentication,
this poses a limitation, since encryption requires a
secret and RSA authentication requires an outkey. Thus,
the dial syntax is extended so that both a secret and
an outkey can be specified.

The new extended syntax is backwards compatible with the
old syntax. However, a secret can now be specified after
the outkey, or the outkey can be specified after the secret.
This makes it possible to spawn an encrypted RSA authenticated
call without a corresponding peer being predefined in iax.conf.

ASTERISK-29707 #close

Change-Id: I1f8149313ed760169d604afbb07720a8b07dd00e
2021-11-08 10:34:04 -06:00
Alexander Traud 95da40cd50 res_snmp: As build tool, prefer pkg-config over net-snmp-config.
ASTERISK-29709

Change-Id: Ie169df878bdfc3a06b3097c5c38d185b480f54d4
2021-11-04 10:49:58 -05:00
Alexander Traud 8b76a3cd3b stasis: Avoid 'dispatched' as unused variable in normal mode.
ASTERISK-29710

Change-Id: Ia849f1172e4e694c5d5d7f0cad449f936ee12216
2021-11-01 10:34:38 -05:00
Sean Bright 2c03f73016 various: Fix GCC 11.2 compilation issues.
* Initialize some variables that are never used anyway.

* Use valid pointers instead of integers cast to void pointers when
  calling pthread_setspecific().

ASTERISK-29711 #close
ASTERISK-29713 #close

Change-Id: I8728cd6f2f4b28e0e48113c5da450b768c2a6683
2021-10-29 12:16:16 -05:00
George Joseph 08cb67251f ast_coredumper: Refactor to better find things
The search for a running asterisk when --running is used
has been greatly simplified and in the event it doesn't
work, you can now specify a pid to use on the command
line with --pid.

The search for asterisk modules when --tarball-coredumps
is used has been enhanced to have a better chance of finding
them and in the event it doesn't work, you can now specify
--libdir on the command line to indicate the library directory
where they were installed.

The DATEFORMAT variable was renamed to DATEOPTS and is now
passed to the 'date' utility rather than running DATEFORMAT
as a command.

The coredump and output files are now renamed with DATEOPTS.
This can be disabled by specifying --no-rename.

Several confusing and conflicting options were removed:
--append-coredumps
--conffile
--no-default-search
--tarball-uniqueid

The script was re-structured to make it easier for follow.

Change-Id: I674be64bdde3ef310b6a551d4911c3b600ffee59
2021-10-28 13:50:13 -05:00
Kevin Harwell ae97aaedb0 strings/json: Add string delimter match, and object create with vars methods
Add a function to check if there is an exact match a one string between
delimiters in another string.

Add a function that will create an ast_json object out of a list of
Asterisk variables. An excludes string can also optionally be passed
in.

Also, add a macro to make it easier to get object integers.

Change-Id: I5f34f18e102126aef3997f19a553a266d70d6226
2021-10-28 08:58:44 -05:00
Ben Ford 2e55c0fded STIR/SHAKEN: Option split and response codes.
The stir_shaken configuration option now has 4 different choices to pick
from: off, attest, verify, and on. Off and on behave the same way they
do now. Attest will only perform attestation on the endpoint, and verify
will only perform verification on the endpoint.

Certain responses are required to be sent based on certain conditions
for STIR/SHAKEN. For example, if we get a Date header that is outside of
the time range that is considered valid, a 403 Stale Date response
should be sent. This and several other responses have been added.

Change-Id: I4ac1ecf652cd0e336006b0ca638dc826b5b1ebf7
2021-10-27 08:45:27 -05:00
Rodrigo Ramírez Norambuena a203769c9d app_queue: Add LoginTime field for member in a queue.
Add a time_t logintime to storage a time when a member is added into a
queue.

Also, includes show this time (in seconds) using a 'queue show' command
and the field LoginTime for response for AMI events.

ASTERISK-18069 #close

Change-Id: Ied6c3a300f78d78eebedeb3e16a1520fc3fff190
2021-10-25 08:31:07 -05:00
Kevin Harwell 859f579504 res_speech: Add a type conversion, and new engine unregister methods
Add a new function that converts a speech results type to a string.
Also add another function to unregister an engine, but returns a
pointer to the unregistered engine object instead of a success/fail
integer.

Change-Id: I0f7de17cb411021c09fb03988bc2b904e1380192
2021-10-21 16:25:04 -05:00
Mike Bradeen 0b2646aee6 various: Fix GCC 11 compilation issues.
test_voicemail_api: Use empty char* for empty_msg_ids.
chan_skinny: Fix size of calledParty to be maximum extension.
menuselect: Change Makefile to stop deprecated warnings. Added comments
test_linkedlist: 'bogus' variable was manually allocated from a macro
and the test fails if this happens but the compiler couldn't 'see' this
and returns a warning. memset to all 0's after allocation.
chan_ooh323: Fixed various indentation issues that triggered misleading
 indentation warnings.

ASTERISK-29682
Reported by: George Joseph

Change-Id: If4fe42222c8444dc16828a42731ee53b4ce5cbbe
2021-10-21 11:39:15 -05:00
Shloime Rosenblum 63c8d12e95 apps/app_playback.c: Add 'mix' option to app_playback
I am adding a mix option that will play by filename and say.conf unlike
say option that will only play with say.conf. It
will look on the format of the name, if it is like say it play with
say.conf if not it will play the file name.

ASTERISK-29662

Change-Id: I815816916a308f0fa8f165140dc15772dcbd547a
2021-10-21 10:47:30 -05:00
George Joseph c07e3c2f4d BuildSystem: Check for alternate openssl packages
OpenSSL is one of those packages that often have alternatives
with later versions.  For instance, CentOS/EL 7 has an
openssl package at version 1.0.2 but there's an openssl11
package from the epel repository that has 1.1.1.  This gets
installed to /usr/include/openssl11 and /usr/lib64/openssl11.
Unfortunately, the existing --with-ssl and --with-crypto
./configure options expect to point to a source tree and
don't work in this situation.  Also unfortunately, the
checks in ./configure don't use pkg-config.

In order to make this work with the existing situation, you'd
have to run...
./configure --with-ssl=/usr/lib64/openssl11 \
    --with-crypto=/usr/lib64/openssl11 \
    CFLAGS=-I/usr/include/openssl11

BUT...  those options don't get passed down to bundled pjproject
so when you run make, you have to include the CFLAGS again
which is a big pain.

Oh...  To make matters worse, although you can specify
PJPROJECT_CONFIGURE_OPTS on the ./configure command line,
they don't get saved so if you do a make clean, which will
force a re-configure of bundled pjproject, those options
don't get used.

So...

* In configure.ac... Since pkg-config is installed by install_prereq
  anyway, we now use it to check for the system openssl >= 1.1.0.
  If that works, great.  If not, we check for the openssl11
  package. If that works, great.  If not, we fall back to just
  checking for any openssl.  If pkg-config isn't installed for some
  reason, or --with-ssl=<dir> or --with-crypto=<dir> were specified
  on the ./configure command line, we fall back to the existing
  logic that uses AST_EXT_LIB_CHECK().

* The whole OpenSSL check process has been moved up before
  THIRD_PARTY_CONFIGURE(), which does the initial pjproject
  bundled configure, is run.  This way the results of the above
  checks, which may result in new include or library directories,
  is included.

* Although not strictly needed for openssl, We now save the value of
  PJPROJECT_CONFIGURE_OPTS in the makeopts file so it can be used
  again if a re-configure is triggered.

ASTERISK-29693

Change-Id: I341ab7603e6b156aa15a66f43675ac5029d5fbde
2021-10-20 13:21:16 -05:00
Sean Bright 8c2720e540 func_talkdetect.c: Fix logical errors in silence detection.
There are 3 separate changes here:

1. The documentation erroneously stated that the dsp_talking_threshold
   argument was a number of milliseconds when it is actually an energy
   level used by the DSP code to classify talking vs. silence.

2. Fixes a copy paste error in the argument handling code.

3. Don't erroneously switch to the talking state if we aren't actively
   handling a frame we've classified as talking.

Patch inspired by one provided by Moritz Fain (License #6961).

ASTERISK-27816 #close

Change-Id: I5953fd570b98b49c41cee55bfe3b941753fb2511
2021-10-19 10:22:33 -05:00
Sebastien Duthil e3466893e9 main/stun.c: fix crash upon STUN request timeout
Some ast_stun_request users do not provide a destination address when
sending to a connection-mode socket.

ASTERISK-29691

Change-Id: Idd9114c3380216ba48abfc3c68619e79ad37defc
2021-10-15 13:40:10 -05:00
Mike Bradeen bac66e9743 build: prevent binary downloads for non x86 architectures
download_externals: Add check for i686 and i386 (in addition
to the current x86_64) and exit if not one of the three.

ASTERISK-26497

Change-Id: Ia4d429fcefa5b2f5b6e99159d4607de8e8325b2f
2021-10-15 13:39:10 -05:00
Sean Bright 482281deff configure: Remove unused OpenSSL SRTP check.
Discovered while looking at ASTERISK~29684. Usage was removed in change
I3c77c7b00b2ffa2e935632097fa057b9fdf480c0.

Change-Id: Iaf2f7a16ea5a7eee6375319347e4b40b8e7b10e3
2021-10-15 10:48:12 -05:00
Asterisk Development Team 9063680148 Update CHANGES and UPGRADE.txt for 18.8.0 2021-10-13 05:21:03 -05:00
Sean Bright 804b1987fb Makefile: Use basename in a POSIX-compliant way.
If you aren't using GNU coreutils, chances are that your basename
doesn't know about the -s argument. Luckily for us, basename does what
we need it do even without the -s argument.

Change-Id: I8b81a429bb037b997ee6640ff8a2b5e860962bb7
2021-10-11 10:04:34 -05:00
Mark Murawski e091aa2763 pbx_ael: Fix crash and lockup issue regarding 'ael reload'
Avoid infinite recursion and crash

Change-Id: I8ed05ec3aa2806c50c77edc5dd0cd4e4fa08b3f4
2021-10-08 09:40:54 -05:00
Naveen Albert 437b2bfbd6 chan_iax2: Add encryption for RSA authentication
Adds support for encryption to RSA-authenticated
calls. Also prevents crashes if an RSA IAX2 call
is initiated to a switch requiring encryption
but no secret is provided.

ASTERISK-20219

Change-Id: I18f1f9d7c59b4f9cffa00f3b94a4c875846efd40
2021-10-07 18:23:21 -05:00
Matthew Kern 15e432220c res_pjsip_t38: bind UDPTL sessions like RTP
In res_pjsip_sdp_rtp, the bind_rtp_to_media_address option and the
fallback use of the transport's bind address solve problems sending
media on systems that cannot send ipv4 packets on ipv6 sockets, and
certain other situations. This change extends both of these behaviors
to UDPTL sessions as well in res_pjsip_t38, to fix fax-specific
problems on these systems, introducing a new option
endpoint/t38_bind_udptl_to_media_address.

ASTERISK-29402

Change-Id: I87220c0e9cdd2fe9d156846cb906debe08c63557
2021-10-06 08:54:27 -05:00
Naveen Albert 5a6f140765 app_read: Fix null pointer crash
If the terminator character is not explicitly specified
and an indications tone is used for reading a digit,
there is no null pointer check so Asterisk crashes.
This prevents null usage from occuring.

ASTERISK-29673 #close

Change-Id: Ie941833e123c3dbfb88371b5de5edbbe065514ac
2021-09-30 11:47:13 -05:00
Jean Aunis 0ab4e7491d res_rtp_asterisk: fix memory leak
Add missing reference decrement in rtp_deallocate_transport()

ASTERISK-29671

Change-Id: I8d22dbedb90e8dade0829b7a28372f404b07caa9
2021-09-30 01:42:25 -05:00
Shloime Rosenblum 29c44caecb main/say.c: Support future dates with Q and q format params
The current versions do not support future dates in all say application when using the 'Q' or 'q' format parameter and says "today" for everything that is greater than today

ASTERISK-29637

Change-Id: I1fb1cef0ce3c18d87b1fc94ea309d13bc344af02
2021-09-28 08:34:40 -05:00
Joseph Nadiv 4368764032 res_pjsip_registrar: Remove unavailable contacts if exceeds max_contacts
The behavior of max_contacts and remove_existing are connected.  If
remove_existing is enabled, the soonest expiring contacts are removed.
This may occur when there is an unavailable contact.  Similarly,
when remove_existing is not enabled, registrations from good
endpoints are rejected in favor of retaining unavailable contacts.

This commit adds a new AOR option remove_unavailable, and the effect
of this setting will depend on remove_existing.  If remove_existing
is set to no, we will still remove unavailable contacts when they
exceed max_contacts, if there are any. If remove_existing is set to
yes, we will prioritize the removal of unavailable contacts before
those that are expiring soonest.

ASTERISK-29525

Change-Id: Ia2711b08f2b4d1177411b1be23e970d7fdff5784
2021-09-24 09:48:47 -05:00
Joshua C. Colp ea36473c45 ari: Ignore invisible bridges when listing bridges.
When listing bridges we go through the ones present in
ARI, get their snapshot, turn it into JSON, and add it
to the payload we ultimately return.

An invisible "dial bridge" exists within ARI that would
also try to be added to this payload if the channel
"create" and "dial" routes were used. This would ultimately
fail due to invisible bridges having no snapshot
resulting in the listing of bridges failing.

This change makes it so that the listing of bridges
ignores invisible ones.

ASTERISK-29668

Change-Id: I14fa4b589b4657d1c2a5226b0f527f45a0cd370a
2021-09-23 11:18:26 -03:00
Naveen Albert 484da42d6c func_vmcount: Add support for multiple mailboxes
Allows multiple mailboxes to be specified for VMCOUNT
instead of just one.

ASTERISK-29661 #close

Change-Id: I9108528300795fd5b607efa9d4dd7b74be031813
2021-09-22 10:49:27 -05:00
Sean Bright e98839b73c message.c: Support 'To' header override with AMI's MessageSend.
The MessageSend AMI action has been updated to allow the Destination
and the To addresses to be provided separately. This brings the
MessageSend manager command in line with the capabilities of the
MessageSend dialplan application.

ASTERISK-29663 #close

Change-Id: I8513168d3e189a9fed88aaab6f5547ccb50d332c
2021-09-22 10:16:14 -05:00
Naveen Albert cf0d656ae6 func_channel: Add CHANNEL_EXISTS function.
Adds a function to check for the existence of a channel by
name or by UNIQUEID.

ASTERISK-29656 #close

Change-Id: Ib464e9eb6e13dc683a846286798fecff4fd943cb
2021-09-21 18:20:30 -05:00
Naveen Albert cfd0246d11 app_queue: Fix hint updates for included contexts
Previously, if custom hints were used with the hint:
format in app_queue, when device state changes occured,
app_queue would only do a literal string comparison of
the context used for the hint in app_queue and the context
of the hint which just changed state. This caused hints
to not update and become stale if the context associated
with the agent included the context which actually changes
state, essentially completely breaking device state for
any such agents defined in this manner.

This fix adds an additional check to ensure that included
contexts are also compared against the context which changed
state, so that the behavior is correct no matter whether the
context is specified to app_queue directly or indirectly.

ASTERISK-29578 #close

Change-Id: I8caf2f8da8157ef3d9ea71a8568c1eec95592b78
2021-09-21 14:32:44 -05:00
Sean Bright b2c834e349 res_http_media_cache.c: Compare unaltered MIME types.
Rather than stripping parameters from Content-Type headers before
comparison, first try to compare the whole string. If no match is
found, strip the parameters and try that way.

ASTERISK-29275 #close

Change-Id: I2963c8ecbb3a9605b78b6421c415108d77a66a0f
2021-09-21 13:11:18 -05:00
Naveen Albert a65bb134f5 logger: Add custom logging capabilities
Adds the ability for users to log to custom log levels
by providing custom log level names in logger.conf. Also
adds a logger show levels CLI command.

ASTERISK-29529

Change-Id: If082703cf81a436ae5a565c75225fa8c0554b702
2021-09-21 12:09:59 -05:00
Sean Bright dce142baa4 app_externalivr.c: Fix mixed leading whitespace in source code.
No functional changes.

Change-Id: I46514152c0af67f395526374aaa847ccd6a85378
2021-09-21 11:46:36 -05:00
Guido Falsi 03377c35fc res_rtp_asterisk.c: Fix build failure when not building with pjproject.
Some code has been added referencing symbols defined in a block
protected by #ifdef HAVE_PJPROJECT. Protect those code parts in
ifdef blocks too.

ASTERISK-29660

Change-Id: Ib18d4392d51ac80ca5481dabf6e498a4e3e49e6f
2021-09-20 15:48:36 -05:00
Asterisk Development Team 00cf86dafe Update CHANGES and UPGRADE.txt for 18.7.0 2021-09-16 08:39:41 -05:00
Carlos Oliva e8f7b53023 app_mp3: Force output to 16 bits in mpg123
In new mpg123 versions (since 1.26) the default output is 32 bits
Asterisk expects the output in 16 bits, so we force the output to be on 16 bits.
It will work wit new and old versions of mpg123.
Thanks Thomas Orgis <thomas-forum@orgis.org> for giving the key!

ASTERISK-29635 #close

Change-Id: I88c7740118b5af4e895bd8b765b68ed5c11fc816
2021-09-15 12:44:36 -05:00
George Joseph 0947c30224 pjproject: Add patch to fix trailing whitespace issue in rtpmap
An issue was found where a particular manufacturer's phones add a
trailing space to the end of the rtpmap attribute when specifying
a payload type that has a "param" after the format name and clock
rate. For example:

a=rtpmap:120 opus/48000/2 \r\n

Because pjmedia_sdp_attr_get_rtpmap currently takes everything after
the second '/' up to the line end as the param, the space is
included in future comparisons, which then fail if the param being
compared to doesn't also have the space.

We now use pj_scan_get() to parse the param part of rtpmap so
trailing whitespace is automatically stripped.

ASTERISK-29654

Change-Id: Ibd0a4e243a69cde7ba9312275b13ab62ab86bc1b
2021-09-15 12:14:20 -05:00
Naveen Albert 1a23c9c047 res_pjsip_caller_id: Add ANI2/OLI parsing
Adds parsing of ANI II digits (Originating
Line Information) to PJSIP, on par with
what currently exists in chan_sip.

ASTERISK-29472

Change-Id: Ifc938a7a7d45ce33999ebf3656a542226f6d3847
2021-09-15 10:27:29 -05:00
Naveen Albert 60daa8f761 app_mf: Add channel agnostic MF sender
Adds a SendMF application and PlayMF manager
event to send arbitrary R1 MF tones on the
current or specified channel.

ASTERISK-29496

Change-Id: I5d89afdbccee3f86cc702ed96d882f3d351327a4
2021-09-14 15:03:42 -05:00
Sean Bright 847349853a test_http_media_cache.c: Fix copy/paste error during test deregistration.
Change-Id: I9a3a978b2f818be464e062d97b93831b127ef28c
2021-09-13 07:17:40 -05:00
Naveen Albert c736cef310 app_stack: Include current location if branch fails
Previously, the error emitted when app_stack tries
to branch to a dialplan location that doesn't exist
has included only the information about the attempted
branch in the error log. This adds the current location
as well so users can see where the branch failed in
the logs.

ASTERISK-29626

Change-Id: Ia23502ab2ad21485a1ac74295063a8f25a6df5ce
2021-09-13 07:16:50 -05:00
Sungtae Kim d9747104ff resource_channels.c: Fix external media data option
Fixed the external media creation handle to handle the 'data' option correctly.

ASTERISK-29629

Change-Id: I22e57fe8ebf3d3e08fb2121aa4a8a52cc62e8129
2021-09-10 16:00:28 -05:00
Naveen Albert 6198c1d28c func_strings: Add STRBETWEEN function
Adds the STRBETWEEN function, which can be used to insert a
substring between each character in a string. For instance,
this can be used to insert pauses between DTMF tones in a
string of digits.

ASTERISK-29627

Change-Id: Ice23009d4a8e9bb9718d2b2301d405567087d258
2021-09-10 15:59:22 -05:00
Sean Bright ee62a07914 test_abstract_jb.c: Fix put and put_out_of_order memory leaks.
We can't rely on RAII_VAR(...) to properly clean up data that is
allocated within a loop.

ASTERISK-27176 #close

Change-Id: Ib575616101230c4f603519114ec62ebf3936882c
2021-09-10 12:17:03 -05:00
Naveen Albert 19de228e8b func_env: Add DIRNAME and BASENAME functions
Adds the DIRNAME and BASENAME functions, which are
wrappers around the corresponding C library functions.
These can be used to safely and conveniently work with
file paths and names in the dialplan.

ASTERISK-29628 #close

Change-Id: Id3aeb907f65c0ff96b6e57751ff0cb49d61db7f3
2021-09-10 11:47:41 -05:00
Naveen Albert b6b7b1490b func_sayfiles: Retrieve say file names
Up until now, all of the logic used to translate
arguments to the Say applications has been
directly coupled to playback, preventing other
modules from using this logic.

This refactors code in say.c and adds a SAYFILES
function that can be used to retrieve the file
names that would be played. These can then be
used in other applications or for other purposes.

Additionally, a SayMoney application and a SayOrdinal
application are added. Both SayOrdinal and SayNumber
are also expanded to support integers greater than
one billion.

ASTERISK-29531

Change-Id: If9718c89353b8e153d84add3cc4637b79585db19
2021-09-10 11:45:41 -05:00
Naveen Albert a6eb1b6f95 res_tonedetect: Tone detection module
dsp.c contains arbitrary tone detection functionality
which is currently only used for fax tone recognition.
This change makes this functionality publicly
accessible so that other modules can take advantage
of this.

Additionally, a WaitForTone and TONE_DETECT app and
function are included to allow users to do their
own tone detection operations in the dialplan.

ASTERISK-29546

Change-Id: Ie38c395000f4fd4d04e942e8658e177f8f499b26
2021-09-10 11:08:35 -05:00
George Joseph 2806a45034 res_snmp: Add -fPIC to _ASTCFLAGS
With gcc 11, res/res_snmp.c and res/snmp/agent.c need the
-fPIC option added to its _ASTCFLAGS.

ASTERISK-29634

Change-Id: I34649c85e075fd954e578378fabf798c3f038f50
2021-09-10 10:37:33 -05:00
Sean Bright 858cb386fd term.c: Add support for extended number format terminfo files.
ncurses 6.1 introduced an extended number format for terminfo files
which the terminfo parsing in Asterisk is not able to parse. This
results in some TERM values that do support color (screen-256color on
Ubuntu 20.04 for example) to not get a color console.

ASTERISK-29630 #close

Change-Id: I27a4fcfab502219924af2d6b1c46feba92903cb3
2021-09-09 06:48:40 -05:00
Sean Bright 347e9a7e4d app_voicemail.c: Ability to silence instructions if greeting is present.
There is an option to silence voicemail instructions but it does not
take into consideration if a recorded greeting exists or not. Add a
new 'S' option that does that.

ASTERISK-29632 #close

Change-Id: I03f2f043a9beb9d99deab302247e2a8686066fb4
2021-09-08 19:11:54 -05:00
Jasper Hafkenscheid c1a575907b res_srtp: Disable parsing of not enabled cryptos
When compiled without extended srtp crypto suites also disable parsing
these from received SDP. This prevents using these, as some client
implementations are not stable.

ASTERISK-29625

Change-Id: I7dafb29be1cdaabdc984002573f4bea87520533a
2021-09-08 18:20:46 -05:00
Sean Bright 689c703b2c dns.c: Load IPv6 DNS resolvers if configured.
IPv6 nameserver addresses are stored in different part of the
__res_state structure, so look there if we appear to have support for
it.

ASTERISK-28004 #close

Change-Id: I67067077d8a406ee996664518d9c8fbf11f6977d
2021-09-08 18:18:05 -05:00
George Joseph de19836c24 bridge_softmix: Suppress error on topology change failure
There are conditions under which a failure to change topology
is expected so there's no need to print an ERROR message.

ASTERISK-29618
Reported by: Alexander

Change-Id: Idc168b8588e018bf3a23769f08c4ad646086d481
2021-09-08 07:55:35 -05:00
sungtae kim 479cc17f45 resource_channels.c: Fix wrong external media parameter parse
Fixed ARI external media handler to accept body parameters.

ASTERISK-29622

Change-Id: I49509c48a6cbc0fb4165bfa4f834b5e8b9ace20d
2021-09-02 15:18:31 -05:00
Sean Bright 5c836c8e36 config_options: Handle ACO arrays correctly in generated XML docs.
There are 3 separate changes here but they are all closely related:

* Only try to set matchfield attributes on 'field' nodes

* We need to adjust how we treat the category pointer based on the
  value of the category_match, to avoid memory corruption. We now
  generate a regex-like string when match types other than
  ACO_WHITELIST and ACO_BLACKLIST are used.

* Switch app_agent_pool from ACO_BLACKLIST_ARRAY to
  ACO_BLACKLIST_EXACT since we only have one category we need to
  ignore, not two.

ASTERISK-29614 #close

Change-Id: I7be7bdb1bb9814f942bc6bb4fdd0a55a7b7efe1e
2021-09-02 15:13:03 -05:00
Naveen Albert 5a685249ce chan_iax2: Add ANI2/OLI information element
Adds an information element for ANI2 so that
Originating Line Information can be transmitted
over IAX2 channels.

ASTERISK-29605 #close

Change-Id: Iaeacdf6ccde18eaff7f776a0f49fee87dcb549d2
2021-09-02 14:16:58 -05:00
Mark Murawski 042ae05be7 pbx_ael: Fix crash and lockup issue regarding 'ael reload'
Currently pbx_ael does not check if a reload is currently pending
before proceeding with a reload. This can cause multiple threads to
operate at the same time on what should be mutex protected data. This
change adds protection to reloading to ensure only one ael reload is
executing at a time.

ASTERISK-29609 #close

Change-Id: I5ed392ad226f6e4e7696ad742076d3e45c57af35
2021-09-02 14:16:08 -05:00
Naveen Albert dd980e00b4 app_read: Allow reading # as a digit
Allows for the digit # to be read as a digit,
just like any other DTMF digit, as opposed to
forcing it to be used as an end of input
indicator. The default behavior remains
unchanged.

ASTERISK-18454 #close

Change-Id: I3033432adb9d296ad227e76b540b8b4a2417665b
2021-09-01 10:30:59 -05:00
Sebastien Duthil ac492f2ff8 res_rtp_asterisk: Automatically refresh stunaddr from DNS
This allows the STUN server to change its IP address without having to
reload the res_rtp_asterisk module.

The refresh of the name resolution occurs first when the module is
loaded, then recurringly, slightly after the previous DNS answer TTL
expires.

ASTERISK-29508 #close

Change-Id: I7955a046293f913ba121bbd82153b04439e3465f
2021-09-01 10:29:20 -05:00
Naveen Albert e660a2c03b bridge_basic: Change warning to verbose if transfer cancelled
The attended transfer feature will emit a warning if the user
cancels the transfer or the attended transfer doesn't complete
for any reason. Changes the warning to a verbose message,
since nothing is actually wrong here.

ASTERISK-29612 #close

Change-Id: I64c93cdb21360a0a8d45e9cb6db3af8168f66e6d
2021-08-26 08:51:54 -05:00
Naveen Albert c7af46995e app_queue: Don't reset queue stats on reload
Prevents reloads of app_queue from also resetting
queue statistics.

Also preserves individual queue agent statistics
if we're just reloading members.

ASTERISK-28701

Change-Id: Ib5d4cdec175e44de38ef0f6ede4a7701751766f1
2021-08-25 18:35:39 -05:00
Alexander Traud 82d6bd7ec9 res_rtp_asterisk: sqrt(.) requires the header math.h.
ASTERISK-29616

Change-Id: I6c01623926bf10ccac32612687a50fdab3ba0900
2021-08-25 18:04:15 -05:00
Alexander Traud 8410afc7ab dialplan: Add one static and fix two whitespace errors.
Change-Id: Ia14d515ab63e773097adc6af772ca7123a392f83
2021-08-25 09:31:42 -05:00
Sarah Autumn 241686f860 sig_analog: Changes to improve electromechanical signalling compatibility
This changeset is intended to address compatibility issues encountered
when interfacing Asterisk to electromechanical telephone switches that
implement ANI-B, ANI-C, or ANI-D.

In particular the behaviours that this impacts include:

 - FGC-CAMA did not work at all when using MF signaling. Modified the
   switch case block to send calls to the correct part of the
   signaling-handling state machine.

 - For FGC-CAMA operation, the delay between called number ST and
   second wink for ANI spill has been made configurable; previously
   all calls were made to wait for one full second.

 - After the ANI spill, previous behavior was to require a 'ST' tone
   to advance the call.  This has been changed to allow 'STP' 'ST2P'
   or 'ST3P' as well, for compatibility with ANI-D.

 - Store ANI2 (ANI INFO) digits in the CALLERID(ANI2) channel variable.

 - For calls with an ANI failure, No. 1 Crossbar switches will send
   forward a single-digit failure code, with no calling number digits
   and no ST pulse to terminate the spill.  I've made the ANI timeout
   configurable so to reduce dead air time on calls with ANI fail.

 - ANI info digits configurable.  Modern digital switches will send 2
   digits, but ANI-B sends only a single info digit.  This caused the
   ANI reported by Asterisk to be misaligned.

 - Changed a confusing log message to be more informative.

ASTERISK-29518

Change-Id: Ib7e27d987aee4ed9bc3663c57ef413e21b404256
2021-08-20 15:30:55 -05:00
Andre Barbosa eb486db3af media_cache: Don't lock when curl the remote file
When playing a remote sound file, which is not in cache, first we need
to download it with ast_bucket_file_retrieve.

This can take a while if the remote host is slow. The current CURL
timeout is 180secs, so in extreme situations, it can take 3 minutes to
return.

Because ast_media_cache_retrieve has a lock on all function, while we
are waiting for the delayed download, Asterisk is not able to play any
more files, even the files already cached locally.

ASTERISK-29544 #close

Change-Id: I8d4142b463ae4a1d4c41bff2bf63324821567408
2021-08-20 11:47:40 -05:00
George Joseph b72425b1f0 res_pjproject: Allow mapping to Asterisk TRACE level
Allow mapping pjproject log messages to the Asterisk TRACE
log level.  The defaults were also changes to log pjproject
levels 3,4 to DEBUG and 5,6 to TRACE.  Previously 3,4,5,6
all went to DEBUG.

ASTERISK-29582

Change-Id: I859a37a8dec263ed68099709cfbd3e665324c72d
2021-08-19 13:00:02 -05:00
Naveen Albert dffc5e7f5c app_milliwatt: Timing fix
The Milliwatt application uses incorrect tone timings
that cause it to play the 1004 Hz tone constantly.

This adds an option to enable the correct timing
behavior, so that the Milliwatt application can
be used for milliwatt test lines. The default behavior
remains unchanged for compatability reasons, even
though it is incorrect.

ASTERISK-29575 #close

Change-Id: I73ccc6c6fcaa31931c6fff3b85ad1805b2ce9d8c
2021-08-19 11:18:00 -05:00
Naveen Albert c52ef4ac79 func_math: Return integer instead of float if possible
The MIN, MAX, and ABS functions all support float
arguments, but currently return floats even if the
arguments are all integers and the response is
a whole number, in which case the user is likely
expecting an integer. This casts the float to an integer
before printing into the response buffer if possible.

ASTERISK-29495

Change-Id: I902d29eacf3ecd0f8a6a5e433c97f0421d205488
2021-08-19 11:05:13 -05:00
Naveen Albert 9cac1c16da app_morsecode: Add American Morse code
Previously, the Morsecode application only supported international
Morse code. This adds support for American Morse code and adds an
option to configure the frequency used in off intervals.

Additionally, the application checks for hangup between tones
to prevent application execution from continuing after hangup.

ASTERISK-29541

Change-Id: I172431a2e18e6527d577e74adfb05b154cba7bd4
2021-08-19 10:33:38 -05:00
Naveen Albert 3eec5b8c5c func_scramble: Audio scrambler function
Adds a function to scramble audio on a channel using
whole spectrum frequency inversion. This can be used
as a privacy enhancement with applications like
ChanSpy or other potentially sensitive audio.

ASTERISK-29542

Change-Id: I01020769d91060a1f56a708eb405f87648d1a67e
2021-08-19 10:01:48 -05:00
Naveen Albert cb1dfecc11 app_originate: Add ability to set codecs
A list of codecs to use for dialplan-originated calls can
now be specified in Originate, similar to the ability
in call files and the manager action.

Additionally, we now default to just using the slin codec
for originated calls, rather than all the slin* codecs up
through slin192, which has been known to cause issues
and inconsistencies from AMI and call file behavior.

ASTERISK-29543

Change-Id: I96a1aeb83d54b635b7a51e1b4680f03791622883
2021-08-19 09:09:22 -05:00
Alexander Traud a8e8b3aaff BuildSystem: Remove two dead exceptions for compiler Clang.
Commit 305ce3d added -Wno-parentheses-equality to Makefile.rules,
turning the previous two warning suppressions from commit e9520db
redundant. Let us remove the latter.

Change-Id: I0b471254b31e6e05902062761dded4b3e626c7ac
2021-08-19 09:03:03 -05:00
Sean Bright 121860e3f6 mgcp: Remove dead debug code
ASTERISK-20339 #close

Change-Id: I36f364aaa1971241d8f3ea1a5909b463d185a2d5
2021-08-16 12:32:59 -05:00
Joshua C. Colp 13fd0789a2 policy: Add deprecation and removal versions to modules.
app_meetme is deprecated in 19, to be removed in 21.
app_osplookup is deprecated in 19, to be removed in 21.
chan_alsa is deprecated in 19, to be removed in 21.
chan_mgcp is deprecated in 19, to be removed in 21.
chan_skinny is deprecated in 19, to be removed in 21.
res_pktccops is deprecated in 19, to be removed in 21.
cdr_mysql was deprecated in 1.8, to be removed in 19.
app_mysql was deprecated in 1.8, to be removed in 19.
app_ices was deprecated in 16, to be removed in 19.
app_macro was deprecated in 16, to be removed in 21.
app_fax was deprecated in 16, to be removed in 19.
app_url was deprecated in 16, to be removed in 19.
app_image was deprecated in 16, to be removed in 19.
app_nbscat was deprecated in 16, to be removed in 19.
app_dahdiras was deprecated in 16, to be removed in 19.
cdr_syslog was deprecated in 16, to be removed in 19.
chan_oss was deprecated in 16, to be removed in 19.
chan_phone was deprecated in 16, to be removed in 19.
chan_sip was deprecated in 17, to be removed in 21.
chan_nbs was deprecated in 16, to be removed in 19.
chan_misdn was deprecated in 16, to be removed in 19.
chan_vpb was deprecated in 16, to be removed in 19.
res_config_sqlite was deprecated in 16, to be removed in 19.
res_monitor was deprecated in 16, to be removed in 21.
conf2ael was deprecated in 16, to be removed in 19.
muted was deprecated in 16, to be removed in 19.

ASTERISK-29548
ASTERISK-29549
ASTERISK-29550
ASTERISK-29551
ASTERISK-29552
ASTERISK-29553
ASTERISK-29554
ASTERISK-29555
ASTERISK-29557
ASTERISK-29558
ASTERISK-29559
ASTERISK-29560
ASTERISK-29561
ASTERISK-29562
ASTERISK-29563
ASTERISK-29564
ASTERISK-29565
ASTERISK-29566
ASTERISK-29567
ASTERISK-29568
ASTERISK-29569
ASTERISK-29570
ASTERISK-29571
ASTERISK-29572
ASTERISK-29573
ASTERISK-29574

Change-Id: Ic3bee31a10d42c4b3bbc913d893f7b2a28a27131
2021-08-16 11:48:10 -05:00
Asterisk Development Team 288d018fb7 Update CHANGES and UPGRADE.txt for 18.6.0 2021-08-12 11:00:29 -05:00
Naveen Albert 118d848238 func_frame_drop: New function
Adds function to selectively drop specified frames
in the TX or RX direction on a channel, including
control frames.

ASTERISK-29478

Change-Id: I8147c9d55d74e2e48861edba6b22f930920541ec
2021-08-09 07:59:30 -05:00
Alexander Traud 0b1a629ecd aelparse: Accept an included context with timings.
With Asterisk 1.6.0, in the main parser for the configuration file
extensions.conf, the separator was changed from vertical bar to comma.
However, the first separator was not changed in aelparse; it still had
to be a vertical bar, and no comma was allowed.

Additionally, this change allows the vertical bar for the first and
last parameter again, even in the main parser, because the vertical bar
was still accepted for the other parameters.

ASTERISK-29540

Change-Id: I882e17c73adf4bf2f20f9046390860d04a9f8d81
2021-08-06 09:19:38 -05:00
Kevin Harwell 628830921e format_ogg_speex: Implement a "not supported" write handler
This format did not specify a "write" handler, so when attempting to write
to it (ast_writestream) a crash would occur.

This patch adds a default handler that simply issues a "not supported"
warning, thus no longer crashing.

ASTERISK-29539

Change-Id: I8f6ddc7cc3b15da30803be3b1cf68e2ba0fbce91
2021-08-06 07:52:55 -05:00
Naveen Albert adf707f2ae cdr_adaptive_odbc: Prevent filter warnings
Previously, if CDR filters were used so that
not all CDR records used all sections defined
in cdr_adaptive_odbc.conf, then warnings will
always be emitted (if each CDR record is unique
to a particular section, n-1 warnings to be
specific).

This turns the offending warning log into
a verbose message like the other one, since
this behavior is intentional and not
indicative of anything wrong.

ASTERISK-29494

Change-Id: Ifd314fa9298722bc99494d5ca2658a5caa94a5f8
2021-08-04 07:59:52 -05:00
Naveen Albert 940f6c4a03 app_queue: Allow streaming multiple announcement files
Allows multiple files comprising an agent announcement
to be played by separating on the ampersand, similar
to the multi-file support in other Asterisk applications.

ASTERISK-29528

Change-Id: Iec600d8cd5ba14aa1e4e37f906accb356cd7891a
2021-08-04 07:47:44 -05:00
Igor Goncharovsky 1e4ed61a2b res_pjsip_header_funcs: Add PJSIP_HEADERS() ability to read header by pattern
PJSIP currently does not provide a function to replace SIP_HEADERS() function to get a list of headers from INVITE request.
It may be used to get all X- headers in case the actual set and names of headers unknown.

ASTERISK-29389

Change-Id: Ic09d395de71a0021e0d6c5c29e1e19d689079f8b
2021-08-03 09:39:53 -05:00
Rijnhard Hessel 71dd1d91ad res_statsd: handle non-standard meter type safely
Meter types are not well supported,
lacking support in telegraf, datadog and the official statsd servers.
We deprecate meters and provide a compliant fallback for any existing usages.

A flag has been introduced to allow meters to fallback to counters.


ASTERISK-29513

Change-Id: I5fcb385983a1b88f03696ff30a26b55c546a1dd7
2021-08-03 08:18:12 -05:00
under feb1e06ac5 codec_builtin.c: G729 audio gets corrupted by Asterisk due to smoother
If Asterisk gets G.729 6-byte VAD frames inbound, then at outbound Asterisk sends this G.729 stream with non-continuous timestamps.
This makes the audio stream not-playable at the receiver side.
Linphone isn't able to play such an audio - lots of disruptions are heard.
Also I had complains of bad audio from users which use other types of phones.

After debugging, I found this is a regression connected with RTP Smoother (main/smoother.c).

Smoother has a special code to handle G.729 VAD frames (search for AST_SMOOTHER_FLAG_G729 in smoother.c).

However, this flag is never set in Asterisk-12 and newer.
Previously it has been set (see Asterisk-11).

ASTERISK-29526 #close

Change-Id: I6f51ecb1a3ecd9c6d59ec5a6811a27446e17065d
2021-08-03 07:15:10 -05:00
Naveen Albert 016f6a0e14 app_dtmfstore: New application to store digits
Adds application to asynchronously collect digits
dialed on a channel in the TX or RX direction
using a framehook and stores them in a specified
variable, up to a configurable number of digits.

ASTERISK-29477

Change-Id: I51aa93fc9507f7636ac44806c4420ce690423e6f
2021-08-02 12:44:23 -05:00
Joshua C. Colp 9117f09d28 docs: Remove embedded macro in WaitForCond XML documentation.
Change-Id: I40c6514e1843e320f3cbe0b2c70d4a98c0e35b9c
2021-07-27 07:55:16 -05:00
Asterisk Development Team 993b3ba919 Update CHANGES and UPGRADE.txt for 18.5.1 2021-07-22 16:56:34 -05:00
Kevin Harwell 3025ef4f6e AST-2021-009 - pjproject-bundled: Avoid crash during handshake for TLS
If an SSL socket parent/listener was destroyed during the handshake,
depending on timing, it was possible for the handling callback to
attempt access of it after the fact thus causing a crash.

ASTERISK-29415 #close

Change-Id: I105dacdcd130ea7fdd4cf2010ccf35b5eaf1432d
2021-07-22 16:19:37 -05:00
Kevin Harwell 2a141a58b6 AST-2021-008 - chan_iax2: remote crash on unsupported media format
If chan_iax2 received a packet with an unsupported media format, for
example vp9, then it would set the frame's format to NULL. This could
then result in a crash later when an attempt was made to access the
format.

This patch makes it so chan_iax2 now ignores/drops frames received
with unsupported media format types.

ASTERISK-29392 #close

Change-Id: Ifa869a90dafe33eed8fd9463574fe6f1c0ad3eb1
2021-07-22 16:16:59 -05:00
Joshua C. Colp 523a795289 AST-2021-007 - res_pjsip_session: Don't offer if no channel exists.
If a re-INVITE is received after we have sent a BYE request then it
is possible for no channel to be present on the session. If this
occurs we allow PJSIP to produce the offer instead. Since the call
is being hung up if it produces an incorrect offer it doesn't
actually matter. This also ensures that code which produces SDP
does not need to handle if a channel is not present.

ASTERISK-29381

Change-Id: I673cb88c432f38f69b2e0851d55cc57a62236042
2021-07-22 13:27:02 -05:00
Andre Barbosa 2c3defc6c6 res_stasis_playback: Check for chan hangup on play_on_channels
Verify `ast_check_hangup` before looping to the next sound file.
If the call is already hangup we just break the cycle.
It also ensures that the PlaybackFinished event is sent if the call was hangup.

This is also use-full when we are playing a big list of file for a channel that is hangup.
Before this patch Asterisk will give a warning for every sound not played and fire a PlaybackStart for every sound file on the list tried to be played.

With the patch we just break the playback cycle when the chan is hangup.

ASTERISK-29501 #close

Change-Id: Ic4e1c01b974c9a1f2d9678c9d6b380bcfc69feb8
2021-07-20 02:59:47 -05:00
Sean Bright 30feaadabf res_pjsip_stir_shaken: RFC 8225 compliance and error message cleanup.
From RFC 8225 Section 5.2.1:

    The "dest" claim is a JSON object with the claim name of "dest"
    and MUST have at least one identity claim object.  The "dest"
    claim value is an array containing one or more identity claim JSON
    objects representing the destination identities of any type
    (currently "tn" or "uri").  If the "dest" claim value array
    contains both "tn" and "uri" claim names, the JSON object should
    list the "tn" array first and the "uri" array second.  Within the
    "tn" and "uri" arrays, the identity strings should be put in
    lexicographical order, including the scheme-specific portion of
    the URI characters.

Additionally, make it clear that there was a failure to sign the JWT
payload and not necessarily a memory allocation failure.

Change-Id: Ia8733b861aef6edfaa9c2136e97b447a01578dc9
2021-07-19 10:48:18 -05:00
Sebastien Duthil 4bd975f415 stun: Emit warning message when STUN request times out
Without this message, it is not obvious that the reason is STUN timeout.

ASTERISK-29507 #close

Change-Id: I26e4853c23a1aed324552e1b9683ea3c05cb1f74
2021-07-19 06:58:04 -05:00
Sean Bright 76c09b1cfd res_http_media_cache.c: Parse media URLs to find extensions.
Use the URI parsing functions to parse playback URLs in order to find
their file extensions.

For backwards compatibility, we first look at the full URL, then at
any Content-Type header, and finally at just the path portion of the
URL.

ASTERISK-27871 #close

Change-Id: I16d0682f6d794be96539261b3e48f237909139cb
2021-07-19 06:54:06 -05:00
Sean Bright fcebc4d24a main/cdr.c: Correct Party A selection.
This appears to just have been a copy/paste error from 6258bbe7. Fix
suggested by Ross Beer in ASTERISK~29166.

Change-Id: I51e0de92042e53f37597c6f83a75621ef0d1ae37
2021-07-16 10:24:10 -05:00
Naveen Albert a41d192e99 app_reload: New Reload application
Adds an application to reload modules
from within the dialplan.

ASTERISK-29454

Change-Id: Ic8ab025d8b38dd525b872b41c465c999c5810774
2021-07-15 10:05:12 -05:00
Igor Goncharovsky b9bb96ffed res_ari: Fix audiosocket segfault
Add check that data parameter specified when audiosocket used for externalMedia.

ASTERISK-29514 #close

Change-Id: Ie562f03c5d6c3835a3631f376b3d43e75b8f9617
2021-07-13 15:15:38 -05:00
Sean Bright 146b59df3f res_pjsip_config_wizard.c: Add port matching support.
In f8b0c2c9 we added support for port numbers in 'match' statements
but neglected to include that support in the PJSIP config wizard.

The removed code would have also prevented IPv6 addresses from being
successfully used in the config wizard as well.

ASTERISK-29503 #close

Change-Id: Idd5bbfd48009e7a741757743dbaea68e2835a34d
2021-07-08 10:31:21 -05:00
Naveen Albert 1b21b1abf7 app_waitforcond: New application
While several applications exist to wait for
a certain event to occur, none allow waiting
for any generic expression to become true.
This application allows for waiting for a condition
to become true, with configurable timeout and
checking interval.

ASTERISK-29444

Change-Id: I08adf2824b8bc63405778cf355963b5005612f41
2021-07-08 09:45:32 -05:00
Andre Barbosa 283812e492 res_stasis_playback: Send PlaybackFinish event only once for errors
When we try to play a list of sound files in the same Play command,
we get only one PlaybackFinish event, after all sounds are played.

But in the case where the Play fails (because channel is destroyed
for example), Asterisk will send one PlaybackFinish event for each
sound file still to be played. If the list is big, Asterisk is
sending many events.

This patch adds a failed state so we can understand that the play
failed. On that case we don't send the event, if we still have a
list of sounds to be played.

When we reach the last sound, we send the PlaybackFinish with
the failed state.

ASTERISK-29464 #close

Change-Id: I4c2e5921cc597702513af0d7c6c2c982e1798322
2021-06-24 08:56:08 -05:00
George Joseph 88da59efe7 jitterbuffer: Correct signed/unsigned mismatch causing assert
If the system time has stepped backwards because of a time
adjustment between the time a frame is timestamped and the
time we check the timestamps in abstract_jb:hook_event_cb(),
we get a negative interval, but we don't check for that there.
abstract_jb:hook_event_cb() then calls
fixedjitterbuffer:fixed_jb_get() (via abstract_jb:jb_get_fixed)
and the first thing that does is assert(interval >= 0).

There are several issues with this...

 * abstract_jb:hook_event_cb() saves the interval in a variable
   named "now" which is confusing in itself.

 * "now" is defined as an unsigned int which converts the negative
   value returned from ast_tvdiff_ms() to a large positive value.

 * fixed_jb_get()'s parameter is defined as a signed int so the
   interval gets converted back to a negative value.

 * fixed_jb_get()'s assert is NOT an ast_assert but a direct define
   that points to the system assert() so it triggers even in
   production mode.

So...

 * hook_event_cb()'s "now" was renamed to "relative_frame_start" and
   changed to an int64_t.
 * hook_event_cb() now checks for a negative value right after
   retrieving both the current and framedata timestamps and just
   returns the frame if the difference is negative.
 * fixed_jb_get()'s local define of ASSERT() was changed to call
   ast_assert() instead of the system assert().

ASTERISK-29480
Reported by: Dan Cropp

Change-Id: Ic469dec73c2edc3ba134cda6721a999a9714f3c9
2021-06-24 08:21:35 -05:00
Naveen Albert c4236dcff2 app_dial: Expanded A option to add caller announcement
Hitherto, the A option has made it possible to play
audio upon answer to the called party only. This option
is expanded to allow for playback of an audio file to
the caller instead of or in addition to the audio
played to the answerer.

ASTERISK-29442

Change-Id: If6eed3ff5c341dc8c588c8210987f2571e891e5e
2021-06-23 09:36:29 -05:00
Joshua C. Colp 5e1cb3253c core: Don't play silence for Busy() and Congestion() applications.
When using the Busy() and Congestion() applications the
function ast_safe_sleep is used by wait_for_hangup to safely
wait on the channel. This function may send silence if Asterisk
is configured to do so using the transmit_silence option.

In a scenario where an answered channel dials a Local channel
either directly or through call forwarding and the Busy()
or Congestion() dialplan applications were executed with the
transmit_silence option enabled the busy or congestion
tone would not be heard.

This is because inband generation of tones (such as busy
and congestion) is stopped when other audio is sent to
the channel they are being played to. In the given
scenario the transmit_silence option would result in
silence being sent to the channel, thus stopping the
inband generation.

This change adds a variant of ast_safe_sleep which can be
used when silence should not be played to the channel. The
wait_for_hangup function has been updated to use this
resulting in the tones being generated as expected.

ASTERISK-29485

Change-Id: I066bfc987a3ad6f0ccc88e0af4cd63f6a4729133
2021-06-22 08:49:44 -05:00
Bernd Zobl 6b041d1092 res_pjsip_sdp_rtp: Evaluate remotely held for Session Progress
With the fix for ASTERISK_28754 channels are no longer put on hold if an
outbound INVITE is answered with a "Session Progress" containing
"inactive" audio.

The previous change moved the evaluation of the media attributes to
`negotiate_incoming_sdp_stream()` to have the `remotely_held` status
available when building the SDP in `create_outgoing_sdp_stream()`.
This however means that an answer to an outbound INVITE, which does not
traverse `negotiate_incoming_sdp_stream()`, cannot set the
`remotely_held` status anymore.

This change moves the check so that both, `negotiate_incoming_sdp_stream()` and
`apply_negotiated_sdp_stream()` can do the checks.

ASTERISK-29479

Change-Id: Icde805a819399d5123b688e1ed1d2bcd9d5b0f75
2021-06-22 08:01:24 -05:00
Asterisk Development Team 0747162d4f Update CHANGES and UPGRADE.txt for 18.5.0 2021-06-17 09:39:40 -05:00
George Joseph 702e1d33b5 res_pjsip_messaging: Overwrite user in existing contact URI
When the MessageSend destination is in the form
PJSIP/<number>@<endpoint> and the endpoint's contact
URI already has a user component, that user component
will now be replaced with <number> when creating the
request URI.

ASTERISK_29404

Change-Id: I80e5910fa25c803d1440da0594a0d6b34b6b4ad5
2021-06-16 09:29:08 -05:00
Bernd Zobl 804788037e res_pjsip/pjsip_message_filter: set preferred transport in pjsip_message_filter
Set preferred transport when querying the local address to use in
filter_on_tx_messages(). This prevents the module to erroneously select
the wrong transport if more than one transports of the same type (TCP or
TLS) are configured.

ASTERISK-29241

Change-Id: I598e60257a7f92b29efce1fb3e9a2fc06f1439b6
2021-06-15 09:07:53 -05:00
Naveen Albert 2b174a38fe pbx_builtins: Corrects SayNumber warning
Previously, SayNumber always emitted a warning if the caller hung up
during execution. Usually this isn't correct, so check if the channel
hung up and, if so, don't emit a warning.

ASTERISK-29475

Change-Id: Ieea4a67301c6ea83bbc7690c1d4808d79a704594
2021-06-15 09:05:44 -05:00
Jaco Kroon 6b67821098 func_lock: Prevent module unloading in-use module.
The scenario where a channel still has an associated datastore we
cannot unload since there is a function pointer to the destroy and fixup
functions in play.  Thus increase the module ref count whenever we
allocate a datastore, and decrease it during destroy.

In order to tighten the race that still exists in spite of this (below)
add some extra failure cases to prevent allocations in these cases.

Race:

If module ref is zero, an LOCK or TRYLOCK is invoked (near)
simultaneously on a channel that has NOT PREVIOUSLY taken a lock, and if
in such a case the datastore is created *prior* to unloading being set
to true (first step in module unload) then it's possible that the module
will unload with the destructor being called (and segfault) post the
module being unloaded.  The module will however wait for such locks to
release prior to unloading.

If post that we can recheck the module ref before returning the we can
(in theory, I think) eliminate the last of the race.  This race is
mostly theoretical in nature.

Change-Id: I21a514a0b56755c578a687f4867eacb8b59e23cf
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-06-11 13:29:55 -05:00
Jaco Kroon 6f303335d3 func_lock: Add "dialplan locks show" cli command.
For example:

arthur*CLI> dialplan locks show
func_lock locks:
Name                                     Requesters Owner
uls-autoref                              0          (unlocked)
1 total locks listed.

Obviously other potentially useful stats could be added (eg, how many
times there was contention, how many times it failed etc ... but that
would require keeping the stats and I'm not convinced that's worth the
effort.  This was useful to troubleshoot some other issues so submitting
it.

Change-Id: Ib875e56feb49d523300aec5f36c635ed74843a9f
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-06-11 13:27:05 -05:00
Jaco Kroon a3df5d7de8 func_lock: Fix memory corruption during unload.
AST_TRAVERSE accessess current as current = current->(field).next ...
and since we free current (and ast_free poisons the memory) we either
end up on a ast_mutex_lock to a non-existing lock that can never be
obtained, or a segfault.

Incidentally add logging in the "we have to wait for a lock to release"
case, and remove an ineffective statement that sets memory that was just
cleared by ast_calloc to zero.

Change-Id: Id19ba3d9867b23d0e6783b97e6ecd8e62698b8c3
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-06-11 13:04:45 -05:00
Jaco Kroon 6bd741b77d func_lock: Fix requesters counter in error paths.
In two places we bail out with failure after we've already incremented
the requesters counter, if this occured then it would effectively result
in unload to wait indefinitely, thus preventing clean shutdown.

Change-Id: I362a6c0dc424f736d4a9c733d818e72d19675283
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-06-11 13:03:16 -05:00
Naveen Albert a611a0cd42 app_originate: Allow setting Caller ID and variables
Caller ID can now be set on the called channel and
Variables can now be set on the destination
using the Originate application, just as
they can be currently using call files
or the Manager Action.

ASTERISK-29450

Change-Id: Ia64cfe97d2792bcbf4775b3126cad662922a8b66
2021-06-11 11:29:42 -05:00
Sean Bright 26059f8616 menuselect: Fix description of several modules.
The text description needs to be the last thing on the AST_MODULE_INFO
line to be pulled in properly by menuselect.

Change-Id: I0c913e36fea8b661f42e56920b6c5513ae8fd832
2021-06-10 16:30:22 -05:00
Naveen Albert a40e58a4da app_confbridge: New ConfKick() application
Adds a new ConfKick() application, which may
be used to kick a specific channel, all channels,
or all non-admin channels from a specified
conference bridge, similar to existing CLI and
AMI commands.

ASTERISK-29446

Change-Id: I5d96b683880bfdd27b2ab1c3f2e897c5046ded9b
2021-06-08 18:15:52 -05:00
Naveen Albert 6873c5f3e4 sip_to_pjsip: Fix missing cases
Adds the "auto" case which is valid with
both chan_sip dtmfmode and chan_pjsip's
dtmf_mode, adds subscribecontext to
subscribe_context conversion, and accounts
for cipher = ALL being invalid.

ASTERISK-29459

Change-Id: Ie27d6606efad3591038000e5f3c34fa94730f6f2
2021-06-08 15:48:04 -05:00
Naveen Albert 99573f9540 res_pjsip_dtmf_info: Hook flash
Adds hook flash recognition support
for application/hook-flash.

ASTERISK-29460

Change-Id: I1d060fa89a7cf41244c98f892fff44eb1c9738ea
2021-06-08 15:46:08 -05:00
Naveen Albert a861522467 app_confbridge: New option to prevent answer supervision
A new user option, answer_channel, adds the capability to
prevent answering the channel if it hasn't already been
answered yet.

ASTERISK-29440

Change-Id: I26642729d0345f178c7b8045506605c8402de54b
2021-06-08 14:46:14 -05:00
George Joseph 8e2672d2a4 res_pjsip_messaging: Refactor outgoing URI processing
* Implemented the new "to" parameter of the MessageSend()
   dialplan application.  This allows a user to specify
   a complete SIP "To" header separate from the Request URI.

 * Completely refactored the get_outbound_endpoint() function
   to actually handle all the destination combinations that
   we advertized as supporting.

 * We now also accept a destination in the same format
   as Dial()...  PJSIP/number@endpoint

 * Added lots of debugging.

ASTERISK-29404
Reported by Brian J. Murrell

Change-Id: I67a485196d9199916468f7f98bfb9a0b993a4cce
2021-05-27 11:16:24 -05:00
Naveen Albert 9106c9d1f1 func_math: Three new dialplan functions
Introduces three new dialplan functions, MIN and MAX,
which can be used to calculate the minimum or
maximum of up to two numbers, and ABS, an absolute
value function.

ASTERISK-29431

Change-Id: I2bda9269d18f9d54833c85e48e41fce0e0ce4d8d
2021-05-26 13:47:56 -05:00
Ben Ford 26a38c4084 STIR/SHAKEN: Add Date header, dest->tn, and URL checking.
STIR/SHAKEN requires a Date header alongside the Identity header, so
that has been added. Still on the outgoing side, we were missing the
dest->tn section of the JSON payload, so that has been added as well.
Moving to the incoming side, URL checking has been added to the public
cert URL to ensure that it starts with http.

https://wiki.asterisk.org/wiki/display/AST/OpenSIPit+2021

Change-Id: Idee5b1b5e45bc3b483b3070e46ce322dca5b3f1c
2021-05-26 12:33:06 -05:00
Joshua C. Colp 16e4a9d8cf res_pjsip: On partial transport reload also move factories.
For connection oriented transports PJSIP uses factories to
produce transports. When doing a partial transport reload
we need to also move the factory of the transport over so
that anything referencing the transport (such as an endpoint)
has the factory available.

ASTERISK-29441

Change-Id: Ieae0fb98eab2d9257cad996a1136e5a62d307161
2021-05-26 11:37:06 -05:00
Naveen Albert 033c2a2283 func_volume: Add read capability to function.
Up until now, the VOLUME function has been write
only, so that TX/RX values can be set but not
read afterwards. Now, previously set TX/RX values
can be read later.

ASTERISK-29439

Change-Id: Ia23e92fa2e755c36e9c8e69f2940d2703ccccb5f
2021-05-26 11:25:23 -05:00
Evgenios_Greek 59d15c4c2a stasis: Fix "FRACK!, Failed assertion bad magic number" when unsubscribing
When unsubscribing from an endpoint technology a FRACK
would occur due to incorrect reference counting. This fixes
that issue, along with some other issues.

Fixed a typo in get_subscription when calling ao2_find as it
needed to pass the endpoint ID and not the entire object.

Fixed scenario where a subscription would get returned when
it shouldn't have been when searching based on endpoint
technology.

A doulbe unreference has also been resolved by only explicitly
releasing the reference held by tech_subscriptions.

ASTERISK-28237 #close
Reported by: Lucas Tardioli Silveira

Change-Id: Ia91b15f8e5ea68f850c66889a6325d9575901729
2021-05-26 11:10:13 -05:00
Joseph Nadiv b21d4d1b87 res_pjsip.c: Support endpoints with domain info in username
In multidomain environments, it is desirable to create
PJSIP endpoints with the domain info in the endpoint name
in pjsip_endpoint.conf.  This resulted in an error with
registrations, NOTIFY, and OPTIONS packet generation.

This commit will detect if there is an @ in the endpoint
identifier and generate the URI accordingly so NOTIFY and
OPTIONS From headers will generate correctly.

ASTERISK-28393

Change-Id: I96f8d01dfdd5573ba7a28299e46271dd4210b619
2021-05-26 10:36:59 -05:00
Joshua C. Colp 3aed363716 res_rtp_asterisk: Set correct raddr port on RTCP srflx candidates.
RTCP ICE candidates use a base address derived from the RTP
candidate. The port on the base address was not being updated to
the RTCP port.

This change sets the base port to the RTCP port and all is well.

ASTERISK-29433

Change-Id: Ide2d2115b307bfd3c2dfbc4d187515d724519040
2021-05-26 10:26:23 -05:00
Joshua C. Colp 60ed1847b8 asterisk: We've moved to Libera Chat!
Change-Id: I48c1933dd79b50ddc0a6793acec4754b4e95c575
2021-05-25 09:20:30 -05:00
Jeremy Lainé 0f8e2174a7 res_rtp_asterisk: make it possible to remove SOFTWARE attribute
By default Asterisk reports the PJSIP version in a SOFTWARE attribute
of every STUN packet it sends. This may not be desired in a production
environment, and RFC5389 recommends making the use of the SOFTWARE
attribute a configurable option:

https://datatracker.ietf.org/doc/html/rfc5389#section-16.1.2

This patch adds a `stun_software_attribute` yes/no option to make it
possible to omit the SOFTWARE attribute from STUN packets.

ASTERISK-29434

Change-Id: Id3f2b1dd9584536ebb3a1d7e8395fd8b3e46860b
2021-05-21 10:36:38 -05:00
George Joseph 655ee680cd res_pjsip_outbound_authenticator_digest: Be tolerant of RFC8760 UASs
RFC7616 and RFC8760 allow more than one WWW-Authenticate or
Proxy-Authenticate header per realm, each with different digest
algorithms (including new ones like SHA-256 and SHA-512-256).
Thankfully however a UAS can NOT send back multiple Authenticate
headers for the same realm with the same digest algorithm.  The
UAS is also supposed to send the headers in order of preference
with the first one being the most preferred.  We're supposed to
send an Authorization header for the first one we encounter for a
realm that we can support.

The UAS can also send multiple realms, especially when it's a
proxy that has forked the request in which case the proxy will
aggregate all of the Authenticate headers and then send them all
back to the UAC.

It doesn't stop there though... Each realm can require a
different username from the others.  There's also nothing
preventing each digest algorithm from having a unique password
although I'm not sure if that adds any benefit.

So now... For each Authenticate header we encounter, we have to
determine if we support the digest algorithm and, if not, just
skip the header.  We then have to find an auth object that
matches the realm AND the digest algorithm or find a wildcard
object that matches the digest algorithm. If we find one, we add
it to the results vector and read the next Authenticate header.
If the next header is for the same realm AND we already added an
auth object for that realm, we skip the header. Otherwise we
repeat the process for the next header.

In the end, we'll have accumulated a list of credentials we can
pass to pjproject that it can use to add Authentication headers
to a request.

NOTE: Neither we nor pjproject can currently handle digest
algorithms other than MD5.  We don't even have a place for it in
the ast_sip_auth object. For this reason, we just skip processing
any Authenticate header that's not MD5.  When we support the
others, we'll move the check into the loop that searches the
objects.

Changes:

 * Added a new API ast_sip_retrieve_auths_vector() that takes in
   a vector of auth ids (usually supplied on a call to
   ast_sip_create_request_with_auth()) and populates another
   vector with the actual objects.

 * Refactored res_pjsip_outbound_authenticator_digest to handle
   multiple Authenticate headers and set the stage for handling
   additional digest algorithms.

 * Added a pjproject patch that allows them to ignore digest
   algorithms they don't support.  This patch has already been
   merged upstream.

 * Updated documentation for auth objects in the XML and
   in pjsip.conf.sample.

 * Although res_pjsip_authenticator_digest isn't affected
   by this change, some debugging and a testsuite AMI event
   was added to facilitate testing.

Discovered during OpenSIPit 2021.

ASTERISK-29397

Change-Id: I3aef5ce4fe1d27e48d61268520f284d15d650281
2021-05-20 14:21:02 -05:00
Joseph Nadiv 83c2a16b2e res_pjsip_dialog_info_body_generator: Add LOCAL/REMOTE tags in dialog-info+xml
RFC 4235 Section 4.1.6 describes XML elements that should be
sent to subscribed endpoints to identify the local and remote
participants in the dialog.

This patch adds this functionality to PJSIP by iterating through the
ringing channels causing the NOTIFY, and inserts the channel info
into the dialog so that information is properly passed to the endpoint
in dialog-info+xml.

ASTERISK-24601
Patch submitted: Joshua Elson
Modified by: Joseph Nadiv and Sean Bright
Tested by: Joseph Nadiv

Change-Id: I20c5cf5b45f34d7179df6573c5abf863eb72964b
2021-05-19 08:10:25 -05:00
Naveen Albert bfc25e5de2 app_voicemail: Configurable voicemail beep
Hitherto, VoiceMail() played a non-customizable beep tone to indicate
the caller could leave a message. In some cases, the beep may not
be desired, or a different tone may be desired.

To increase flexibility, a new option allows customization of the tone.
If the t option is specified, the default beep will be overridden.
Supplying an argument will cause it to use the specified file for the tone,
and omitting it will cause it to skip the beep altogether. If the option
is not used, the default behavior persists.

ASTERISK-29349

Change-Id: I1c439c0011497e28a28067fc1cf1e654c8843280
2021-05-19 08:03:48 -05:00
Naveen Albert 0ad3504ce0 AMI: Add AMI event to expose hook flash events
Although Asterisk can receive and propogate flash events, it currently
provides no mechanism for doing anything with them itself.

This AMI event allows flash events to be processed by Asterisk.
Additionally, AST_CONTROL_FLASH is included in a switch statement
in channel.c to avoid throwing a warning when we shouldn't.

ASTERISK-29380

Change-Id: Ie17ffe65086e0282c88542e38eed6a461ec79e81
2021-05-19 08:02:15 -05:00
Naveen Albert 7b82587dd6 chan_sip: Expand hook flash recognition.
Some ATAs send hook flash events as application/hook-flash, rather than a DTMF
event. Now, we also recognize hook-flash as a flash event.

ASTERISK-29370

Change-Id: I1c3b82a040dff3affcd94bad8ce33edc90c04725
2021-05-17 08:55:38 -05:00
Joshua C. Colp 6d5cac1d10 pjsip: Add patch for resolving STUN packet lifetime issues.
In some cases it was possible for a STUN packet to be destroyed
prematurely or even destroyed partially multiple times.

This patch provided by Teluu fixes the lifetime of these
packets and ensures they aren't partially destroyed multiple
times.

https://github.com/pjsip/pjproject/pull/2709

ASTERISK-29377

Change-Id: Ie842ad24ddf345e01c69a4d333023f05f787abca
2021-05-17 08:54:34 -05:00
Naveen Albert 283fa3a93b main/file.c: Don't throw error on flash event.
AST_CONTROL_FLASH isn't accounted for in a switch statement in file.c
where it should be ignored. Adding this to the switch ensures a
warning isn't thrown on RFC2833 flash events, since nothing's amiss.

ASTERISK-29372

Change-Id: I4fa549bfb7ba1894a4044de999ea124877422fbc
2021-05-13 10:17:43 -05:00
Sean Bright 78d7862463 chan_pjsip: Correct misleading trace message
ASTERISK-29358 #close

Change-Id: I050daff67066873df4e8fc7f4bd977c1ca06e647
2021-05-12 22:20:23 -04:00
Ben Ford a84d34035a STIR/SHAKEN: Switch to base64 URL encoding.
STIR/SHAKEN encodes using base64 URL format. Currently, we just use
base64. New functions have been added that convert to and from base64
encoding.

The origid field should also be an UUID. This means there's no reason to
have it as an option in stir_shaken.conf, as we can simply generate one
when creating the Identity header.

https://wiki.asterisk.org/wiki/display/AST/OpenSIPit+2021

Change-Id: Icf094a2a54e87db91d6b12244c9f5ba4fc2e0b8c
2021-05-11 15:36:22 -05:00
Ben Ford e0cbdfe063 STIR/SHAKEN: OPENSSL_free serial hex from openssl.
We're getting the serial number of the certificate from openssl and
freeing it with ast_free(), but it needs to be freed with OPENSSL_free()
instead. Now we duplicate the string and free the one from openssl with
OPENSSL_free(), which means we can still use ast_free() on the returned
string.

https://wiki.asterisk.org/wiki/display/AST/OpenSIPit+2021

Change-Id: Ia6e1a4028c1933a0e1d204b769ebb9f5a11f00ab
2021-05-11 13:15:58 -05:00
Ben Ford 5e6508b56f STIR/SHAKEN: Fix certificate type and storage.
During OpenSIPit, we found out that the public certificates must be of
type X.509. When reading in public keys, we use the corresponding X.509
functions now.

We also discovered that we needed a better naming scheme for the
certificates since certificates with the same name would cause issues
(overwriting certs, etc.). Now when we download a public certificate, we
get the serial number from it and use that as the name of the cached
certificate.

The configuration option public_key_url in stir_shaken.conf has also
been renamed to public_cert_url, which better describes what the option
is for.

https://wiki.asterisk.org/wiki/display/AST/OpenSIPit+2021

Change-Id: Ia00b20835f5f976e3603797f2f2fb19672d8114d
2021-05-11 09:29:38 -05:00
George Joseph 40bdfff73b Updates for the MessageSend Dialplan App
Enhancements:

 * The MessageSend dialplan application now takes an optional
   third argument that can set the message's "To" field on
   outgoing messages.  It's an alternative to using the
   MESSAGE(to) dialplan function.

   NOTE: No channel driver currently implements this field.  A
   follow-on commit for res_pjsip_messaging will implement it for
   the chan_pjsip channel driver.

 * To prevent confusion with the first argument, currently named
   "to", it's been renamed to "destination". Its function,
   creating the request URI, hasn't changed.

 * The documentation for MessageSend was updated to be
   more clear about the parameters and how they interact
   the MESSAGE() dialplan function.

 * With the rename of MessageSend's first parameter, and the fact
   that message.c references <info> elements in chan_sip.c,
   res_pjsip_messaging.c and res_xmpp, they each needed
   documentation updates to use MessageDestinationInfo instead of
   MessageToInfo.

 * appdocsxml.dtd was updated to include a missing element
   declaration for "dataType".  This was showing up as an error
   in Eclipse's dtd editor.

 * Despite the changes in this commit, there should be
   no impact to current users of MessageSend.

Change-Id: I6fb5b569657a02866a66ea352fd53d30d8ac965a
2021-05-04 08:07:39 -05:00
Sean Bright 78f518622d translate.c: Avoid refleak when checking for a translation path
Change-Id: Idbd61ff77545f4a78b06a5064b55112e774b70e6
2021-04-30 15:31:58 -05:00
Joshua C. Colp 8faed04b01 chan_local: Skip filtering audio formats on removed streams.
When a stream topology is provided to chan_local when dialing
it filters the audio formats down. This operation did not skip
streams which were removed (that have no formats) resulting in
calling being aborted.

This change causes such streams to be skipped.

ASTERISK-29407

Change-Id: I1de8b98727cb2d10f4bc287da0b5fdcb381addd6
2021-04-30 09:02:50 -05:00
Sean Bright 95414fc918 res_rtp_asterisk: More robust timestamp checking
We assume that a timestamp value of 0 represents an 'uninitialized'
timestamp, but 0 is a valid value. Add a simple wrapper to be able to
differentiate between whether the value is set or not.

This also removes the fix for ASTERISK~28812 which should not be
needed if we are checking the last timestamp appropriately.

ASTERISK-29030 #close

Change-Id: Ie70d657d580d9a1f2877e25a6ef161c5ad761cf7
2021-04-30 09:00:31 -05:00
Asterisk Development Team 1949d828b7 Update CHANGES and UPGRADE.txt for 18.4.0 2021-04-29 10:25:55 -05:00
Sean Bright d2dcd15bd8 res_pjsip.c: OPTIONS processing can now optionally skip authentication
ASTERISK-27477 #close

Change-Id: I68f6715bba92a525149e35d142a49377a34a1193
2021-04-29 07:45:04 -05:00
Jean Aunis dec44306cf translate.c: Take sampling rate into account when checking codec's buffer size
Up/down sampling changes the number of samples produced by a translation.
This must be taken into account when checking the codec's buffer size.

ASTERISK-29328

Change-Id: I9aebe2f8788e00321a7f5c47aa97c617f39e9055
2021-04-28 01:16:07 -05:00
Joshua C. Colp c2f4925ee0 svn: Switch to https scheme.
Some versions of SVN seemingly don't follow the redirect
to https.

Change-Id: Ia7c76c18cb620bcf56f08e1211a7d80d321fe253
2021-04-25 04:46:37 -05:00
George Joseph 5f3d96a765 res_pjsip: Update documentation for the auth object
Change-Id: I2f76867ce02ec611964925159be099de83346e38
2021-04-21 08:30:43 -06:00
George Joseph 88aec107df bridge_channel_write_frame: Check for NULL channel
There is a possibility, when bridge_channel_write_frame() is
called, that the bridge_channel->chan will be NULL.  The first
thing bridge_channel_write_frame() does though is call
ast_channel_is_multistream() which had no check for a NULL
channel and therefore caused a segfault. Since it's still
possible for bridge_channel_write_frame() to write the frame to
the other channels in the bridge, we don't want to bail before we
call ast_channel_is_multistream() but we can just skip the
multi-channel stuff.  So...

bridge_channel_write_frame() only calls ast_channel_is_multistream()
if bridge_channel->chan is not NULL.

As a safety measure, ast_channel_is_multistream() now returns
false if the supplied channel is NULL.

ASTERISK-29379
Reported-by: Vyrva Igor
Reported-by: Ross Beer

Change-Id: Idfe62dbea8c69813ecfd58e113a6620dc42352ce
2021-04-05 07:50:28 -05:00
Sean Bright 404533c149 loader.c: Speed up deprecation metadata lookup
Only use an XPath query once per module, then just navigate the DOM for
everything else.

Change-Id: Ia0336a7185f9180ccba4b6f631a00f9a22a36e92
2021-04-02 12:57:41 -05:00
George Joseph 19eef2a6dc res_prometheus: Clone containers before iterating
The channels, bridges and endpoints scrape functions were
grabbing their respective global containers, getting the
count of entries, allocating metric arrays based on
that count, then iterating over the container.  If the
global container had new objects added after the count
was taken and the metric arrays were allocated, we'd run
out of metric entries and attempt to write past the end
of the arrays.

Now each of the scape functions clone their respective
global containers and all operations are done on the
clone.  Since the clone is stable between getting the
count and iterating over it, we can't run past the end
of the metrics array.

ASTERISK-29130
Reported-By: Francisco Correia
Reported-By: BJ Weschke
Reported-By: Sébastien Duthil

Change-Id: If0c8e40853bc0e9429f2ba9c7f5f358d90c311af
2021-04-02 07:38:57 -05:00
Joshua C. Colp a9a9864478 loader: Output warnings for deprecated modules.
Using the information from the MODULEINFO XML we can
now output useful information at the end of module
loading for deprecated modules. This includes the
version it was deprecated in, the version it will be
removed in, and the replacement if available.

ASTERISK-29339

Change-Id: I2080dab97d2186be94c421b41dabf6d79a11611a
2021-04-01 09:48:13 -05:00
Kevin Harwell 17c86dcfaa res_rtp_asterisk: Fix standard deviation calculation
For some input to the standard deviation algorithm extremely large,
and wrong numbers were being calculated.

This patch uses a new formula for correctly calculating both the
running mean and standard deviation for the given inputs.

ASTERISK-29364 #close

Change-Id: Ibc6e18be41c28bed3fde06d612607acc3fbd621f
2021-04-01 08:43:07 -05:00
Kevin Harwell 0ad1ff8a72 res_rtp_asterisk: Don't count 0 as a minimum lost packets
The calculated minimum lost packets represents the lowest number of
lost packets missed during an RTCP report interval. Zero of course
is the lowest, but the idea is that this value contain the lowest
number of lost packets once some have been missed.

This patch checks to make sure the number of lost packets over an
interval is not zero before checking and setting the minimum value.

Also, this patch updates the rtp lost packet test to check for
packet loss over several reports vs one.

Change-Id: I07d6e21cec61e289c2326138d6bcbcb3c3d5e008
2021-03-31 15:08:38 -05:00
Kevin Harwell 1414b9cc57 res_rtp_asterisk: Statically declare rtp_drop_packets_data object
This patch makes the drop_packets_data object static.

Change-Id: If4f9b21fa0c47d41a35b6b05941d978efb4da87b
2021-03-31 14:07:46 -06:00
Joshua C. Colp b0d828f14a res_rtp_asterisk: Only raise flash control frame on end.
Flash in RTP is conveyed the same as DTMF, just with a
specific digit. In Asterisk however we do flash as a
single control frame.

This change makes it so that only on end do we provide
the flash control frame to the core. Previously we would
provide a flash control frame on both begin and end,
causing flash to work improperly.

ASTERISK-29373

Change-Id: I1accd9c6e859811336e670e698bd8bd124f33226
2021-03-31 11:54:54 -05:00
Kevin Harwell b912b31853 res_rtp_asterisk: Add a DEVMODE RTP drop packets CLI command
This patch makes it so when Asterisk is compiled in DEVMODE a CLI
command is available that allows someone to drop incoming RTP
packets. The command allows for dropping of packets once, or on a
timed interval (e.g. drop 10 packets every 5 seconds). A user can
also specify to drop packets by IP address.

Change-Id: I25fa7ae9bad6ed68e273bbcccf0ee51cae6e7024
2021-03-31 11:23:03 -05:00
Joshua C. Colp 65a4a3a4e6 res_pjsip: Give error when TLS transport configured but not supported.
Change-Id: I058af496021ff870ccec2d8cbade637b348ab80b
2021-03-31 10:17:38 -05:00
Kevin Harwell 15de2f1727 time: Add timeval create and unit conversion functions
Added a TIME_UNIT enumeration, and a function that converts a
string to one of the enumerated values. Also, added functions
that create and initialize a timeval object using a specified
value, and unit type.

Change-Id: Ic31a1c3262a44f77a5ef78bfc85dcf69a8d47392
2021-03-31 09:31:06 -05:00
Sean Bright 35302efe73 app_queue: Add alembic migration to add ringinuse to queue_members.
ASTERISK-28356 #close

Change-Id: I53a1bfdd3113d620bea88349019173a2f3f0ae39
2021-03-30 04:47:14 -05:00
Sean Bright be3153346b modules.conf: Fix more differing usages of assignment operators.
I missed the changes in 18 and master in the previous review.

ASTERISK-24434 #close

Change-Id: Ieb132b2a998ce96daa9c9acf26535a974b895876
2021-03-28 11:47:35 -04:00
Ben Ford bbfb8f2b9d logger.conf.sample: Add more debug documentation.
Change-Id: Iff0e713f2120d8dce8e1e26924b99ed17f9d9dff
2021-03-25 09:27:43 -05:00
Sean Bright 31364fa4c8 queues.conf.sample: Correct 'context' documentation.
ASTERISK-24631 #close

Change-Id: I8bf8776906a72ee02f24de6a85345940b9ff6b6f
2021-03-25 08:41:32 -05:00
Sean Bright e27fa9eceb app_queue.c: Remove dead 'updatecdr' code.
Also removed the sample documentation, and some oddly-placed
documentation about the timeout argument to the Queue() application
itself. There is a large section on the timeout behavior below.

ASTERISK-26614 #close

Change-Id: I8f84e8304b50305b7c4cba2d9787a5d77c3a6217
2021-03-23 16:26:44 -04:00
Mark Murawski a0009c807e logger: Console sessions will now respect logger.conf dateformat= option
The 'core' console (ie: asterisk -c) does read logger.conf and does
use the dateformat= option.

Whereas 'remote' consoles (ie: asterisk -r -T) does not read logger.conf
and uses a hard coded dateformat option for printing received verbose messages:
  main/logger.c: static char dateformat[256] = "%b %e %T"

This change will load logger.conf for each remote console session and
use the dateformat= option to set the per-line timestamp for verbose messages

Change-Id: I3ea10990dbd920e9f7ce8ff771bc65aa7f4ea8c1
ASTERISK-25358: #close
Reported-by: Igor Liferenko
2021-03-22 11:18:01 -05:00
Sean Bright 4393207751 app_queue.c: Don't crash when realtime queue name is empty.
ASTERISK-27542 #close

Change-Id: If0b9719380a25533d2aed1053cff845dc3a4854a
2021-03-22 09:41:39 -05:00
George Joseph c78d0ce429 res_pjsip_session: Make reschedule_reinvite check for NULL topologies
When the check for equal topologies was added to reschedule_reinvite()
it was assumed that both the pending and active media states would
actually have non-NULL topologies.  We since discovered this isn't
the case.

We now only test for equal topologies if both media states have
non-NULL topologies.  The logic had to be rearranged a bit to make
sure that we cloned the media states if their topologies were
non-NULL but weren't equal.

ASTERISK-29215

Change-Id: I61313cca7fc571144338aac826091791b87b6e17
2021-03-22 09:40:13 -05:00
Joshua C. Colp 55c467eab1 app_queue: Only send QueueMemberStatus if status changes.
If a queue member was updated with the same status multiple
times each time a QueueMemberStatus event would be sent
which would be a duplicate of the previous.

This change makes it so that the QueueMemberStatus event is
only sent if the status actually changes.

ASTERISK-29355

Change-Id: I580c60d992a0a8f2bea8b91c868771b3b490d116
2021-03-22 07:51:21 -05:00
Joshua C. Colp ed2f637b47 core_unreal: Fix deadlock with T.38 control frames.
When using the ast_unreal_lock_all function no channel
locks can be held before calling it.

This change unlocks the channel that indicate was
called on before doing so and then relocks it afterwards.

ASTERISK-29035

Change-Id: Id65016201b5f9c9519a216e250f9101c629e19e9
2021-03-22 07:50:04 -05:00
Joshua C. Colp f213833514 res_pjsip: Add support for partial transport reload.
Some configuration items for a transport do not result in
the underlying transport changing, but instead are just
state we keep ourselves and use. It is perfectly reasonable
to change these items.

These include local_net and external_* information.

ASTERISK-29354

Change-Id: I027857ccfe4419f460243e562b5f098434b3d43a
2021-03-22 04:08:15 -05:00
Jaco Kroon f47c5cbdf9 menuselect: exit non-zero in case of failure on --enable|disable options.
ASTERISK-29348

Change-Id: I77e3466435f5a51a57538b29addb68d811af238d
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-03-19 08:13:51 -05:00
Joshua C. Colp 2e7fc84398 res_rtp_asterisk: Force resync on SSRC change.
When an SSRC change occurs the timestamps are likely
to change as well. As a result we need to reset the
timestamp mapping done in the calc_rxstamp function
so that they map properly from timestamp to real
time.

This previously occurred but due to packet
retransmission support the explicit setting
of the marker bit was not effective.

ASTERISK-29352

Change-Id: I2d4c8f93ea24abc1030196706de2d70facf05a5a
2021-03-17 11:43:19 -06:00
Joshua C. Colp 6aac148d59 menuselect: Add ability to set deprecated and removed versions.
The "deprecated_in" and "removed_in" information can now be
set in MODULEINFO for a module and is then displayed in
menuselect so users can be aware of when a module is slated
to be deprecated and then removed.

ASTERISK-29337

Change-Id: I6952889cf08e0e9e99cf8b43f99b3cef4688087a
2021-03-17 10:07:35 -05:00
Joshua C. Colp be3e469f98 documentation: Fix non-matching module support levels.
Some modules have a different support level documented in their
MODULEINFO XML and Asterisk module definition. This change
brings the two in sync for the modules which were not matching.

ASTERISK-29336

Change-Id: If2f819103d4a271e2e0624ef4db365e897fa3d35
2021-03-16 11:04:45 -05:00
Joshua C. Colp 60fb559ccc xml: Allow deprecated_in and removed_in for MODULEINFO.
ASTERISK-29337

Change-Id: I2211b7da8d29369f8649aeabce07679da0787f2b
2021-03-16 10:34:56 -05:00
Joshua C. Colp 60800b038a xml: Embed module information into core XML documentation.
This change embeds the MODULEINFO block of modules
into the core XML documentation. This provides a shared
mechanism for use by both menuselect and Asterisk for
information and a definitive source of truth.

ASTERISK-29335

Change-Id: Ifbfd5c700049cf320a3e45351ac65dd89bc99d90
2021-03-16 10:31:16 -05:00
Kevin Harwell 263f906af4 manager: Increase the non breaking AMI version number
ASTERISK~29244 added three new AMI events, so bump the version number.

Change-Id: I0e77fa36d38fb27dec3481d4ef08131330da0632
2021-03-11 10:54:53 -06:00
Asterisk Development Team 0afd37e3b5 Update CHANGES and UPGRADE.txt for 18.3.0 2021-03-11 11:40:29 -05:00
Joshua C. Colp f7bda066bb channel: Fix crash in suppress API.
There exists an inconsistency with framehook usage
such that it is only on reads that the frame should
be freed, not on writes as well.

ASTERISK-29071

Change-Id: I5ef918ebe4debac8a469e8d43bf9d6b673e8e472
2021-03-10 11:08:08 -06:00
Jaco Kroon 23e41313a8 func_callerid+res_agi: Fix compile errors related to -Werror=zero-length-bounds
Change-Id: I75152cece8a00b7523d542e5ac22796f9595692b
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-03-10 08:57:16 -06:00
Jaco Kroon 52707fba7f app.h: Fix -Werror=zero-length-bounds compile errors in dev mode.
Change-Id: I5c104dc1f8417ccd3d01faf86e84ccbf89bc3b31
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-03-10 04:24:27 -06:00
Sean Bright 94debe5085 app_dial.c: Only send DTMF on first progress event.
ASTERISK-29329 #close

Change-Id: Ic58e7a17f1ff3f785a5b21dced88682581149601
2021-03-10 04:23:25 -06:00
Alexander Traud 262473c6d9 res_format_attr_*: Parameter Names are Case-Insensitive.
see RFC 4855:
parameter names are case-insensitive both in media type strings and
in the default mapping to the SDP a=fmtp attribute.

This change is required for H.263+ because some implementations are
known to use even mixed-case. This does not fix ASTERISK~29268 because
H.264 was not fixed. This approach here lowers/uppers both parameter
names and parameter values. H.264 needs a different approach because
one of its parameter values is not case-insensitive:
sprop-parameter-sets is Base64.

Change-Id: Idf2a73457be231647aed3c87b1da197afba86892
2021-03-10 04:22:18 -06:00
Alexander Traud 4fc0e16838 chan_iax2: System Header strings is included via asterisk.h/compat.h.
The system header strings was included mistakenly with commit 3de0204.
That header is included via asterisk.h and there via the compat.h.

Change-Id: I3dc49060e275295f785670c87cc65fd3c3abd24a
2021-03-10 04:21:27 -06:00
Sean Bright 3084084648 modules.conf: Fix differing usage of assignment operators.
ASTERISK-24434 #close

Change-Id: I0144e8d65d878128da59dcf3df12ca8cee47d6db
2021-03-10 04:20:04 -06:00
Sean Bright e4cd7a7d0b strings.h: ast_str_to_upper() and _to_lower() are not pure.
Because they modify their argument they are not pure functions and
should not be marked as such, otherwise the compiler may optimize
them away.

ASTERISK-29306 #close

Change-Id: Ibec03a08522dd39e8a137ece9bc6a3059dfaad5f
2021-03-10 04:18:36 -06:00
Sean Bright 16e4d1f36f res_musiconhold.c: Plug ref leak caused by ao2_replace() misuse.
ao2_replace() bumps the reference count of the object that is doing the
replacing, which is not what we want. We just want to drop the old ref
on the old object and update the pointer to point to the new object.

Pointed out by George Joseph in #asterisk-dev

Change-Id: Ie8167ed3d4b52b9d1ea2d785f885e8c27206743d
2021-03-08 17:21:29 -06:00
Torrey Searle 90ef6a14a7 res/res_rtp_asterisk: generate new SSRC on native bridge end
For RTCP to work, we update the ssrc to be the one corresponding to
the native bridge while active.  However when the bridge ends we
should generate a new SSRC as the sequence numbers will not continue
from the native bridge left off.

ASTERISK-29300 #close

Change-Id: I23334b6934d2bf6490bda4bbf6414d96b8d17d10
2021-03-08 08:13:51 -06:00
Joshua C. Colp a9acbd19f3 sorcery: Add support for more intelligent reloading.
Some sorcery objects actually contain dynamic content
that can change despite the underlying configuration
itself not changing. A good example of this is the
res_pjsip_endpoint_identifier_ip module which allows
specifying hostnames. While the configuration may not
change between reloads the DNS information of the
hostnames can.

This change adds the ability for a sorcery object to be
marked as having dynamic contents which is then taken
into account when reloading by the sorcery file based
config module. If there is an object with dynamic content
then a reload will be forced while if there are none
then the existing behavior of not reloading occurs.

ASTERISK-29321

Change-Id: I9342dc55be46cc00204533c266a68d972760a0b1
2021-03-05 10:33:10 -06:00
George Joseph 269bb08ea2 res_pjsip_refer: Move the progress dlg release to a serializer
Although the dlg session count was incremented in a pjsip servant
thread, there's no guarantee that the last thread to unref this
progress object was one.  Before we decrement, we need to make
sure that this is either a servant thread or that we push the
decrement to a serializer that is one.

Because pjsip_dlg_dec_session requires the dialog lock, we don't
want to wait on the task to complete if we had to push it to a
serializer.

Change-Id: I8ff2d5d94be3ff04298394070434e22a7d3cbc41
2021-03-05 08:18:55 -06:00
Joshua C. Colp 5f1c21e4ca res_pjsip_registrar: Include source IP and port in log messages.
When registering it can be useful to see the source IP address and
port in cases where multiple devices are using the same endpoint
or when anonymous is in use.

ASTERISK-29325

Change-Id: Ie178a6f55f53f8473035854c411bc3d056e0a2e0
2021-03-05 08:14:01 -06:00
Joshua C. Colp 682f7d9437 asterisk: Update copyright.
ASTERISK-29326

Change-Id: Ia95dbfb66e2d11ac4d1228444283bb2e4d77396a
2021-03-04 13:47:51 -06:00
Ben Ford 77328142b4 AST-2021-006 - res_pjsip_t38.c: Check for session_media on reinvite.
When Asterisk sends a reinvite negotiating T38 faxing, it's possible a
crash can occur if the response contains a m=image and zero port. The
reinvite callback code now checks session_media to see if it is null or
not before trying to access the udptl variable on it.

ASTERISK-29305

Change-Id: I1dfc51c5fa586e38579ede4bc228edee213ccaa9
2021-03-04 07:57:25 -07:00
Alexander Traud 0323293142 res_format_attr_h263: Generate valid SDP fmtp for H.263+.
Fixed:
* RFC 4629 does not allow the value "0" for MPI, K, and N.
* Allow value "0" for PAR.
* BPP is printed only when specified because "0" has a meaning.

New:
* Added CPCF and MaxBR.
* Some implementations provide CIF without MPI: a=fmtp:xx CIF;F=1
  Although a violation of RFC 3555 section 3, we can support that.

Changed:
* Resorts the CIFs from large to small which partly fixes ASTERISK~29267.

Change-Id: I95a650c715007b8dde11a77cb37d9c6c123a441e
2021-03-03 12:27:52 -06:00
Joshua C. Colp 976b1a1d7a res_pjsip_nat: Don't rewrite Contact on REGISTER responses.
When sending a SIP response to an incoming REGISTER request
we don't want to change the Contact header as it will
contain the Contacts registered to the AOR and not our own
Contact URI.

ASTERISK-29235

Change-Id: I35a0723545281dd01fcd5cae497baab58720478c
2021-03-03 12:27:32 -06:00
Joshua C. Colp b43b81d953 channel: Fix memory leak in suppress API.
A frame suppression API exists as part of channels
which allows audio frames to or from a channel to
be dropped. The MuteAudio AMI action uses this
API to perform its job.

This API uses a framehook to intercept flowing
audio and drop it when appropriate. It is the
responsibility of the framehook to free the
frame it is given if it changes the frame. The
suppression API failed to do this resulting in
a leak of audio frames.

This change adds the freeing of these frames.

ASTERISK-29071

Change-Id: Ie50acd454d672d36af914050c327d2e120d8ba7b
2021-03-03 10:15:03 -06:00
Salah Ahmed df8d335ad1 res_rtp_asterisk: Check remote ICE reset and reset local ice attrb
This change will check is the remote ICE session got reset or not by
checking the offered ufrag and password with session. If the remote ICE
reset session then Asterisk reset its local ufrag and password to reject
binding request with Old ufrag and Password.

ASTERISK-29266

Change-Id: I9c55e79a7af98a8fbb497d336b828ba41bc34eeb
2021-03-03 09:54:06 -06:00
Holger Hans Peter Freyther 3286c04856 pjsip: Generate progress (once) when receiving a 180 with a SDP
ASTERISK-29105

Change-Id: If1615fe7115fe544ef974b044d3cea5c48b94a38
2021-03-02 11:22:44 -06:00
Nico Kooijman 7b052ec965 main: With Dutch language year after 2020 is not spoken in say.c
Implemented the english way of saying the year in ast_say_date_with_format_nl.
Currently the numbers are spoken correctly until 2020 and stopped working
this year.

ASTERISK-29297 #close
Reported-by: Jacek Konieczny

Change-Id: If5918eed5ab05df31df4dd23f08a909a60f6aba4
2021-03-02 11:19:51 -06:00
Nick French dedfb334bd res_pjsip: dont return early from registration if init auth fails
If set_outbound_initial_authentication_credentials() fails,
handle_client_registration() bails early without creating or
sending a register message.

[set_outbound_initial_authentication_credentials() failures
can occur during the process of retrieving an oauth access
token.]

The return from handle_client_registration is ignored, so
returning an error doesn't do any good.

This is a real problem when the registration request is a
re-register, because then the registration will still be
marked 'active' despite the re-register never being sent at all.

So instead, log a warning but let the registration be created
and sent (and probably fail) and follow the normal registration
failed retry/abort logic.

ASTERISK-29315 #close

Change-Id: I2e03b1ea7fba1fa1a8279086aa4b17679e7fa7fa
2021-03-02 11:17:49 -06:00
Alexei Gradinari d5e73d2121 res_fax: validate the remote/local Station ID for UTF-8 format
If the remote Station ID contains invalid UTF-8 characters
the asterisk fails to publish the Stasis and ReceiveFax status messages.

json.c: Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.
0: /usr/sbin/asterisk(ast_json_vpack+0x98) [0x4f3f28]
1: /usr/sbin/asterisk(ast_json_pack+0x8c) [0x4f3fcc]
2: /usr/sbin/asterisk(ast_channel_publish_varset+0x2b) [0x57aa0b]
3: /usr/sbin/asterisk(pbx_builtin_setvar_helper+0x121) [0x530641]
4: /usr/lib64/asterisk/modules/res_fax.so(+0x44fe) [0x7f27f4bff4fe]
...
stasis_channels.c: Error creating message

json.c: Error building JSON from '{s: s, s: s, s: s, s: s, s: s, s: s, s: o}': Invalid UTF-8 string.
0: /usr/sbin/asterisk(ast_json_vpack+0x98) [0x4f3f28]
1: /usr/sbin/asterisk(ast_json_pack+0x8c) [0x4f3fcc]
2: /usr/lib64/asterisk/modules/res_fax.so(+0x5acd) [0x7f27f4c00acd]
...
res_fax.c: Error publishing ReceiveFax status message

This patch replaces the invalid UTF-8 Station IDs with an empty string.

ASTERISK-29312 #close

Change-Id: Ieb00b6ecf67db3bfca787649caa8517f29d987db
2021-03-02 11:17:02 -06:00
Sean Bright 6673c1b177 app_page.c: Don't fail to Page if beep sound file is missing
ASTERISK-16799 #close

Change-Id: I40367b0d6dbf66a39721bde060c8b2d734a61cf4
2021-02-26 09:36:07 -06:00
George Joseph 15afabdf8e res_pjsip_refer: Refactor progress locking and serialization
Although refer_progress_notify() always runs in the progress
serializer, the pjproject evsub module itself can cause the
subscription to be destroyed which then triggers
refer_progress_on_evsub_state() to clean it up.  In this case,
it's possible that refer_progress_notify() could get the
subscription pulled out from under it while it's trying to use
it.

At one point we tried to have refer_progress_on_evsub_state()
push the cleanup to the serializer and wait for its return before
returning to pjproject but since pjproject calls its state
callbacks with the dialog locked, this required us to unlock the
dialog while waiting for the serialized cleanup, then lock it
again before returning to pjproject. There were also still some
cases where other callers of refer_progress_notify() weren't
using the serializer and crashes were resulting.

Although all callers of refer_progress_notify() now use the
progress serializer, we decided to simplify the locking so we
didn't have to unlock and relock the dialog in
refer_progress_on_evsub_state().

Now, refer_progress_notify() holds the dialog lock for its
duration and since pjproject also holds the dialog lock while
calling refer_progress_on_evsub_state() (which does the cleanup),
there should be no more chances for the subscription to be
cleaned up while still being used to send NOTIFYs.

To be extra safe, we also now increment the session count on
the dialog when we create a progress object and decrement
the count when the progress is destroyed.

ASTERISK-29313

Change-Id: I97a8bb01771a3c85345649b8124507f7622a8480
2021-02-26 08:12:54 -06:00
Kevin Harwell be0a61bc3d res_rtp_asterisk: Add packet subtype during RTCP debug when relevant
For some RTCP packet types the report count is actually the packet's subtype.
This was not being reflected in the packet debug output.

This patch makes it so for some RTCP packet types a "Packet Subtype" is
now output in the debug replacing the "Reception reports" (i.e count).

Change-Id: Id4f4b77bb37077a4c4f039abd6a069287bfefcb8
2021-02-26 08:06:11 -06:00
Boris P. Korzun beb579bc99 res_config_pgsql: Limit realtime_pgsql() to return one (no more) record.
Added a SELECT 'LIMIT' clause to realtime_pgsql() and refactored the function.

ASTERISK-29293 #close

Change-Id: If5a6d4b1072ea2e6e89059b21139d554a74b34f5
2021-02-25 08:51:31 -06:00
Ben Ford 83b0f5963f res_pjsip_session.c: Check topology on re-invite.
Removes an unnecessary check for the conditional that compares the
stream topologies to see if they are equal to suppress re-invites. This
was a problem when a Digium phone received an INVITE that offered codecs
different than what it supported, causing Asterisk to send the
re-invite.

ASTERISK-29303

Change-Id: I04dc91befb2387904e28a9aaeaa3bcdbcaa7fa63
2021-02-25 08:46:33 -06:00
Jaco Kroon 7ab53fce7a res_odbc_transaction: correctly initialise forcecommit value from DSN.
Also improve the in-process documentation to clarify that the value is
initialised from the DSN and not default false, but that the DSN's value
is default false if unset.

ASTERISK-29311 #close

Change-Id: I46e2379f7b0656034442bce77cb37ccd4e61098d
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-02-25 08:45:49 -06:00
Joshua C. Colp 1af2a84c8b res_pjsip_session: Always produce offer on re-INVITE without SDP.
When PJSIP receives a re-INVITE without an SDP offer the INVITE
session library will first call the on_create_offer callback and
if unavailable then use the active negotiated SDP as the offer.

In some cases this would result in a different SDP then was
previously used without an incremented SDP version number. The two
known cases are:

1. Sending an initial INVITE with a set of codecs and having the
remote side answer with a subset. The active negotiated SDP would
have the pruned list but would not have an incremented SDP version
number.

2. Using re-INVITE for unhold. We would modify the active negotiated
SDP but would not increment the SDP version.

To solve these, and potential other unknown cases, the on_create_offer
callback has now been implemented which produces a fresh offer with
incremented SDP version number. This better fits within the model
provided by the INVITE session library.

ASTERISK-28452

Change-Id: I2d81048d54edcb80fe38fdbb954a86f0a58281a1
2021-02-25 08:42:07 -06:00
Jaco Kroon 916d5d5e45 app.h: Restore C++ compatibility for macro AST_DECLARE_APP_ARGS
This partially reverts commit 3d1bf3c537,
specifically for app.h.

This works with both gcc 9.3.0 and 10.2.0 now, both for C and C++ (as
tested with external modules).

ASTERISK-29287

Change-Id: I5b9f02a9b290675682a1d13f1788fdda597c9fca
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-02-23 13:39:36 -06:00
Ivan Poddubnyi 985d3e4940 app_queue: Fix conversion of complex extension states into device states
Queue members using dialplan hints as a state interface must handle
INUSE+RINGING hint as RINGINUSE devstate, and INUSE + ONHOLD as INUSE.

ASTERISK-28369

Change-Id: I127e06943d4b4f1afc518f9e396de77449992b9f
2021-02-23 13:37:22 -06:00
Alexander Traud 1adf9368ee chan_sip: Filter pass-through audio/video formats away, again.
Instead of looking for pass-through formats in the list of transcodable
formats (which is going to find nothing), go through the result which
is going to be the jointcaps of the tech_pvt of the channel. Finally,
only with that list, ast_format_cap_remove(.) is going to succeed.

This restores the behaviour of Asterisk 1.8. However, it does not fix
ASTERISK_29282 because that issue report is about chan_sip and PJSIP.
Here, only chan_sip is fixed because PJSIP does not even call
ast_rtp_instance_available_formats -> ast_translate_available_format.

Change-Id: Icade2366ac2b82935b95a9981678c987da2e8c34
2021-02-23 12:30:32 -06:00
Jaco Kroon bee35fe04a func_odbc: Introduce minargs config and expose ARGC in addition to ARGn.
minargs enables enforcing of minimum count of arguments to pass to
func_odbc, so if you're unconditionally using ARG1 through ARG4 then
this should be set to 4.  func_odbc will generate an error in this case,
so for example

[FOO]
minargs = 4

and ODBC_FOO(a,b,c) in dialplan will now error out instead of using a
potentially leaked ARG4 from Gosub().

ARGC is needed if you're using optional argument, to verify whether or
not an argument has been passed, else it's possible to use a leaked ARGn
from Gosub (app_stack).  So now you can safely do
${IF($[${ARGC}>3]?${ARGV}:default value)} kind of thing.

Change-Id: I6ca0b137d90b03f6aa9c496991f6cbf1518f6c24
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-02-23 12:18:13 -06:00
Sebastien Duthil 092628c982 app_mixmonitor: Add AMI events MixMonitorStart, -Stop and -Mute.
ASTERISK-29244

Change-Id: I1862d58264c2c8b5d8983272cb29734b184d67c5
2021-02-23 12:15:03 -06:00
George Joseph dbd8908f8d res_pjsip_refer: Always serialize calls to refer_progress_notify
refer_progress_notify wasn't always being called from the progress
serializer.  This could allow clearing notification->progress->sub
in one thread while another was trying to use it.

* Instances where refer_progress_notify was being called in-line,
  have been changed to use ast_sip_push_task().

Change-Id: Idcf1934c4e873f2c82e2d106f8d9f040caf9fa1e
2021-02-19 07:35:57 -06:00
Kevin Harwell fad0cf12e6 AST-2021-002: Remote crash possible when negotiating T.38
When an endpoint requests to re-negotiate for fax and the incoming
re-invite is received prior to Asterisk sending out the 200 OK for
the initial invite the re-invite gets delayed. When Asterisk does
finally send the re-inivite the SDP includes streams for both audio
and T.38.

This happens because when the pending topology and active topologies
differ (pending stream is not in the active) in the delayed scenario
the pending stream is appended to the active topology. However, in
the fax case the pending stream should replace the active.

This patch makes it so when a delay occurs during fax negotiation,
to or from, the audio stream is replaced by the T.38 stream, or vice
versa instead of being appended.

Further when Asterisk sent the re-invite with both audio and T.38,
and the endpoint responded with a declined T.38 stream then Asterisk
would crash when attempting to change the T.38 state.

This patch also puts in a check that ensures the media state has a
valid fax session (associated udptl object) before changing the
T.38 state internally.

ASTERISK-29203 #close

Change-Id: I407f4fa58651255b6a9030d34fd6578cf65ccf09
2021-02-18 10:38:03 -06:00
Alexander Traud 703158b903 rtp: Enable srtp replay protection
Add option "srtpreplayprotection" rtp.conf to enable srtp
replay protection.

ASTERISK-29260
Reported by: Alexander Traud

Change-Id: I5cd346e3c6b6812039d1901aa4b7be688173b458
2021-02-18 10:36:33 -06:00
Ivan Poddubnyi 2770cc5872 res_pjsip_diversion: Fix adding more than one histinfo to Supported
New responses sent within a PJSIP sessions are based on those that were
sent before. Therefore, adding/modifying a header once causes it to be
sent on all responses that follow.

Sending 181 Call Is Being Forwarded many times first adds "histinfo"
duplicated more and more, and eventually overflows past the array
boundary.

This commit adds a check preventing adding "histinfo" more than once,
and skipping it if there is no more space in the header.

Similar overflow situations can also occur in res_pjsip_path and
res_pjsip_outbound_registration so those were also modified to
check the bounds and suppress duplicate Supported values.

ASTERISK-29227
Reported by: Ivan Poddubny

Change-Id: Id43704a1f1a0293e35cc7f844026f0b04f2ac322
2021-02-18 10:34:44 -06:00
Sean Bright 5a6f2f913b res_rtp_asterisk.c: Fix signed mismatch that leads to overflow
ASTERISK-29205 #close

Change-Id: Ib7aa65644e8df76e2378d7613ee7cf751b9d0bea
2021-02-18 10:33:06 -06:00
Joshua C. Colp acb7ce4fe7 pjsip: Make modify_local_offer2 tolerate previous failed SDP.
If a remote side is broken and sends an SDP that can not be
negotiated the call will be torn down but there is a window
where a second 183 Session Progress or 200 OK that is forked
can be received that also attempts to negotiate SDP. Since
the code marked the SDP negotiation as being done and complete
prior to this it assumes that there is an active local and remote
SDP which it can modify, while in fact there is not as the SDP
did not successfully negotiate. Since there is no local or remote
SDP a crash occurs.

This patch changes the pjmedia_sdp_neg_modify_local_offer2
function to no longer assume that a previous SDP negotiation
was successful.

ASTERISK-29196

Change-Id: I22de45916d3b05fdc2a67da92b3a38271ee5949e
2021-02-18 09:51:53 -06:00
Ben Ford 62e2dd484d core_unreal: Fix T.38 faxing when using local channels.
After some changes to streams and topologies, receiving fax through
local channels stopped working. This change adds a stream topology with
a stream of type IMAGE to the local channel pair and allows fax to be
received.

ASTERISK-29035 #close

Change-Id: Id103cc5c9295295d8e68d5628e76220f8f17e9fb
2021-02-16 18:11:37 -06:00
Boris P. Korzun 57d130d3aa format_wav: Support of MIME-type for wav16
Provided a support of a MIME-type for wav16. Added new MIME-type
for classic wav.

ASTERISK-29275 #close

Change-Id: I749bda287ba1ab20c1e0af5e4c0153817d47873b
2021-02-12 07:21:02 -06:00
Alexander Traud 45e48e387c chan_sip: Allow [peer] without audio (text+video).
Two previous commits, 620d9f4 and 6d980de, allow to set up a call
without audio, again. That was introduced originally with commit f04d5fb
but changed and broke over time. The original commit missed one
scenario: A [peer] section in sip.conf, which does not allow audio at
all. In that case, chan_sip rejected the call, although even when the
requester offered no audio. Now, chan_sip does not check whether there
is no audio format but checks whether there is no format in general. In
other words, if there is at least one format to offer, the call succeeds.

However, to prevent calls with no-audio, chan_sip still rejects calls
when both call parties (caller = requester of the call *and* callee =
[peer] section in sip.conf) included audio. In such a case, it is
expected that the call should have audio.

ASTERISK-29280

Change-Id: I0fb74faf51ef22a60c10b467df6a4d1c1943b73e
2021-02-12 07:19:09 -06:00
George Joseph 28f187d6c5 chan_iax2.c: Require secret and auth method if encryption is enabled
If there's no secret specified for an iax2 peer and there's no secret
specified in the dial string, Asterisk will crash if the auth method
requested by the peer is MD5 or plaintext.  You also couldn't specify
a default auth method in the [general] section of iax.conf so if you
don't have static peers defined and just use the dial string, Asterisk
will still crash even if you have a secret specified in the dial string.

* Added logic to iax2_call() and authenticate_reply() to print
  a warning and hanhup the call if encryption is requested and
  there's no secret or auth method.  This prevents the crash.

* Added the ability to specify a default "auth" in the [general]
  section of iax.conf.

ASTERISK-29624
Reported by: N A

Change-Id: I5928e16137581f7d383fcc7fa04ad96c919e6254
2021-02-09 09:15:49 -06:00
Sean Bright 24d6adfe99 app_read: Release tone zone reference on early return.
Change-Id: I350939f2220f9e5d44ddf4c8d9a4c99fde4d169a
2021-02-04 09:57:24 -06:00
Alexander Traud 87ad1138ff chan_sip: Set up calls without audio (text+video), again.
The previous commit 6d980de fixed this issue in the core of Asterisk.
With that, each channel technology can be used without audio
theoretically. Practically, the channel-technology driver chan_sip
turned out to have an invalid check preventing that. chan_sip tested
whether there is at least one audio format. However, chan_sip has to
test whether there is at least one format. More cannot be tested while
requesting chan_sip because only the [general] capabilities but not the
[peer] caps are known yet. And the [peer] caps might not be a subset or
show any intersection with the [general] caps. This change here fixes
this.

The original commit f04d5fb, thirteen years ago, contained a software
bug as it passed ANY audio capability to the channel-technology driver.
Instead, it should have passed NO audio format. Therefore, this
addressed issue here was not noticed in Asterisk 1.6.x and Asterisk 1.8.
Then, Asterisk 10 changed that from ANY to NO, but nobody reported since
then.

ASTERISK-29265

Change-Id: Ic16a3bf13cd1b5c4fc4041ed74961177d96b600f
2021-02-03 03:01:12 -06:00
Dan Cropp 088816284a chan_pjsip, app_transfer: Add TRANSFERSTATUSPROTOCOL variable
When a Transfer/REFER is executed, TRANSFERSTATUSPROTOCOL variable is
0 when no protocl specific error
SIP example of failure, 3xx-6xx for the SIP error code received

This allows applications to perform actions based on the failure
reason.

ASTERISK-29252 #close
Reported-by: Dan Cropp

Change-Id: Ia6a94784b4925628af122409cdd733c9f29abfc4
2021-01-27 11:42:10 -06:00
roadkill 176274caa4 res/res_pjsip.c: allow user=phone when number contain *#
if From number contain * or # asterisk will not add user=phone

Currently only number that uses AST_DIGIT_ANYNUM can have "user=phone" but the validation should use AST_DIGIT_ANY
this is a problem when you want to send call to ISUP
as they will disregard the From header and either replace From with anonymous or with p-asserted-identity

ASTERISK-29261
Reported by: Mark Petersen
Tested by: Mark Petersen

Change-Id: I3307bdbf757582740bfee4110e85f7b6c9291cc4
2021-01-27 11:04:02 -06:00
Alexander Traud f64ddf3db3 channel: Set up calls without audio (text+video), again.
ASTERISK-29259

Change-Id: Ib6a6550e0e08355745d66da8e60ef49e81f9c6c5
2021-01-27 10:53:40 -06:00
Alexander Traud 4c154f3431 chan_sip: SDP: Reject audio streams correctly.
This completes the fix for ASTERISK_24543. Only when the call is an
outgoing call, consult and append the configured format capabilities
(p->caps). When all audio formats got rejected the negotiated format
capabilities (p->jointcaps) contain no audio formats for incoming
calls. This is required when there are other accepted media streams.

ASTERISK-29258

Change-Id: I8bab31c7f3f3700dce204b429ad238a524efebb9
2021-01-27 10:42:01 -06:00
Ivan Poddubnyi 7c0fbaf010 main/frame: Add missing control frame names to ast_frame_subclass2str
Log proper control frame names instead of "Unknown control '14'", etc.

Change-Id: I1724f2f4d1b064b25a5c93a7da0cb03be5143935
2021-01-27 10:04:32 -06:00
Boris P. Korzun f1c88a497b res_musiconhold: Add support of various URL-schemes by MoH.
Provided a support of variuos URL-schemes for res_musiconhold,
registered by ast_bucket_scheme_register().

ASTERISK-29262 #close

Change-Id: If0ea8697587353dce358a70035d82649fd4632b6
2021-01-25 10:54:16 -06:00
Robert Cripps 017e09b40a res/res_pjsip_session.c: Check that media type matches in
function ast_sip_session_media_state_add.

Check ast_media_type matches when a ast_sip_session_media is found
otherwise when transitioning from say image to audio, the wrong
session is returned in the first if statement.

ASTERISK-29220 #close

Change-Id: I6f6efa9b821ebe8881bb4c8c957f8802ddcb4b5d
2021-01-18 11:30:26 -06:00
Sean Bright fb42b60326 res_pjsip_pubsub: Fix truncation of persisted SUBSCRIBE packet
The last argument to ast_copy_string() is the buffer size, not the
number of characters, so we add 1 to avoid stamping out the final \n
in the persisted SUBSCRIBE message.

Change-Id: I019b78942836f57965299af15d173911fcead5b2
2021-01-18 11:30:08 -06:00
Jaco Kroon 9c56870929 AC_HEADER_STDC causes a compile failure with autoconf 2.70
From https://www.mail-archive.com/bug-autoconf@gnu.org/msg04408.html

> ... the long-obsolete AC_HEADER_STDC, previously used internally by
> AC_INCLUDES_DEFAULT, used AC_EGREP_HEADER.  The AC_HEADER_STDC macro
> is now a no-op (and is not used at all within Autoconf anymore), so
> that change is likely what made the first use of AC_EGREP_HEADER the
> one inside the if condition, causing the observed results.

The implication is that the test does nothing anyway, and due to it
being a no-op from 2.70 onwards, results in the required not being set
to yes, resulting in ./configure to fail.

Change-Id: Ic1ff38d87f791fbf1f2a80512f81bb7110392460
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-01-18 11:11:53 -06:00
Alexander Traud a25bcf70ed pjsip_scheduler: Fix pjsip show scheduled_tasks like for compiler Clang.
Otherwise, Clang 10 warned because of logical-not-parentheses.

Change-Id: Ia8fb493f727b08070eb2dcf520c08df34ed11d79
2021-01-18 10:37:41 -06:00
Alexander Traud 3f119192bb res_pjsip_session: Avoid sometimes-uninitialized warning with Clang.
ASTERISK-29248

Change-Id: I2b17bd5ffb246bc64c463402c9831413da78a556
2021-01-18 10:36:30 -06:00
Ben Ford 87a35f8e94 chan_pjsip.c: Add parameters to frame in indicate.
There are a couple of parameters (datalen and data) that do not get set
in chan_pjsip_indicate which could cause an Invalid message to pop up
for things such as fax. This patch adds them to the frame.

Change-Id: Ia51be086a0708be905e73d1f433572c49c7e38f8
2021-01-18 10:02:28 -06:00
Asterisk Development Team 89fea9bafe Update CHANGES and UPGRADE.txt for 18.2.0 2021-01-14 10:56:04 -05:00
Jean Aunis c10557c401 Stasis/messaging: tech subscriptions conflict with endpoint subscriptions.
When both a tech subscription and an endpoint subscription exist for a given
endpoint, TextMessageReceived events are dispatched to the tech subscription
only.

ASTERISK-29229

Change-Id: I9eac4cba5f9e27285a282509395347abc58fc2b8
2021-01-13 09:37:19 -06:00
Ivan Poddubnyi c3fad2fd01 chan_pjsip: Assign SIPDOMAIN after creating a channel
session->channel doesn't exist until chan_pjsip creates it, so intead of
setting a channel variable every new incoming call sets one and the same
global variable.

This patch moves the code to chan_pjsip so that SIPDOMAIN is set on
a newly created channel, it also removes a misleading reference to
channel->session used to fetch call pickup configuraion.

ASTERISK-29240

Change-Id: I90c9bbbed01f5d8863585631a29322ae4e046755
2021-01-13 08:28:30 -06:00
Alexander Traud ad606d4ad1 chan_sip: SDP: Sidestep stream parsing when its media is disabled.
Previously, chan_sip parsed all known media streams in an SDP offer
like video (and text) even when videosupport=no (and textsupport=no).
This wasted processor power. Furthermore, chan_sip accepted SDP offers,
including no audio but just video (or text) streams although
videosupport=no (or textsupport=no). Finally, chan_sip denied the whole
offer instead of individual streams when they had encryption (SDES-sRTP)
unexpectedly enabled.

ASTERISK-29238
ASTERISK-29237
ASTERISK-29222

Change-Id: Ie49e4e2a11f0265f914b684738348ba8c0f89755
2021-01-13 07:42:19 -06:00
Ivan Poddubnyi cc496044db chan_pjsip: Stop queueing control frames twice on outgoing channels
The fix for ASTERISK-27902 made chan_pjsip process SIP responses twice.
This resulted in extra noise in logs (for example, "is making progress"
and "is ringing" get logged twice by app_dial), as well as in noise in
signalling: one incoming 183 Session Progress results in 2 outgoing 183-s.

This change splits the response handler into 2 functions:
 - one for updating HANGUPCAUSE, which is still called twice,
 - another that does the rest, which is called only once as before.

ASTERISK-28016
Reported-by: Alex Hermann

ASTERISK-28549
Reported-by: Gant Liu

ASTERISK-28185
Reported-by: Julien

Change-Id: I0a1874be5bb5ed12d572d17c7f80de6e5e542940
2021-01-11 12:14:51 -06:00
roadkill cba8426b4c contrib/systemd: Added note on common issues with systemd and asterisk
With newer version of linux /var/run/ is a symlink to /run/ that has
been turned into tmpfs.

Added note that if asterisk has to bind to a specific IP that
systemd has to wait until the network is up.

Added note on how to make sure that the environment variable
HOSTNAME is included.

ASTERISK-29216
Reported by: Mark Petersen
Tested by: Mark Petersen

Change-Id: Ib3e560655befd3e99eec743687144f5569533379
2021-01-11 11:41:46 -06:00
George Joseph b3927ff8bc Revert "res_pjsip_outbound_registration.c: Use our own scheduler and other stuff"
This reverts commit 860e40dd80.

Reason for revert: Too many issues reported.  Need to research and correct.

ASTERISK-29230
ASTERISK-29231
Reported by: Michael Maier

Change-Id: I9011e2eecda4e91e1cfeeda6d1a7f1a0453eab41
2021-01-11 09:28:25 -06:00
Jaco Kroon 3a230cc6a9 func_lock: fix multiple-channel-grant problems.
Under contention it becomes possible that multiple channels will be told
they successfully obtained the lock, which is a bug.  Please refer

ASTERISK-29217

This introduces a couple of changes.

1.  Replaces requesters ao2 container with simple counter (we don't
    really care who is waiting for the lock, only how many).  This is
    updated undex ->mutex to prevent memory access races.
2.  Correct semantics for ast_cond_timedwait() as described in
    pthread_cond_broadcast(3P) is used (multiple threads can be released
    on a single _signal()).
3.  Module unload races are taken care of and memory properly cleaned
    up.

Change-Id: I6f68b5ec82ff25b2909daf6e4d19ca864a463e29
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-01-06 12:03:46 -06:00
Jaco Kroon 49f625b8db pbx_lua: Add LUA_VERSIONS environment variable to ./configure.
On Gentoo it's possible to have multiple lua versions installed, all
with a path of /usr, so it's not possible to use the current --with-lua
option to determisticly pin to a specific version as is required by the
Gentoo PMS standards.

This environment variable allows to lock to specific versions,
unversioned check will be skipped if this variable is supplied.

Change-Id: I8c403eda05df25ee0193960262ce849c7d2fd088
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
2021-01-06 11:58:45 -06:00
Dan Cropp fb23f98521 chan_pjsip: Incorporate channel reference count into transfer_refer().
Add channel reference count for PJSIP REFER. The call could be terminated
prior to the result of the transfer. In that scenario, when the SUBSCRIBE/NOTIFY
occurred several minutes later, it would attempt to access a session which was
no longer valid.  Terminate event subscription if pjsip_xfer_initiate() or
pjsip_xfer_send_request() fails in transfer_refer().

ASTERISK-29201 #close
Reported-by: Dan Cropp

Change-Id: I3fd92fd14b4e3844d3d7b0f60fe417a4df5f2435
2021-01-06 11:04:05 -06:00
Kevin Harwell 0e1ba9a778 app_mixmonitor: cleanup datastore when monitor thread fails to launch
launch_monitor_thread is responsible for creating and initializing
the mixmonitor, and dependent data structures. There was one off
nominal path after the datastore gets created that triggers when
the channel being monitored is hung up prior to monitor starting
itself.

If this happened the monitor thread would not "launch", and the
mixmonitor object and associated objects are freed, including the
underlying datastore data object. However, the datastore itself was
not removed from the channel, so when the channel eventually gets
destroyed it tries to access the previously freed datastore data
and crashes.

This patch removes and frees datastore object itself from the channel
before freeing the mixmonitor object thus ensuring the channel does
not call it when destroyed.

ASTERISK-28947 #close

Change-Id: Id4f9e958956d62473ed5ff06c98ae3436e839ff8
2021-01-06 10:52:05 -06:00
Sean Bright 9ff548f1db app_voicemail: Prevent deadlocks when out of ODBC database connections
ASTERISK-28992 #close

Change-Id: Ia7d608924036139ee2520b840d077762d02668d0
2021-01-06 10:50:48 -06:00
Kevin Harwell d9aef0e6e5 pbx_realtime: wrong type stored on publish of ast_channel_snapshot_type
A prior patch segmented channel snapshots, and changed the underlying
data object type associated with ast_channel_snapshot_type stasis
messages. Prior to Asterisk 18 it was a type ast_channel_snapshot, but
now it type ast_channel_snapshot_update.

When publishing ast_channel_snapshot_type in pbx_realtime the
ast_channel_snapshot was being passed in as the message data
object. When a handler, expecting a data object type of
ast_channel_snapshot_update, dereferenced this value a crash
would occur.

This patch makes it so pbx_realtime now uses the expected type, and
channel snapshot publish method when publishing.

ASTERISK-29168 #close

Change-Id: I9a2cfa0ec285169317f4b9146e4027da8a4fe896
2021-01-06 09:12:58 -06:00
Sean Bright 68d3d3af6f asterisk: Export additional manager functions
Rename check_manager_enabled() and check_webmanager_enabled() to begin
with ast_ so that the symbols are automatically exported by the
linker.

ASTERISK~29184

Change-Id: I85762b9a5d14500c15f6bad6507138c8858644c9
2021-01-06 09:11:31 -06:00
Nick French 3c8598ffef res_pjsip: Prevent segfault in UDP registration with flow transports
Segfault occurs during outbound UDP registration when all
transport states are being iterated over. The transport object
in the transport is accessed, but flow transports have a NULL
transport object.

Modify to not iterate over any flow transport

ASTERISK-29210 #close

Change-Id: If28dc3a18bdcbd0a49598b09b7fe4404d45c996a
2021-01-04 05:03:11 -06:00
Richard Mudgett 3d379845e6 chan_vpb.cc: Fix compile errors.
Fix the usual compile problem when someone adds a new callback to struct
ast_channel_tech.

Change-Id: I9bdeb8a8cc65f03b2d6e4f2eb5809af47c906c32
2020-12-31 13:13:42 -06:00
Richard Mudgett 027f4e3a21 res_pjsip_session.c: Fix compiler warnings.
AST_VECTOR_SIZE() returns a size_t.  This is not always equivalent to an
unsigned long on all machines.

Change-Id: I0a4189a104e6e3a2e2273de06620eaef19df9338
2020-12-28 08:26:35 -06:00
Sungtae Kim d8b7a6f599 res_pjsip_session: Fixed NULL active media topology handle
Added NULL pointer check to prevent Asterisk crash.

ASTERISK-29215

Change-Id: If07e50ea8d78cb610af9195fc13b5dca4bfcef95
2020-12-23 07:45:48 -06:00
Torrey Searle a7aea71e60 res/res_pjsip_diversion: prevent crash on tel: uri in History-Info
Add a check to see if the URI is a Tel URI and prevent crashing on
trying to retrieve the reason parameter.

ASTERISK-29191
ASTERISK-29219

Change-Id: I0320aa205f22cda511d60a2edf2b037e8fd6cc37
2020-12-22 12:59:48 -06:00
Sean Bright 13682210e2 app_chanspy: Spyee information missing in ChanSpyStop AMI Event
The documentation in the wiki says there should be spyee-channel
information elements in the ChanSpyStop AMI event.

    https://wiki.asterisk.org/wiki/x/Xc5uAg

However, this is not the case in Asterisk <= 16.10.0 Version. We're
using these Spyee* arguments since Asterisk 11.x, so these arguments
vanished in Asterisk 12 or higher.

For maximum compatibility, we still send the ChanSpyStop event even if
we are not able to find any 'Spyee' information.

ASTERISK-28883 #close

Change-Id: I81ce397a3fd614c094d043ffe5b1b1d76188835f
2020-12-17 14:03:52 -06:00
Sungtae Kim 4b450b4334 res_ari: Fix wrong media uri handle for channel play
Fixed wrong null object handle in
/channels/<channel_id>/play request handler.

ASTERISK-29188

Change-Id: I6691c640247a51ad15f23e4a203ca8430809bafe
2020-12-17 11:07:09 -06:00
Pirmin Walthert 7a6cfde4db res_pjsip_nat.c: Create deep copies of strings when appropriate
In rewrite_uri asterisk was not making deep copies of strings when
changing the uri. This was in some cases causing garbage in the route
header and in other cases even crashing asterisk when receiving a
message with a record-route header set. Thanks to Ralf Kubis for
pointing out why this happens. A similar problem was found in
res_pjsip_transport_websocket.c. Pjproject needs as well to be patched
to avoid garbage in CANCEL messages.

ASTERISK-29024 #close

Change-Id: Ic5acd7fa2fbda3080f5f36ef12e46804939b198b
2020-12-17 09:10:54 -06:00
George Joseph ccb4951bf8 logger.c: Automatically add a newline to formats that don't have one
Scope tracing allows you to not specify a format string or
variable, in which case it just prints the indent, file,
function, and line number.  The trace output automatically
adds a newline to the end in this case.  If you also have
debugging turned on for the module, a debug message is
also printed but the standard log functionality which
prints it doesn't add the newline so you have messages
that don't break correctly.

 * format_log_message_ap(), which is the common log
   message formatter for all channels, now adds a
   newline to the end of format strings that don't
   already have a newline.

ASTERISK-29209
Reported by: Alexander Traud

Change-Id: I994a7df27f88df343b7d19f3e81a4b562d9d41da
2020-12-17 09:08:20 -06:00
Joshua C. Colp 938a240793 res_pjsip_pidf_digium_body_supplement: Support Sangoma user agent.
This adds support for both Digium and Sangoma user agent strings
for the Sangoma specific body supplement.

Change-Id: Ib99362b24b91d3cbe888d8b2fce3fad5515d9482
2020-12-16 09:21:36 -06:00
Nathan Bruning 0774d9f9aa res_musiconhold: Don't crash when real-time doesn't return any entries
ASTERISK-29211 #close

Change-Id: Ifbf0a4f786ab2a52342f9d1a1db4c9907f069877
2020-12-15 08:06:22 -06:00
Joshua C. Colp 5b4e71fa0a pjsip: Match lifetime of INVITE session to our session.
In some circumstances it was possible for an INVITE
session to be destroyed while we were still using it.
This occurred due to the reference on the INVITE session
being released internally as a result of its state
changing to DISCONNECTED.

This change adds a reference to the INVITE session
which is released when our own session is destroyed,
ensuring that the INVITE session remains valid for
the lifetime of our session.

ASTERISK-29022

Change-Id: I300c6d9005ff0e6efbe1132daefc7e47ca6228c9
2020-12-09 13:06:32 -06:00
lvl 92fcd4edba Introduce astcachedir, to be used for temporary bucket files
As described in the issue, /tmp is not a suitable location for a
large amount of cached media files, since most distributions make
/tmp a RAM-based tmpfs mount with limited capacity.

I opted for a location that can be configured separately, as opposed
to using a subdirectory of spooldir, given the different storage
profile (transient files vs files that might stay there indefinitely).

This commit just makes the cache directory configurable, but leaves
it at /tmp by default, to ensure backwards compatibility.

A future commit that only targets master could change the default
location to something more sensible such as /var/tmp/asterisk. At
that point, the cachedir could be created and cleaned up during
uninstall by the Makefile script.

ASTERISK-29143

Change-Id: Ic54e95199405abacd9e509cef5f08fa14c510b5d
2020-12-09 13:06:04 -06:00
Sean Bright f39d5ea7cd res_http_media_cache.c: Set reasonable number of redirects
By default libcurl does not follow redirects, so we explicitly enable
it by setting CURLOPT_FOLLOWLOCATION. Once that is enabled, libcurl
will follow up to CURLOPT_MAXREDIRS redirects, which by default is
configured to be unlimited.

This patch sets CURLOPT_MAXREDIRS to a more reasonable default (8). If
we determine at some point that this needs to be increased on
configurable it is a trivial change.

ASTERISK-29173 #close

Change-Id: I4925ebbcf0c7d728bb9252b3795b3479ae225b30
2020-12-03 11:29:21 -05:00
Sean Bright f9438e6457 media_cache: Fix reference leak with bucket file metadata
Change-Id: Ia0e4124110df613ce5fdfa9ef8780016ebaa52c6
2020-12-03 08:43:56 -06:00
Stanislav 6a85dc860f res_pjsip_stir_shaken: Fix module description
the 'J' is missing in module description.
"PSIP STIR/SHAKEN Module for Asterisk" -> "PJSIP STIR/SHAKEN Module for Asterisk"

ASTERISK-29175 #close

Change-Id: I17da008540ee2e8496b644d05f995b320b54ad7a
2020-12-01 11:24:58 -06:00
Joshua C. Colp fd57fae048 voicemail: add option 'e' to play greetings as early media
When using this option, answering the channel is deferred until
all prompts/greetings have been played and the caller is about
to leave their message.

ASTERISK-29118 #close

Change-Id: I41b9f0428783c0bd697c8c994f906d1e75ce9ddb
2020-12-01 11:23:04 -06:00
Alexander Traud bf9f0f13c4 loader: Sync load- and build-time deps.
In MODULEINFO, each depend has to be listed in .requires of AST_MODULE_INFO.

ASTERISK-29148

Change-Id: I254dd33194ae38d2877b8021c57c2a5deb6bbcd2
2020-11-20 13:51:34 -06:00
Sean Bright 994fbdaf48 CHANGES: Remove already applied CHANGES update
Change-Id: Iee7163bc732d58c5cbaa2cfab1f5aab4a412060a
2020-11-20 11:01:58 -06:00
Alexander Greiner-Baer c79bd583d9 res_pjsip: set Accept-Encoding to identity in OPTIONS response
RFC 3261 says that the Accept-Encoding header should be present
in an options response. Permitted values according to RFC 2616
are only compression algorithms like gzip or the default identity
encoding. Therefore "text/plain" is not a correct value here.
As long as the header is hard coded, it should be set to "identity".

Without this fix an Alcatel OmniPCX periodically logs warnings like
"[sip_acceptIncorrectHeader] Header Accept-Encoding is malformed"
on a SIP Trunk.

ASTERISK-29165 #close

Change-Id: I0aa2211ebf0b4c2ed554ac7cda794523803a3840
2020-11-19 16:14:13 -06:00
Alexander Traud e884d935f6 chan_sip: Remove unused sip_socket->port.
12 years ago, with ASTERISK_12115 the last four get/uses of socket.port
vanished. However, the struct member itself and all seven set/uses
remained as dead code.

ASTERISK-28798

Change-Id: Ib90516a49eca3d724a70191278aaf2144fb58c59
2020-11-19 15:37:11 -06:00
Boris P. Korzun 33e3542132 bridge_basic: Fixed setup of recall channels
Fixed a bug (like a typo) in retransfer_enter()
at main/bridge_basic.c:2641. common_recall_channel_setup() setups
common things on the recalled transfer target, but used same target
as source instead trasfered.

ASTERISK-29161 #close

Change-Id: Ieb549654a621c38b1ad5e9d15b9f18823d9cc31f
2020-11-18 10:12:51 -06:00
Alexander Traud 6e1fb58183 modules.conf: Align the comments for more conclusiveness.
Change-Id: I79cc693cd5a6e5dd7d403b7e91d970ff1ddf8306
2020-11-16 09:10:28 -06:00
George Joseph 2413598705 app_queue: Fix deadlock between update and show queues
Operations that update queues when shared_lastcall is set lock the
queue in question, then have to lock the queues container to find the
other queues with the same member. On the other hand, __queues_show
(which is called by both the CLI and AMI) does the reverse. It locks
the queues container, then iterates over the queues locking each in
turn to display them.  This creates a deadlock.

* Moved queue print logic from __queues_show to a separate function
  that can be called for a single queue.

* Updated __queues_show so it doesn't need to lock or traverse
  the queues container to show a single queue.

* Updated __queues_show to snap a copy of the queues container and iterate
  over that instead of locking the queues container and iterating over
  it while locked.  This prevents us from having to hold both the
  container lock and the queue locks at the same time.  This also
  allows us to sort the queue entries.

ASTERISK-29155

Change-Id: I78d4dc36728c2d7bc187b97d82673fc77f2bcf41
2020-11-12 16:17:48 -06:00
Asterisk Development Team 98d1537c1e Update CHANGES and UPGRADE.txt for 18.1.0 2020-11-12 06:50:09 -05:00
George Joseph 860e40dd80 res_pjsip_outbound_registration.c: Use our own scheduler and other stuff
* Instead of using the pjproject timer heap, we now use our own
  pjsip_scheduler.  This allows us to more easily debug and allows us to
  see times in "pjsip show/list registrations" as well as being able to
  see the registrations in "pjsip show scheduled_tasks".

* Added the last registration time, registration interval, and the next
  registration time to the CLI output.

* Removed calls to pjsip_regc_info() except where absolutely necessary.
  Most of the calls were just to get the server and client URIs for log
  messages so we now just save them on the client_state object when we
  create it.

* Added log messages where needed and updated most of the existong ones
  to include the registration object name at the start of the message.

Change-Id: I4534a0fc78c7cb69f23b7b449dda9748c90daca2
2020-11-10 07:13:10 -07:00
George Joseph 569fc28966 pjsip_scheduler.c: Add type ONESHOT and enhance cli show command
* Added a ONESHOT type that never reschedules.

* Added "like" capability to "pjsip show scheduled_tasks" so you can do
  the following:

  CLI> pjsip show scheduled_tasks like outreg
  PJSIP Scheduled Tasks:

  Task Name                                     Interval  Times Run ...
  ============================================= ========= ========= ...
  pjsip/outreg/testtrunk-reg-0-00000074            50.000   oneshot ...
  pjsip/outreg/voipms-reg-0-00000073              110.000   oneshot ...

* Fixed incorrect display of "Next Start".

* Compacted the displays of times in the CLI.

* Added two new functions (ast_sip_sched_task_get_times2,
  ast_sip_sched_task_get_times_by_name2) that retrieve the interval,
  next start time, and next run time in addition to the times already
  returned by ast_sip_sched_task_get_times().

Change-Id: Ie718ca9fd30490b8a167bedf6b0b06d619dc52f3
2020-11-09 16:39:08 -06:00
Alexei Gradinari da0f2ea99e sched: AST_SCHED_REPLACE_UNREF can lead to use after free of data
The data can be freed if the old object '_data' is the same object as
new 'data'. Because at first the object is unreferenced which can lead
to destroying it.

This could happened in res_pjsip_pubsub when the publication is updated
which could lead to segfault in function publish_expire.

Change-Id: I0164f57c387243510bdbd2f8dcf33377b6c202da
2020-11-09 08:59:34 -06:00
Alexander Traud 5a6037778b res_pjsip/config_transport: Load and run without OpenSSL.
ASTERISK-28933
Reported-by: Walter Doekes

Change-Id: I65eac49e5b0a79261ea80e2b9b38a836886ed59f
2020-11-09 08:50:52 -06:00
Alexander Traud be54c7e9ea res_stir_shaken: Include OpenSSL headers where used actually.
This avoids the inclusion of the OpenSSL headers in the public header,
which avoids one external library dependency in res_pjsip_stir_shaken.

Change-Id: I6a07e2d81d2b5442e24e99b8cc733a99f881dcf4
2020-11-09 08:03:21 -06:00
Dovid Bender c635c78265 func_curl.c: Allow user to set what return codes constitute a failure.
Currently any response from res_curl where we get an answer from the
web server, regardless of what the response is (404, 403 etc.) Asterisk
currently treats it as a success. This patch allows you to set which
codes should be considered as a failure by Asterisk. If say we set
failurecodes=404,403 then when using curl in realtime if a server gives
a 404 error Asterisk will try to failover to the next option set in
extconfig.conf

ASTERISK-28825

Reported by: Dovid Bender
Code by: Gobinda Paul

Change-Id: I94443e508343e0a3e535e51ea6e0562767639987
2020-11-06 12:39:27 -06:00
Kevin Harwell 6baa4b53be AST-2020-001 - res_pjsip: Return dialog locked and referenced
pjproject returns the dialog locked and with a reference. However,
in Asterisk the method that handles this decrements the reference
and removes the lock prior to returning. This makes it possible,
under some circumstances, for another thread to free said dialog
before the thread that created it attempts to use it again. Of
course when the thread that created it tries to use a freed dialog
a crash can occur.

This patch makes it so Asterisk now returns the newly created
dialog both locked, and with an added reference. This allows the
caller to de-reference, and unlock the dialog when it is safe to
do so.

In the case of a new SIP Invite the lock, and reference are now
held for the entirety of the new invite handling process.
Otherwise it's possible for the dialog, or its dependent objects,
like the transaction, to disappear. For example if there is a TCP
transport error.

ASTERISK-29057 #close

Change-Id: I5ef645a47829596f402cf383dc02c629c618969e
2020-11-05 11:52:28 -06:00
Ben Ford 82325ba58b AST-2020-002 - res_pjsip: Stop sending INVITEs after challenge limit.
If Asterisk sends out and INVITE and receives a challenge with a
different nonce value each time, it will continually send out INVITEs,
even if the call is hung up. The endpoint must be configured for
outbound authentication in order for this to occur. A limit has been set
on outbound INVITEs so that, once reached, Asterisk will stop sending
INVITEs and the transaction will terminate.

ASTERISK-29013

Change-Id: I2d001ca745b00ca8aa12030f2240cd72363b46f7
2020-11-05 10:42:29 -06:00
Sean Bright fe540d0326 sip_to_pjsip.py: Handle #include globs and other fixes
* Wildcards in #includes are now properly expanded

* Implement operators for Section class to allow sorting

ASTERISK-29142 #close

Change-Id: I9b9cd95f4cbe5c24506b75d17173c5aa1a83e5df
2020-11-05 08:37:54 -06:00
Alexander Traud e0ee53dc9c Compiler fixes for GCC with -Og
ASTERISK-29144

Change-Id: I2a72c072083b4492a223c6f9d73d21f4f424db62
2020-11-03 17:07:42 -06:00
Alexander Traud 2dacadd9df Compiler fixes for GCC with -Os
ASTERISK-29145

Change-Id: I9af705f2b9725c53141aef5d0ff512a1800f073c
2020-11-03 15:45:46 -06:00
Alexander Traud f86af1fbd0 Compiler fixes for GCC when printf %s is NULL
ASTERISK-29146

Change-Id: Ib04bdad87d729f805f5fc620ef9952f58ea96d41
2020-11-03 15:32:33 -06:00
Alexander Traud 5b25c75d7b chan_sip: On authentication, pick MD5 for sure.
RFC 8760 added new digest-access-authentication schemes. Testing
revealed that chan_sip does not pick MD5 if several schemes are offered
by the User Agent Server (UAS). This change does not implement any of
the new schemes like SHA-256. This change makes sure, MD5 is picked so
UAS with SHA-2 enabled, like the service www.linphone.org/freesip, can
still be used. This should have worked since day one because SIP/2.0
already envisioned several schemes (see RFC 3261 and its augmented BNF
for 'algorithm' which includes 'token' as third alternative; note: if
'algorithm' was not present, MD5 is still assumed even in RFC 7616).

Change-Id: I61ca0b1f74b5ec2b5f3062c2d661cafeaf597fcd
2020-11-03 15:12:57 -06:00
Walter Doekes fb3b14ab7d main/say: Work around gcc 9 format-truncation false positive
Version: gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Warning:
  say.c:2371:24: error: ‘%d’ directive output may be truncated writing
    between 1 and 11 bytes into a region of size 10
    [-Werror=format-truncation=]
  2371 |     snprintf(buf, 10, "%d", num);
  say.c:2371:23: note: directive argument in the range [-2147483648, 9]

That's not possible though, as the if() starts out checking for (num < 0),
making this Warning a false positive.

(Also replaced some else<TAB>if with else<SP>if while in the vicinity.)

Change-Id: Ic7a70120188c9aa525a6d70289385bfce878438a
2020-10-29 08:18:48 -05:00
Kevin Harwell 439f7bb848 res_pjsip, res_pjsip_session: initialize local variables
This patch initializes a couple of local variables to some default values.
Interestingly, in the 'pj_status_t dlg_status' case the value not being
initialized caused memory to grow, and not be recovered, in the off nominal
path (at least on my machine).

Change-Id: I22ee65e1e1bff8efacea8a167c6c8428898523f7
2020-10-28 09:51:08 -05:00
Alexander Traud f89531cb98 install_prereq: Add GMime 3.0.
Ubuntu 20.10 does not come with GMime 2.6. Ubuntu 16.04 LTS does not
come with GMime 3.0. aptitude ignores any missing package. Therefore,
it installs the correct package(s). However, in Ubuntu 18.04 LTS and
Ubuntu 20.04 LTS, both versions are installed alongside although only
one is really needed.

Change-Id: Ic58aa9f2e131d94671f286f17dbd61e1ccbabcb7
2020-10-28 09:37:00 -05:00
Nick French f041763e3b res_pjsip_session: Restore calls to ast_sip_message_apply_transport()
Commit 44bb0858cb ("debugging: Add enough
to choke a mule") accidentally removed calls to
ast_sip_message_apply_transport when it was attempting to just add
debugging code.

The kiss of death was saying that there were no functional changes in
the commit comment.

This makes outbound calls that use the 'flow' transport mechanism fail,
since this call is used to relay headers into the outbound INVITE
requests.

ASTERISK-29124 #close

Change-Id: I0f3e32c2e8ac415e30b1d29966d75a1546f0526a
2020-10-28 08:37:32 -05:00
Alexander Traud 2773f93154 BuildSystem: Enable Lua 5.4.
Note to maintainers: Lua 5.4, Lua 5.3, and Lua 5.2 have not been tested
at runtime with pbx_lua. Until then, use the lowest available version
of Lua, if you enabled the module pbx_lua at all.

Change-Id: Ie5270448b11fcb4e2a53d899e4fe7fea793ce7e0
2020-10-28 08:04:50 -05:00
Sean Bright 6f321b561a features.conf.sample: Sample sound files incorrectly quoted
ASTERISK-29136 #close

Change-Id: I3186536d65a50014c8da4780c9224919caa81440
2020-10-22 11:25:37 -05:00
Andrew Siplas ff33f7f44f logger.conf.sample: add missing comment mark
Add missing comment mark from stock configuration.

ASTERISK-29123 #close

Change-Id: I4f94eb4544166bca8af4c17fd11edee3c6980620
2020-10-14 08:24:49 -05:00
Joshua C. Colp 412b385de5 res_pjsip: Adjust outgoing offer call pref.
This changes the outgoing offer call preference
default option to match the behavior of previous
versions of Asterisk.

The additional advanced codec negotiation options
have also been removed from the sample configuration
and marked as reserved for future functionality in
XML documentation.

The codec preference options have also been fixed to
enforce local codec configuration.

ASTERISK-29109

Change-Id: Iad19347bd5f3d89900c15ecddfebf5e20950a1c2
2020-10-13 11:14:04 -05:00
Kevin Harwell 6255e7976c Logging: Add debug logging categories
Added debug logging categories that allow a user to output debug
information based on a specified category. This lets the user limit,
and filter debug output to data relevant to a particular context,
or topic. For instance the following categories are now available for
debug logging purposes:

  dtls, dtls_packet, ice, rtcp, rtcp_packet, rtp, rtp_packet,
  stun, stun_packet

These debug categories can be enable/disable via an Asterisk CLI command.

While this overrides, and outputs debug data, core system debugging is
not affected by this patch. Statements still output at their appropriate
debug level. As well backwards compatibility has been maintained with
past debug groups that could be enabled using the CLI (e.g. rtpdebug,
stundebug, etc.).

ASTERISK-29054 #close

Change-Id: I6e6cb247bb1f01dbf34750b2cd98e5b5b41a1849
(cherry picked from commit 56028426de)
2020-10-12 10:50:26 -05:00
Sean Bright a6faa53af0 tcptls.c: Don't close TCP client file descriptors more than once
ASTERISK-28430 #close

Change-Id: Ib556b0a0c95cca939e956886214ec8d828d89606
2020-10-08 05:46:31 -05:00
Jean Aunis 7ced144867 resource_endpoints.c: memory leak when providing a 404 response
When handling a send_message request to a non-existing endpoint, the response's
body is overriden and not properly freed.

ASTERISK-29108

Change-Id: Ie1d3d70065f80793445b60f5e4a7eb31b4b9c5c8
2020-10-06 01:38:09 -05:00
Sean Bright abee490639 app_voicemail.c: Document VMSayName interruption behavior
ASTERISK-26424 #close

Change-Id: I797ad0ed302d0b3d2c90543eff5b7207ed08ecf0
2020-10-02 12:57:40 -05:00
Sean Bright 5a0b19a4f3 pbx.c: On error, ast_add_extension2_lockopt should always free 'data'
In the event that the desired extension already exists,
ast_add_extension2_lockopt() will free the 'data' it is passed before
returning an error, so we should not be freeing it ourselves.

Additionally, there were two places where ast_add_extension2_lockopt()
could return an error without also freeing the 'data' pointer, so we
add that.

ASTERISK-29097 #close

Change-Id: I904707aae55169feda050a5ed7c6793b53fe6eae
2020-10-02 12:57:22 -05:00
George Joseph 4a049ad510 app_confbridge/bridge_softmix: Add ability to force estimated bitrate
app_confbridge now has the ability to set the estimated bitrate on an
SFU bridge.  To use it, set a bridge profile's remb_behavior to "force"
and set remb_estimated_bitrate to a rate in bits per second.  The
remb_estimated_bitrate parameter is ignored if remb_behavior is something
other than "force".

Change-Id: Idce6464ff014a37ea3b82944452e56cc4d75ab0a
2020-10-02 08:04:21 -05:00
Jasper van der Neut 08ccfd4588 channels: Don't dereference NULL pointer
Check result of ast_translator_build_path against NULL before dereferencing.

ASTERISK-29091

Change-Id: Ia3538ea190bd371f70c9dd49984b021765691b29
2020-09-30 08:25:52 -05:00
Holger Hans Peter Freyther 4499fbc819 res_pjsip_sdp_rtp: Fix accidentally native bridging calls
Stop advertising RFC2833 support on the rtp_engine when DTMF mode is
auto but no tel_event was found inside SDP file.

On an incoming call create_rtp will be called and when session->dtmf is
set to AST_SIP_DTMF_AUTO, the AST_RTP_PROPERTY_DTMF will be set without
looking at the SDP file.

Once get_codecs gets called we move the DTMF mode from RFC2833 to INBAND
but continued to advertise RFC2833 support.

This meant the native_rtp bridge would falsely consider the two channels
as compatible. In addition to changing the DTMF mode we now set or
remove the AST_RTP_PROPERTY_DTMF.

The property is checked in ast_rtp_dtmf_compatible and called by
native_rtp_bridge_compatible.

ASTERISK-29051 #close

Change-Id: I1e0c1e324598a437932c0b7836bcb626aba8e287
2020-09-30 08:21:07 -05:00
lvl b3b6b5e9f7 res_musiconhold: Load all realtime entries, not just the first
ASTERISK-29099

Change-Id: I45636679c0fb5a5f59114c8741626631a604e8a6
2020-09-29 10:00:44 -05:00
Torrey Searle c470327e6c res_pjsip_diversion: fix double 181
Arming response to both AST_SIP_SESSION_BEFORE_REDIRECTING and
AST_SIP_SESSION_BEFORE_MEDIA causes 302 to to be handled twice,
resulting in to 181 being generated.

Change-Id: I866e5461564644ffb8a5e12b6f1330b50a7b63ab
2020-09-29 07:24:37 -05:00
Sean Bright 5929e0ccbd res_musiconhold: Clarify that playlist mode only supports HTTP(S) URLs
Change-Id: I41e77a04e4a523f4ed61a7a20b738ffd42be441e
2020-09-28 14:02:49 -05:00
Sean Bright 9b08eddf90 dsp.c: Update calls to ast_format_cmp to check result properly
ASTERISK-28311 #close

Change-Id: Ib1ce8fc1a8752751f5bf3615c59245532dfd9aa2
2020-09-23 15:21:41 -05:00
Sean Bright d0644faa5a res_musiconhold: Start playlist after initial announcement
Only track our sample offset if we are playing a non-announcement file,
otherwise we will skip that number of samples when we start playing the
first MoH file.

ASTERISK-24329 #close

Change-Id: Ib6b3c84fcaa1063889ab38ba7e7fc50050a3ccfc
2020-09-23 11:25:42 -05:00
Joshua C. Colp 9eeb40af33 res_pjsip_session: Fix stream name memory leak.
When constructing a stream name based on the media type
and position the allocated name was not being freed
causing a leak.

Change-Id: I52510863b24a2f531f0a55b440bb2c81844029de
2020-09-23 10:58:20 -05:00
Sean Bright 28c88e8fe2 func_curl.c: Prevent crash when using CURLOPT(httpheader)
Because we use shared thread-local cURL instances, we need to ensure
that the state of the cURL instance is correct before each invocation.

In the case of custom headers, we were not resetting cURL's internal
HTTP header pointer which could result in a crash if subsequent
requests do not configure custom headers.

ASTERISK-29085 #close

Change-Id: I8b4ab34038156dfba613030a45f10e932d2e992d
2020-09-23 10:04:23 -05:00
Joshua C. Colp 957aff751d res_pjsip_session: Fix session reference leak.
The ast_sip_dialog_get_session function returns the session
with reference count increased. This was not taken into
account and was causing sessions to remain around when they
should not be.

ASTERISK-29089

Change-Id: I430fa721b0a824311a59effec6056e9ec528e3e8
2020-09-23 10:02:30 -05:00
Michal Hajek 2bce21da88 res_stasis.c: Add compare function for bridges moh container
Sometimes not play MOH on bridge.

ASTERISK-29081
Reported-by: Michal Hajek <michal.hajek@daktela.com>

Change-Id: I760c73e0c9be1d340303b5d1c18a00c4759e8232
2020-09-23 09:58:41 -05:00
George Joseph 99bd7d95de logger.h: Fix ast_trace to respect scope_level
ast_trace() was always emitting messages when it's level was set to -1
because it was ignoring scope_level.

Change-Id: I849c8f4f4613899c37f82be0202024e7d117e506
2020-09-22 09:54:34 -05:00
Sean Bright c90c182932 audiosocket: Fix module menuselect descriptions
The module description needs to be on the same line as the
AST_MODULE_INFO or it is not parsed correctly.

Change-Id: I9ba11df1415369790e8656fcb527bb2749373c21
2020-09-22 09:02:10 -05:00
George Joseph fdc13060df bridge_softmix/sfu_topologies_on_join: Ignore topology change failures
When a channel joins a bridge, we do topology change requests on all
existing channels to add the new participant to them.  However the
announcer channel will return an error because it doesn't support
topology in the first place.  Unfortunately, there doesn't seem to be a
reliable way to tell if the error is expected or not so the error is
ignored for all channels.  If the request fails on a "real" channel,
that channel just won't get the new participant's video.

Change-Id: Ic95db4683f27d224c1869fe887795d6b9fdea4f0
2020-09-17 14:20:23 -05:00
Sean Bright 6f32c254be res_pjsip_session.c: Fix build when TEST_FRAMEWORK is not defined
Change-Id: Id4852c26e9c412af8e37b5dd3c15da9453ad3276
2020-09-16 09:09:23 -05:00
Torrey Searle 83140c9fed res_pjsip_diversion: implement support for History-Info
Implemention of History-Info capable of interworking with Diversion
Header following RFC7544

ASTERISK-29027 #close

Change-Id: I2296369582d4b295c5ea1e60bec391dd1d318fa6
2020-09-16 09:07:14 -05:00
Sean Bright 4964302984 format_cap: Perform codec lookups by pointer instead of name
ASTERISK-28416 #close

Change-Id: I069420875ebdbcaada52d92599a5f7de3cb2cdf4
2020-09-15 14:37:21 -05:00
George Joseph cc71be0078 res_pjsip_session: Fix issue with COLP and 491
The recent 491 changes introduced a check to determine if the active
and pending topologies were equal and to suppress the re-invite if they
were. When a re-invite is sent for a COLP-only change, the pending
topology is NULL so that check doesn't happen and the re-invite is
correctly sent. Of course, sending the re-invite sets the pending
topology.  If a 491 is received, when we resend the re-invite, the
pending topology is set and since we didn't request a change to the
topology in the first place, pending and active topologies are equal so
the topologies-equal check causes the re-invite to be erroneously
suppressed.

This change checks if the topologies are equal before we run the media
state resolver (which recreates the pending topology) so that when we
do the final topologies-equal check we know if this was a topology
change request.  If it wasn't a change request, we don't suppress
the re-invite even though the topologies are equal.

ASTERISK-29014

Change-Id: Iffd7dd0500301156a566119ebde528d1a9573314
2020-09-14 09:40:14 -06:00
George Joseph ad4f2a8c99 debugging: Add enough to choke a mule
Added to:
 * bridges/bridge_softmix.c
 * channels/chan_pjsip.c
 * include/asterisk/res_pjsip_session.h
 * main/channel.c
 * res/res_pjsip_session.c

There NO functional changes in this commit.

Change-Id: I06af034d1ff3ea1feb56596fd7bd6d7939dfdcc3
2020-09-11 10:41:15 -06:00
George Joseph d4f3b17dd3 res_pjsip_session: Handle multi-stream re-invites better
When both Asterisk and a UA send re-invites at the same time, both
send 491 "Transaction in progress" responses to each other and back
off a specified amount of time before retrying. When Asterisk
prepares to send its re-invite, it sets up the session's pending
media state with the new topology it wants, then sends the
re-invite.  Unfortunately, when it received the re-invite from the
UA, it partially processed the media in the re-invite and reset
the pending media state before sending the 491 losing the state it
set in its own re-invite.

Asterisk also was not tracking re-invites received while an existing
re-invite was queued resulting in sending stale SDP with missing
or duplicated streams, or no re-invite at all because we erroneously
determined that a re-invite wasn't needed.

There was also an issue in bridge_softmix where we were using a stream
from the wrong topology to determine if a stream was added.  This also
caused us to erroneously determine that a re-invite wasn't needed.

Regardless of how the delayed re-invite was triggered, we need to
reconcile the topology that was active at the time the delayed
request was queued, the pending topology of the queued request,
and the topology currently active on the session.  To do this we
need a topology resolver AND we need to make stream named unique
so we can accurately tell what a stream has been added or removed
and if we can re-use a slot in the topology.

Summary of changes:

 * bridge_softmix:
   * We no longer reset the stream name to "removed" in
     remove_all_original_streams().  That was causing  multiple streams
     to have the same name and wrecked the checks for duplicate streams.

   * softmix_bridge_stream_sources_update() was checking the old_stream
     to see if it had the softmix prefix and not considering the stream
     as "new" if it did.  If the stream in that slot has something in it
     because another re-invite happened, then that slot in old might
     have a softmix stream but the same stream in new might actually
     be a new one.  Now we check the new_stream's name instead of
     the old_stream's.

 * stream:
   * Instead of using plain media type name ("audio", "video", etc) as
     the default stream name, we now append the stream position to it
     to make it unique.  We need to do this so we can distinguish multiple
     streams of the same type from each other.

   * When we set a stream's state to REMOVED, we no longer reset its
     name to "removed" or destroy its metadata.  Again, we need to
     do this so we can distinguish multiple streams of the same
     type from each other.

 * res_pjsip_session:
   * Added resolve_refresh_media_states() that takes in 3 media states
     and creates an up-to-date pending media state that includes the changes
     that might have happened while a delayed session refresh was in the
     delayed queue.

   * Added is_media_state_valid() that checks the consistency of
     a media state and returns a true/false value. A valid state has:
     * The same number of stream entries as media session entries.
         Some media session entries can be NULL however.
     * No duplicate streams.
     * A valid stream for each non-NULL media session.
     * A stream that matches each media session's stream_num
       and media type.

   * Updated handle_incoming_sdp() to set the stream name to include the
     stream position number in the name to make it unique.

   * Updated the ast_sip_session_delayed_request structure to include both
     the pending and active media states and updated the associated delay
     functions to process them.

   * Updated sip_session_refresh() to accept both the pending and active
     media states that were in effect when the request was originally queued
     and to pass them on should the request need to be delayed again.

   * Updated sip_session_refresh() to call resolve_refresh_media_states()
     and substitute its results for the pending state passed in.

   * Updated sip_session_refresh() with additional debugging.

   * Updated session_reinvite_on_rx_request() to simply return PJ_FALSE
     to pjproject if a transaction is in progress.  This stops us from
     creating a partial pending media state that would be invalid later on.

   * Updated reschedule_reinvite() to clone both the current pending and
     active media states and pass them to delay_request() so the resolver
     can tell what the original intention of the re-invite was.

   * Added a large unit test for the resolver.

ASTERISK-29014

Change-Id: Id3440972943c611a15f652c6c569fa0e4536bfcb
2020-09-11 10:41:15 -06:00
Sungtae Kim 1fd12b88c7 realtime: Increased reg_server character size
Currently, the ps_contacts table's reg_server column in realtime database type is varchar(20).
This is fine for normal cases, but if the hostname is longer than 20, it returns error and then
failed to register the contact address of the peer.

Normally, 20 characters limitation for the hostname is fine, but with the cloud env.
So, increased the size to 255.

ASTERISK-29056

Change-Id: Iac52c8c35030303cfa551bb39f410b33bffc507d
2020-09-10 10:37:38 -05:00
Sungtae Kim a0d41a27d4 res_stasis.c: Added video_single option for bridge creation
Currently, it was not possible to create bridge with video_mode single.
This made hard to put the bridge in a vidoe_single mode.
So, added video_single option for Bridge creation using the ARI.
This allows create a bridge with video_mode single.

ASTERISK-29055

Change-Id: I43e720e5c83fc75fafe10fe22808ae7f055da2ae
2020-09-10 09:54:35 -05:00
Ben Ford 7eaae4e7b6 Bridging: Use a ref to bridge_channel's channel to prevent crash.
There's a race condition with bridging where a bridge can be torn down
causing the bridge_channel's ast_channel to become NULL when it's still
needed. This particular case happened with attended transfers, but the
crash occurred when trying to publish a stasis message. Now, the
bridge_channel is locked, a ref to the ast_channel is obtained, and that
ref is passed down the chain.

Change-Id: Ic48715c0c041615d17d286790ae3e8c61bb28814
2020-09-09 18:18:08 -05:00
Asterisk Development Team f589985840 Update CHANGES and UPGRADE.txt for 18.0.0 2020-09-09 09:08:27 -05:00
Patrick Verzele 5a49757e40 res_pjsip_session: Deferred re-INVITE without SDP send a=sendrecv instead of a=sendonly
Building on ASTERISK-25854. When the device requests hold by sending SDP with attribute recvonly, asterisk places the session in sendonly mode. When the device later requests to resume the call by using a re-INVITE excluding SDP, asterisk needs to change the sendonly mode to sendrecv again.

Change-Id: I60341ce3d87f95869f3bc6dc358bd3e8286477a6
2020-09-03 08:15:14 -05:00
Kevin Harwell ec03909831 conversions: Add string to signed integer conversion functions
Change-Id: Id603b0b03b78eb84c7fca030a08b343c0d5973f9
2020-09-02 06:22:25 -05:00
Kfir Itzhak c83e4821e5 app_queue: Fix leave-empty not recording a call as abandoned
This fixes a bug introduced mistakenly in ASTERISK-25665:
If leave-empty is enabled, a call may sometimes be removed from
a queue without recording it as abandoned.
This causes Asterisk to not generate an abandon event for that
call, and for the queue abandoned counter to be incorrect.

ASTERISK-29043 #close

Change-Id: I1a71b81df78adff59af587f1d8483cf57df430c7
2020-09-01 10:14:41 -05:00
George Joseph e32815dddb ast_coredumper: Fix issues with naming
If you run ast_coredumper --tarball-coredumps in the same directory
as the actual coredump, tar can fail because the link to the
actual coredump becomes recursive.  The resulting tarball will
have everything _except_ the coredump (which is usually what
you need)

There's also an issue that the directory name in the tarball
is the same as the coredump so if you extract the tarball the
directory it creates will overwrite the coredump.

So:

 * Made the link to the coredump use the absolute path to the
   file instead of a relative one.  This prevents the recursive
   link and allows tar to add the coredump.

 * The tarballed directory is now named <coredump>.output instead
   of just <coredump> so if you expand the tarball it won't
   overwrite the coredump.

Change-Id: I8b3eeb26e09a577c702ff966924bb0a2f9a759ea
2020-08-31 17:14:34 -05:00
Joshua C. Colp 4f0766dcda parking: Copy parker UUID as well.
When fixing issues uncovered by GCC10 a copy of the parker UUID
was removed accidentally. This change restores it so that the
subscription has the data it needs.

ASTERISK-29042

Change-Id: I7d396a14ea648bd26d3c363dd78e78bd386b544a
2020-08-31 12:23:55 -05:00
Alexander Traud 9ed1b1452d sip_nat_settings: Update script for latest Linux.
With the latest Linux, 'ifconfig' is not installed on default anymore.
Furthermore, the output of the current net-tools 'ifconfig' changed.
Therefore, parsing failed. This update uses 'ip addr show' instead.
Finally, the service for the external IP changed.

Change-Id: I9b1a7c3f457e3553b50a3e9a55524e40d70245a0
2020-08-28 14:54:33 -05:00
Alexander Traud 217449a1e5 samples: Fix keep_alive_interval default in pjsip.conf.
Since ASTERISK_27978 the default is not off but 90 seconds. That change
happened because ASTERISK_27347 disabled the keep-alives in the bundled
PJProject and Asterisk should behave the same as before.

Change-Id: Ie63dc558ade6a5a2b969c30a4bd492d63730dc46
2020-08-28 14:13:57 -05:00
Kevin Harwell 31fbfc5e95 chan_pjsip: disallow PJSIP_SEND_SESSION_REFRESH pre-answer execution
This patch makes it so if the PJSIP_SEND_SESSION_REFRESH dialplan function
is called on a channel prior to answering a warning is issued and the
function returns unsuccessful.

ASTERISK-28878 #close

Change-Id: I053f767d10cf3b2b898fa9e3e7c35ff07e23c9bb
2020-08-28 13:10:10 -05:00
Joshua C. Colp 6d50d152d8 pbx: Fix hints deadlock between reload and ExtensionState.
When the ExtensionState AMI action is executed on a pattern matched
hint it can end up adding a new hint if one does not already exist.
This results in a locking order of contexts -> hints -> contexts.

If at the same time a reload is occurring and adding its own hint
it will have a locking order of hints -> contexts.

This results in a deadlock as one thread wants a lock on contexts
that the other has, and the other thread wants a lock on hints
that the other has.

This change enforces a hints -> contexts locking order by explicitly
locking hints in the places where a hint is added when queried for.
This matches the order seen through normal adding of hints.

ASTERISK-29046

Change-Id: I49f027f4aab5d2d50855ae937bcf5e2fd8bfc504
2020-08-28 12:37:10 -05:00
George Joseph 5a8cacb93d logger.c: Added a new log formatter called "plain"
Added a new log formatter called "plain" that always prints
file, function and line number if available (even for verbose
messages) and never prints color control characters.  It also
doesn't apply any special formatting for verbose messages.
Most suitable for file output but can be used for other channels
as well.

You use it in logger.conf like so:
debug => [plain]debug
console => [plain]error,warning,debug,notice,pjsip_history
messages => [plain]warning,error,verbose

Change-Id: I4fdfe4089f66ce2f9cb29f3005522090dbb5243d
2020-08-28 12:28:47 -05:00
Nickolay Shmyrev 0319e0b07f res_speech: Bump reference on format object
Properly bump reference on format object to avoid memory corruption on double free

ASTERISK-29040 #close

Change-Id: Ic5a7faabfe2ef965ddb024186e1de7ca4542e2a3
2020-08-27 13:52:05 -05:00
Torrey Searle addd295cda res_pjsip_diversion: handle 181
Adapt the response handler so it also called when 181 is received.
In the case 181 is received, also generate the 181 response.

ASTERISK-29001 #close

Change-Id: I73cfee46a8ca85371280ebdb38674f8fde7510df
2020-08-26 13:14:37 -05:00
Evandro César Arruda 36dd15c659 app_queue: Member lastpause time reseting
This fixes the reseting members lastpause problem when realtime members is being used,
the function rt_handle_member_record was forcing the reset members lastpause because it
does not exist in realtime

ASTERISK-29034 #close

Change-Id: Ic9107e4456732a1f78412a32adb2ef87f5da40b5
2020-08-25 17:29:05 -05:00
Sean Bright b575868000 app_voicemail: Process urgent messages with mailcmd
Rather than putting messages into INBOX and then moving them to Urgent
later, put them directly in to the Urgent folder. This prevents
mailcmd from being skipped.

ASTERISK-27273 #close

Change-Id: I49934e093290d308506ab8d45a40ef705c5ae4f5
2020-08-25 16:46:13 -05:00
Joshua C. Colp 3c074038fe res_pjsip_session: Don't aggressively terminate on failed re-INVITE.
Per the RFC when an outgoing re-INVITE is done we should
only terminate the dialog if a 481 or 408 is received.

ASTERISK-29033

Change-Id: I6c3ff513aa41005d02de0396ba820083e9b18503
2020-08-25 13:24:29 -05:00
Sean Bright 5ec7099312 bridge_channel: Ensure text messages are zero terminated
T.140 data in RTP is not zero terminated, so when we are queuing a text
frame on a bridge we need to ensure that we are passing a zero
terminated string.

ASTERISK-28974 #close

Change-Id: Ic10057387ce30b2094613ea67e3ae8c5c431dda3
2020-08-25 10:26:56 -05:00
Sean Bright 5dfeeba623 res_musiconhold.c: Use ast_file_read_dir to scan MoH directory
Two changes of note in this patch:

* Use ast_file_read_dir instead of opendir/readdir/closedir

* If the files list should be sorted, do that at the end rather than as
  we go which improves performance for large lists

Change-Id: Ic7e9c913c0f85754c99c74c9cf6dd3514b1b941f
2020-08-25 09:35:04 -05:00
George Joseph c4c72d55a2 scope_trace: Added debug messages and added additional macros
The SCOPE_ENTER and SCOPE_EXIT* macros now print debug messages
at the same level as the scope level.  This allows the same
messages to be printed to the debug log when AST_DEVMODE
isn't enabled.

Also added a few variants of the SCOPE_EXIT macros that will
also call ast_log instead of ast_debug to make it easier to
use scope tracing and still print error messages.

Change-Id: I7fe55f7ec28069919a0fc0b11a82235ce904cc21
2020-08-25 09:21:27 -05:00
George Joseph d26ab7f8f9 stream.c: Added 2 more debugging utils and added pos to stream string
* Added ast_stream_to_stra and ast_stream_topology_to_stra() macros
   which are shortcuts for
      ast_str_tmp(256, ast_stream_to_str(stream, &STR_TMP))

 * Added the stream position to the string representation of the
   stream.

 * Fixed some formatting in ast_stream_to_str().

Change-Id: Idaf4cb0affa46d4dce58a73a111f35435331cc4b
2020-08-20 07:46:11 -06:00
Dennis Buteyn 9058d9e591 chan_sip: Clear ToHost property on peer when changing to dynamic host
The ToHost parameter was not cleared when a peer's host value was
changed to dynamic. This causes invites to be sent to the original host.

ASTERISK-29011 #close

Change-Id: I9678d512741f71baca8f131a65b7523020b07d5c
2020-08-18 09:01:44 -05:00
George Joseph 6faf76308d ACN: Changes specific to the core
Allow passing a topology from the called channel back to the
calling channel.

 * Added a new function ast_queue_answer() that accepts a stream
   topology and queues an ANSWER CONTROL frame with it as the
   data.  This allows the called channel to indicate its resolved
   topology.

 * Added a new virtual function to the channel tech structure
   answer_with_stream_topology() that allows the calling channel
   to receive the called channel's topology.  Added
   ast_raw_answer_with_stream_topology() that invokes that virtual
   function.

 * Modified app_dial.c and features.c to grab the topology from the
   ANSWER frame queued by the answering channel and send it to
   the calling channel with ast_raw_answer_with_stream_topology().

 * Modified frame.c to automatically cleanup the reference
   to the topology on ANSWER frames.

Added a few debugging messages to stream.c.

Change-Id: I0115d2ed68d6bae0f87e85abcf16c771bdaf992c
2020-08-18 05:26:24 -05:00
cmaj 543f936147 Makefile: Fix certified version numbers
Adds sed before awk to produce reasonable ASTERISKVERSIONNUM
on certified versions of Asterisk eg. 16.8-cert3 is 160803
instead of the previous 00800.

ASTERISK-29021 #close

Change-Id: Icf241df0ff6db09011b8c936a317a84b0b634e16
2020-08-14 14:52:18 -05:00
Sean Bright 57554c2834 res_musiconhold.c: Prevent crash with realtime MoH
The MoH class internal file vector is potentially being manipulated by
multiple threads at the same time without sufficient locking. Switch to
a reference counted list and operate on copies where necessary.

ASTERISK-28927 #close

Change-Id: I479c5dcf88db670956e8cac177b5826c986b0217
2020-08-11 17:18:23 -05:00
Joshua C. Colp a3d87f78ed res_pjsip: Fix codec preference defaults.
When reading in a codec preference configuration option
the value would be set on the respective option before
applying any default adjustments, resulting in the
configuration not being as expected.

This was exposed by the REST API push configuration as
it used the configuration returned by Asterisk to then do
a modification. In the case of codec preferences one of
the options had a transcode value of "unspecified" when the
defaults should have ensured it would be "allow" instead.

This also renames the options in other places that were
missed.

Change-Id: I4ad42e74fdf181be2e17bc75901c62591d403964
2020-08-11 05:43:51 -05:00
Sean Bright da8a617dc9 vector.h: Fix implementation of AST_VECTOR_COMPACT() for empty vectors
The assumed behavior of realloc() - that it was effectively a free() if
its second argument was 0 - is Linux specific behavior and is not
guaranteed by either POSIX or the C specification.

Instead, if we want to resize a vector to 0, do it explicitly.

Change-Id: Ife31d4b510ebab41cb5477fdc7ea4e3138ca8b4f
2020-08-10 07:10:30 -05:00
Michael Neuhauser 6482ab5bea pjproject: clone sdp to protect against (nat) modifications
PJSIP, UDP transport with external_media_address and session timers
enabled. Connected to SIP server that is not in local net. Asterisk
initiated the connection and is refreshing the session after 150s
(timeout 300s). The 2nd refresh-INVITE triggered by the pjsip timer has
a malformed IP address in its SDP (garbage string). This only happens
when the SDP is modified by the nat-code to replace the local IP address
with the configured external_media_address.
Analysis: the code to modify the SDP (in
res_pjsip_session.c:session_outgoing_nat_hook() and also (redundantly?)
in res_pjsip_sdp_rtp.c:change_outgoing_sdp_stream_media_address()) uses
the tdata->pool to allocate the replacement string. But the same
pjmedia_sdp_stream that was modified for the 1st refresh-INVITE is also
used for the 2nd refresh-INVITE (because it is stored in pjmedia's
pjmedia_sdp_neg structure). The problem is, that at that moment, the
tdata->pool that holds the stringified external_media_address from the
1. refresh-INVITE has long been reused for something else.
Fix by Sauw Ming of pjproject (see
https://github.com/pjsip/pjproject/pull/2476): the local, potentially
modified pjmedia_sdp_stream is cloned in
pjproject/source/pjsip/src/pjmedia/sip_neg.c:process_answer() and the
clone is stored, thereby detaching from the tdata->pool (which is only
released *after* process_answer())

ASTERISK-28973
Reported-by: Michael Neuhauser

Change-Id: I272ac22436076596e06aa51b9fa23fd1c7734a0e
2020-08-10 06:33:25 -05:00
Ben Ford 769a9611e7 utils.c: NULL terminate ast_base64decode_string.
With the addition of STIR/SHAKEN, the function ast_base64decode_string
was added for convenience since there is a lot of converting done during
the STIR/SHAKEN process. This function returned the decoded string for
you, but did not NULL terminate it, causing some issues (specifically
with MALLOC_DEBUG). Now, the returned string is NULL terminated, and the
documentation has been updated to reflect this.

Change-Id: Icdd7d05b323b0c47ff6ed43492937a03641bdcf5
2020-08-06 12:19:29 -05:00
George Joseph 802aa97fa0 ACN: Configuration renaming for pjsip endpoint
This change renames the codec preference endpoint options.
incoming_offer_codec_prefs becomes codec_prefs_incoming_offer
to keep the options together when showing an endpoint.

Change-Id: I6202965b4723777f22a83afcbbafcdafb1d11c8d
2020-08-06 10:50:26 -05:00
Ben Ford de23cb4002 res_stir_shaken: Fix memory allocation error in curl.c
Fixed a memory allocation that was not passing in the correct size for
the struct in curl.c.

Change-Id: I5fb92fbbe84b075fa6aefa2423786df80e114c3a
(cherry picked from commit deaa3742dc)
2020-08-05 05:01:35 -05:00
George Joseph 71446b68fc res_pjsip_session: Ensure reused streams have correct bundle group
When a bundled stream is removed, its bundle_group is reset to -1.
If that stream is later reused, the bundle parameters on session
media need to be reset correctly it could mistakenly be rebundled
with a stream that was removed and never reused.  Since the removed
stream has no rtp instance, a crash will result.

Change-Id: Ie2b792220f9291587ab5f9fd123145559dba96d7
2020-07-28 12:12:55 -05:00
Joshua C. Colp 99eafe5771 res_pjsip_registrar: Don't specify an expiration for static contacts.
Statically configured contacts on an AOR don't have an expiration
time so when adding them to the resulting 200 OK if an endpoint
registers ensure they are marked as such.

ASTERISK-28995

Change-Id: I9f0e45eb2ccdedc9a0df5358634a19ccab0ad596
2020-07-28 09:46:52 -05:00
Sean Bright d9ae902f52 utf8.c: Add UTF-8 validation and utility functions
There are various places in Asterisk - specifically in regards to
database integration - where having some kind of UTF-8 validation would
be beneficial. This patch adds:

* Functions to validate that a given string contains only valid UTF-8
  sequences.

* A function to copy a string (similar to ast_copy_string) stopping when
  an invalid UTF-8 sequence is encountered.

* A UTF-8 validator that allows for progressive validation.

All of this is based on the excellent UTF-8 decoder by Björn Höhrmann.
More information is available here:

    https://bjoern.hoehrmann.de/utf-8/decoder/dfa/

The API was written in such a way that should allow us to replace the
implementation later should we determine that we need something more
comprehensive.

Change-Id: I3555d787a79e7c780a7800cd26e0b5056368abf9
2020-07-28 09:45:17 -05:00
sungtae kim 2e32b56bdb stasis_bridge.c: Fixed wrong video_mode shown
Currently, if the bridge has created by the ARI, the video_mode
parameter was
not shown in the BridgeCreated event correctly.

Fixed it and added video_mode shown in the 'bridge show <bridge id>'
cli.

ASTERISK-28987

Change-Id: I8c205126724e34c2bdab9380f523eb62478e4295
2020-07-24 11:32:47 -05:00
Sean Bright 9022f35f09 vector.h: Add AST_VECTOR_SORT()
Allows a vector to be sorted in-place, rather than only during
insertion.

Change-Id: I22cba9ddf556a7e44dacc53c4431bd81dd2fa780
2020-07-24 11:29:35 -05:00
George Joseph a678dafac8 CI: Force publishAsteriskDocs to use python2
Change-Id: I7d951e75ad2d472fa096647dfb55670b11105e23
2020-07-24 08:58:12 -05:00
Joshua C. Colp af70bbb13a websocket / pjsip: Increase maximum packet size.
When dealing with a lot of video streams on WebRTC
the resulting SDPs can grow to be quite large. This
effectively doubles the maximum size to allow more
streams to exist.

The res_http_websocket module has also been changed
to use a buffer on the session for reading in packets
to ensure that the stack space usage is not excessive.

Change-Id: I31d4351d70c8e2c11564807a7528b984f3fbdd01
2020-07-23 07:30:17 -05:00
Sean Bright 7a43bedd72 acl.c: Coerce a NULL pointer into the empty string
If an ACL is misconfigured in the realtime database (for instance, the
"rule" is blank) and Asterisk attempts to read the ACL, Asterisk will
crash.

ASTERISK-28978 #close

Change-Id: Ic1536c4df856231bfd2da00128f7822224d77610
2020-07-20 11:37:48 -05:00
Joshua C. Colp 8d15f72721 pjsip: Include timer patch to prevent cancelling timer 0.
I noticed this while looking at another issue and brought
it up with Teluu. It was possible for an uninitialized timer
to be cancelled, resulting in the invalid timer id of 0
being placed into the timer heap causing issues.

This change is a backport from the pjproject repository
preventing this from happening.

Change-Id: I1ba318b1f153a6dd7458846396e2867282b428e7
2020-07-16 07:26:00 -05:00
George Joseph 3330764213 Update .gitreview defaultbranch to 18
Change-Id: Ib2c42fc2d46563e2fbadbd5513cb029b4042791e
2020-07-15 08:14:45 -06:00
839 changed files with 206740 additions and 22581 deletions

87
.github/ISSUE_TEMPLATE/bug-report.yml vendored Normal file
View File

@ -0,0 +1,87 @@
name: Bug
description: File a bug report
title: "[bug]: "
labels: ["bug", "triage"]
#assignees:
# - octocat
body:
- type: markdown
attributes:
value: |
Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. Please note that log messages and other files should not be sent to the Sangoma Asterisk Team unless explicitly asked for. All files should be placed on this issue in a sanitized fashion as needed.
A good first step is for you to review the Asterisk Issue Guidelines if you haven't already. The guidelines detail what is expected from an Asterisk issue report.
Then, if you are submitting a patch, please review the Patch Contribution Process.
Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.
Please note that by submitting data, code, or documentation to Sangoma through GitHub, you accept the Terms of Use present at
https://www.asterisk.org/terms-of-use/.
Thanks for taking the time to fill out this bug report!
- type: dropdown
id: severity
attributes:
label: Severity
options:
- Trivial
- Minor
- Major
- Critical
- Blocker
validations:
required: true
- type: input
id: versions
attributes:
label: Versions
description: Enter one or more versions separated by commas.
validations:
required: true
- type: input
id: components
attributes:
label: Components/Modules
description: Enter one or more components or modules separated by commas.
validations:
required: true
- type: textarea
id: environment
attributes:
label: Operating Environment
description: OS, Disribution, Version, etc.
validations:
required: true
- type: dropdown
id: frequency
attributes:
label: Frequency of Occurrence
options:
- "Never"
- "One Time"
- "Occasional"
- "Frequent"
- "Constant"
- type: textarea
id: description
attributes:
label: Issue Description
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell
- type: markdown
attributes:
value: |
[Asterisk Issue Guidelines](https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines)
- type: checkboxes
id: guidelines
attributes:
label: Asterisk Issue Guidelines
options:
- label: Yes, I have read the Asterisk Issue Guidelines
required: true

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Asterisk Community Support
url: https://community.asterisk.org
about: Please ask and answer questions here.
- name: Feature Requests
url: https://github.com/asterisk/asterisk-feature-requests/issues
about: Please submit feature requests here.

27
.github/ISSUE_TEMPLATE/improvement.yml vendored Normal file
View File

@ -0,0 +1,27 @@
name: Improvement
description: Submit an improvement to existing functionality
title: "[improvement]: "
labels: ["improvement", "triage"]
body:
- type: markdown
attributes:
value: |
Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. Please note that log messages and other files should not be sent to the Sangoma Asterisk Team unless explicitly asked for. All files should be placed on this issue in a sanitized fashion as needed.
A good first step is for you to review the Asterisk Issue Guidelines if you haven't already. The guidelines detail what is expected from an Asterisk issue report.
Then, if you are submitting a patch, please review the Patch Contribution Process.
Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.
Please note that by submitting data, code, or documentation to Sangoma through GitHub, you accept the Terms of Use present at
https://www.asterisk.org/terms-of-use/.
Thanks for taking the time to fill out this bug report!
- type: textarea
id: description
attributes:
label: Improvement Description
description: Describe the improvement in as much detail as possible
validations:
required: true

27
.github/ISSUE_TEMPLATE/new-feature.yml vendored Normal file
View File

@ -0,0 +1,27 @@
name: New Feature Submission
description: Submit a New Feature
title: "[new-feature]: "
labels: ["new-feature", "triage"]
body:
- type: markdown
attributes:
value: |
Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. Please note that log messages and other files should not be sent to the Sangoma Asterisk Team unless explicitly asked for. All files should be placed on this issue in a sanitized fashion as needed.
A good first step is for you to review the Asterisk Issue Guidelines if you haven't already. The guidelines detail what is expected from an Asterisk issue report.
Then, if you are submitting a patch, please review the Patch Contribution Process.
Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.
Please note that by submitting data, code, or documentation to Sangoma through GitHub, you accept the Terms of Use present at
https://www.asterisk.org/terms-of-use/.
Thanks for taking the time to fill out this bug report!
- type: textarea
id: description
attributes:
label: Feature Description
description: Describe the new feature in as much detail as possible
validations:
required: true

167
.github/workflows/CherryPickTest.yml vendored Normal file
View File

@ -0,0 +1,167 @@
name: CherryPickTest
run-name: "Cherry-Pick Tests for PR ${{github.event.number}}"
on:
pull_request_target:
types: [ labeled ]
concurrency:
group: ${{github.workflow}}-${{github.event.number}}
cancel-in-progress: true
env:
PR_NUMBER: ${{ github.event.number }}
MODULES_BLACKLIST: ${{ vars.GATETEST_MODULES_BLACKLIST }} ${{ vars.UNITTEST_MODULES_BLACKLIST }}
jobs:
IdentifyBranches:
name: IdentifyBranches
if: ${{ github.event.label.name == vars.CHERRY_PICK_TEST_LABEL }}
outputs:
branches: ${{ steps.getbranches.outputs.branches }}
branch_count: ${{ steps.getbranches.outputs.branch_count }}
runs-on: ubuntu-latest
steps:
- name: Remove Trigger Label, Add InProgress Label
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr edit --repo ${{github.repository}} \
--remove-label ${{vars.CHERRY_PICK_TEST_LABEL}} \
--remove-label ${{vars.CHERRY_PICK_CHECKS_PASSED_LABEL}} \
--remove-label ${{vars.CHERRY_PICK_CHECKS_FAILED_LABEL}} \
--remove-label ${{vars.CHERRY_PICK_GATES_PASSED_LABEL}} \
--remove-label ${{vars.CHERRY_PICK_GATES_FAILED_LABEL}} \
--remove-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
${{env.PR_NUMBER}} || :
- name: Get cherry-pick branches
uses: asterisk/asterisk-ci-actions/GetCherryPickBranchesFromPR@main
id: getbranches
with:
repo: ${{github.repository}}
pr_number: ${{env.PR_NUMBER}}
cherry_pick_regex: ${{vars.CHERRY_PICK_REGEX}}
github_token: ${{secrets.GITHUB_TOKEN}}
- name: Check Branch Count
if: ${{ steps.getbranches.outputs.branch_count > 0 }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr edit --repo ${{github.repository}} \
--add-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
${{env.PR_NUMBER}} || :
CherryPickUnitTestMatrix:
needs: [ IdentifyBranches ]
if: ${{ needs.IdentifyBranches.outputs.branch_count > 0 && ( success() || failure() ) }}
continue-on-error: false
strategy:
fail-fast: false
matrix:
branch: ${{ fromJSON(needs.IdentifyBranches.outputs.branches) }}
runs-on: ubuntu-latest
steps:
- name: Run Unit Tests for branch ${{matrix.branch}}
uses: asterisk/asterisk-ci-actions/AsteriskUnitComposite@main
with:
asterisk_repo: ${{github.repository}}
pr_number: ${{env.PR_NUMBER}}
base_branch: ${{matrix.branch}}
is_cherry_pick: true
modules_blacklist: ${{env.MODULES_BLACKLIST}}
github_token: ${{secrets.GITHUB_TOKEN}}
unittest_command: ${{vars.UNITTEST_COMMAND}}
CherryPickUnitTests:
needs: [ IdentifyBranches, CherryPickUnitTestMatrix ]
if: ${{ needs.IdentifyBranches.outputs.branch_count > 0 && ( success() || failure() ) }}
runs-on: ubuntu-latest
steps:
- name: Check unit test matrix status
env:
RESULT: ${{needs.CherryPickUnitTestMatrix.result}}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
case $RESULT in
success)
gh pr edit --repo ${{github.repository}} \
--add-label ${{vars.CHERRY_PICK_CHECKS_PASSED_LABEL}} \
${{env.PR_NUMBER}} || :
echo "::notice::All tests passed"
exit 0
;;
skipped)
gh pr edit --repo ${{github.repository}} \
--remove-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
--add-label ${{vars.CHERRY_PICK_CHECKS_FAILED_LABEL}} \
${{env.PR_NUMBER}} || :
echo "::notice::Unit tests were skipped because of an earlier failure"
exit 1
;;
*)
gh pr edit --repo ${{github.repository}} \
--remove-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
--add-label ${{vars.CHERRY_PICK_CHECKS_FAILED_LABEL}} \
${{env.PR_NUMBER}} || :
echo "::error::One or more tests failed ($RESULT)"
exit 1
esac
CherryPickGateTestMatrix:
needs: [ IdentifyBranches, CherryPickUnitTests ]
if: ${{ success() }}
continue-on-error: false
strategy:
fail-fast: false
matrix:
branch: ${{ fromJSON(needs.IdentifyBranches.outputs.branches) }}
group: ${{ fromJSON(vars.GATETEST_LIST) }}
runs-on: ubuntu-latest
steps:
- name: Run Gate Tests for ${{ matrix.group }}-${{matrix.branch}}
uses: asterisk/asterisk-ci-actions/AsteriskGateComposite@main
with:
test_type: Gate
asterisk_repo: ${{github.repository}}
pr_number: ${{env.PR_NUMBER}}
base_branch: ${{matrix.branch}}
is_cherry_pick: true
modules_blacklist: ${{env.MODULES_BLACKLIST}}
github_token: ${{secrets.GITHUB_TOKEN}}
testsuite_repo: ${{vars.TESTSUITE_REPO}}
gatetest_group: ${{matrix.group}}
gatetest_command: ${{ toJSON(fromJSON(vars.GATETEST_COMMANDS)[matrix.group]) }}
CherryPickGateTests:
needs: [ IdentifyBranches, CherryPickGateTestMatrix ]
if: ${{ success() || failure() }}
runs-on: ubuntu-latest
steps:
- name: Check test matrix status
env:
RESULT: ${{needs.CherryPickGateTestMatrix.result}}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr edit --repo ${{github.repository}} \
--remove-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
${{env.PR_NUMBER}} || :
case $RESULT in
success)
gh pr edit --repo ${{github.repository}} \
--add-label ${{vars.CHERRY_PICK_GATES_PASSED_LABEL}} \
${{env.PR_NUMBER}} || :
echo "::notice::All Testsuite tests passed"
exit 0
;;
skipped)
echo "::error::Testsuite tests were skipped because of an earlier failure"
exit 1
;;
*)
gh pr edit --repo ${{github.repository}} \
--add-label ${{vars.CHERRY_PICK_GATES_FAILED_LABEL}} \
${{env.PR_NUMBER}} || :
echo "::error::One or more Testsuite tests failed ($RESULT)"
exit 1
esac

123
.github/workflows/CreateDocs.yml vendored Normal file
View File

@ -0,0 +1,123 @@
name: CreateDocs
on:
workflow_dispatch:
inputs:
branches:
description: "JSON array of branches: ['18','20'] (no spaces)"
required: false
type: string
schedule:
# Times are UTC
- cron: '0 04 * * *'
env:
ASTERISK_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BRANCHES: ${{ vars.WIKIDOC_BRANCHES }}
INPUT_BRANCHES: ${{ inputs.branches }}
jobs:
CreateDocsDebug:
runs-on: ubuntu-latest
outputs:
manual_branches: ${{ steps.setup.outputs.manual_branches }}
steps:
- name: setup
run: |
MANUAL_BRANCHES="$INPUT_BRANCHES"
[ -z "$MANUAL_BRANCHES" ] && MANUAL_BRANCHES="$DEFAULT_BRANCHES" || :
echo "manual_branches=${MANUAL_BRANCHES}"
echo "manual_branches=${MANUAL_BRANCHES}" >>${GITHUB_OUTPUT}
exit 0
- name: DumpEnvironment
uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
with:
action-inputs: ${{toJSON(inputs)}}
action-vars: ${{ toJSON(steps.setup.outputs) }}
CreateDocsScheduledMatrix:
needs: [ CreateDocsDebug ]
if: ${{github.event_name == 'schedule' && fromJSON(vars.WIKIDOCS_ENABLE) == true }}
continue-on-error: false
strategy:
fail-fast: false
matrix:
branch: ${{ fromJSON(vars.WIKIDOC_BRANCHES) }}
runs-on: ubuntu-latest
steps:
- name: CreateDocs for ${{matrix.branch}}
uses: asterisk/asterisk-ci-actions/CreateAsteriskDocsComposite@main
with:
asterisk_repo: ${{env.ASTERISK_REPO}}
base_branch: ${{matrix.branch}}
docs_dir: docs_dir/${{matrix.branch}}
github_token: ${{secrets.GITHUB_TOKEN}}
CreateDocsScheduled:
needs: [ CreateDocsScheduledMatrix ]
if: ${{ success() || failure() }}
runs-on: ubuntu-latest
steps:
- name: Check CreateDocsScheduledMatrix status
env:
RESULT: ${{needs.CreateDocsScheduledMatrix.result}}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
case $RESULT in
success)
echo "::notice::Docs created"
exit 0
;;
skipped)
echo "::notice::Skipped"
exit 1
;;
*)
echo "::error::One or CreateDocs failed ($RESULT)"
exit 1
esac
CreateDocsManualMatrix:
needs: [ CreateDocsDebug ]
if: ${{github.event_name == 'workflow_dispatch'}}
continue-on-error: false
strategy:
fail-fast: false
matrix:
branch: ${{ fromJSON(vars.WIKIDOC_MANUAL_BRANCHES) }}
runs-on: ubuntu-latest
steps:
- name: CreateDocs for ${{matrix.branch}}
uses: asterisk/asterisk-ci-actions/CreateAsteriskDocsComposite@main
with:
asterisk_repo: ${{env.ASTERISK_REPO}}
base_branch: ${{matrix.branch}}
docs_dir: docs_dir/${{matrix.branch}}
github_token: ${{secrets.GITHUB_TOKEN}}
CreateDocsManual:
needs: [ CreateDocsManualMatrix ]
if: ${{ success() || failure() }}
runs-on: ubuntu-latest
steps:
- name: Check CreateDocsManualMatrix status
env:
RESULT: ${{needs.CreateDocsManualMatrix.result}}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
case $RESULT in
success)
echo "::notice::Docs created"
exit 0
;;
skipped)
echo "::notice::Skipped"
exit 1
;;
*)
echo "::error::One or CreateDocs failed ($RESULT)"
exit 1
esac

15
.github/workflows/IssueOpened.yml vendored Normal file
View File

@ -0,0 +1,15 @@
name: Issue Opened
run-name: "Issue ${{github.event.number}} ${{github.event.action}} by ${{github.actor}}"
on:
issues:
types: opened
jobs:
triage:
runs-on: ubuntu-latest
steps:
- name: initial labeling
uses: andymckay/labeler@master
with:
add-labels: "triage"
ignore-if-labeled: true

187
.github/workflows/MergeApproved.yml vendored Normal file
View File

@ -0,0 +1,187 @@
name: MergeApproved
run-name: "Merge Approved for PR ${{github.event.number}}"
on:
pull_request_target:
types: [labeled]
env:
PR_NUMBER: ${{ github.event.number }}
BASE_BRANCH: ${{github.event.pull_request.base.ref}}
MODULES_BLACKLIST: ${{ vars.GATETEST_MODULES_BLACKLIST }} ${{ vars.UNITTEST_MODULES_BLACKLIST }}
FORCE: ${{ endsWith(github.event.label.name, '-force') }}
jobs:
IdentifyBranches:
if: contains(fromJSON(vars.MERGE_APPROVED_LABELS), github.event.label.name)
outputs:
branches: ${{ steps.getbranches.outputs.branches }}
all_branches: ${{ steps.checkbranches.outputs.all_branches }}
branch_count: ${{ steps.getbranches.outputs.branch_count }}
runs-on: ubuntu-latest
steps:
- name: Clean up labels
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr edit --repo ${{github.repository}} \
--remove-label ${{github.event.label.name}} \
--remove-label ${{vars.PRE_MERGE_CHECKS_PASSED_LABEL}} \
--remove-label ${{vars.PRE_MERGE_CHECKS_FAILED_LABEL}} \
--remove-label ${{vars.PRE_MERGE_GATES_PASSED_LABEL}} \
--remove-label ${{vars.PRE_MERGE_GATES_FAILED_LABEL}} \
--remove-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \
${{env.PR_NUMBER}} || :
- name: Get cherry-pick branches
uses: asterisk/asterisk-ci-actions/GetCherryPickBranchesFromPR@main
id: getbranches
with:
repo: ${{github.repository}}
pr_number: ${{env.PR_NUMBER}}
cherry_pick_regex: ${{vars.CHERRY_PICK_REGEX}}
github_token: ${{secrets.GITHUB_TOKEN}}
- name: Check Branch Count
id: checkbranches
env:
BRANCH_COUNT: ${{ steps.getbranches.outputs.branch_count }}
BRANCHES: ${{ steps.getbranches.outputs.branches }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr edit --repo ${{github.repository}} \
--add-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \
${{env.PR_NUMBER}} || :
all_branches=$(echo "$BRANCHES" | jq -c "[ \"$BASE_BRANCH\" ] + .")
echo "all_branches=${all_branches}" >>${GITHUB_OUTPUT}
- name: Pre Check Cherry-Picks
if: ${{ steps.getbranches.outputs.branch_count > 0 }}
uses: asterisk/asterisk-ci-actions/CherryPick@main
with:
repo: ${{github.repository}}
pr_number: ${{env.PR_NUMBER}}
branches: ${{steps.getbranches.outputs.branches}}
github_token: ${{secrets.GITHUB_TOKEN}}
push: false
PreMergeUnitTestMatrix:
needs: [ IdentifyBranches ]
if: success()
continue-on-error: false
strategy:
fail-fast: false
matrix:
branch: ${{ fromJSON(needs.IdentifyBranches.outputs.all_branches) }}
runs-on: ubuntu-latest
steps:
- name: Run Unit Tests for branch ${{matrix.branch}}
uses: asterisk/asterisk-ci-actions/AsteriskUnitComposite@main
with:
asterisk_repo: ${{github.repository}}
pr_number: ${{env.PR_NUMBER}}
base_branch: ${{matrix.branch}}
is_cherry_pick: true
modules_blacklist: ${{env.MODULES_BLACKLIST}}
github_token: ${{secrets.GITHUB_TOKEN}}
unittest_command: ${{vars.UNITTEST_COMMAND}}
PreMergeUnitTests:
needs: [ IdentifyBranches, PreMergeUnitTestMatrix ]
runs-on: ubuntu-latest
steps:
- name: Check unit test matrix status
env:
RESULT: ${{needs.PreMergeUnitTestMatrix.result}}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
case $RESULT in
success)
gh pr edit --repo ${{github.repository}} \
--remove-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \
--add-label ${{vars.PRE_MERGE_CHECKS_PASSED_LABEL}} \
${{env.PR_NUMBER}} || :
echo "::notice::All tests passed"
exit 0
;;
skipped)
gh pr edit --repo ${{github.repository}} \
--remove-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \
--add-label ${{vars.PRE_MERGE_CHECKS_FAILED_LABEL}} \
${{env.PR_NUMBER}} || :
echo "::notice::Unit tests were skipped because of an earlier failure"
exit 1
;;
*)
gh pr edit --repo ${{github.repository}} \
--remove-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \
--add-label ${{vars.PRE_MERGE_CHECKS_FAILED_LABEL}} \
${{env.PR_NUMBER}} || :
echo "::error::One or more tests failed ($RESULT)"
exit 1
esac
MergeAndCherryPick:
needs: [ IdentifyBranches, PreMergeUnitTests ]
if: success()
runs-on: ubuntu-latest
steps:
- name: Start Merge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr edit --repo ${{github.repository}} \
--add-label ${{vars.MERGE_IN_PROGRESS_LABEL}} \
${{env.PR_NUMBER}} || :
- name: Get Token needed to push cherry-picks
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v2
with:
application_id: ${{secrets.ASTERISK_ORG_ACCESS_APP_ID}}
application_private_key: ${{secrets.ASTERISK_ORG_ACCESS_APP_PRIV_KEY}}
organization: asterisk
- name: Merge and Cherry Pick to ${{needs.IdentifyBranches.outputs.branches}}
id: mergecp
uses: asterisk/asterisk-ci-actions/MergeAndCherryPickComposite@main
with:
repo: ${{github.repository}}
pr_number: ${{env.PR_NUMBER}}
branches: ${{needs.IdentifyBranches.outputs.branches}}
force: ${{env.FORCE}}
github_token: ${{steps.get_workflow_token.outputs.token}}
- name: Merge Cleanup
if: always()
env:
RESULT: ${{ steps.mergecp.outcome }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_COUNT: ${{ needs.IdentifyBranches.outputs.branch_count }}
BRANCHES: ${{ needs.IdentifyBranches.outputs.branches }}
run: |
case $RESULT in
success)
gh pr edit --repo ${{github.repository}} \
--remove-label ${{vars.MERGE_IN_PROGRESS_LABEL}} \
${{env.PR_NUMBER}} || :
if [ $BRANCH_COUNT -eq 0 ] ; then
gh pr comment --repo ${{github.repository}} \
-b "Successfully merged to branch $BASE_BRANCH." \
${{env.PR_NUMBER}} || :
else
gh pr comment --repo ${{github.repository}} \
-b "Successfully merged to branch $BASE_BRANCH and cherry-picked to $BRANCHES" \
${{env.PR_NUMBER}} || :
fi
exit 0
;;
failure)
gh pr edit --repo ${{github.repository}} \
--remove-label ${{vars.MERGE_IN_PROGRESS_LABEL}} \
--add-label ${{vars.MERGE_FAILED_LABEL}} \
${{env.PR_NUMBER}} || :
exit 1
;;
*)
esac

28
.github/workflows/NightlyAdmin.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: Nightly Admin
on:
schedule:
- cron: '30 1 * * *'
env:
ASTERISK_REPO: ${{ github.repository }}
PR_NUMBER: 0
PR_COMMIT: ''
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MODULES_BLACKLIST: ${{ vars.GATETEST_MODULES_BLACKLIST }} ${{ vars.UNITTEST_MODULES_BLACKLIST }}
jobs:
CloseStaleIssues:
runs-on: ubuntu-latest
steps:
- name: Close Stale Issues
uses: actions/stale@v7
with:
stale-issue-message: 'This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 14 days.'
stale-issue-label: stale
close-issue-message: 'This issue was closed because it has been stalled for 14 days with no activity.'
days-before-stale: 7
days-before-close: 14
days-before-pr-close: -1
only-labels: triage,feedback-required

59
.github/workflows/NightlyTests.yml vendored Normal file
View File

@ -0,0 +1,59 @@
name: NightlyTests
on:
workflow_dispatch:
schedule:
- cron: '0 2 * * *'
env:
ASTERISK_REPO: ${{ github.repository }}
PR_NUMBER: 0
PR_COMMIT: ''
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MODULES_BLACKLIST: ${{ vars.GATETEST_MODULES_BLACKLIST }}
jobs:
AsteriskNightly:
strategy:
fail-fast: false
matrix:
branch: ${{ fromJSON(vars.NIGHTLYTEST_BRANCHES) }}
group: ${{ fromJSON(vars.NIGHTLYTEST_LIST) }}
runs-on: ubuntu-latest
steps:
- name: Run Nightly Tests for ${{ matrix.group }}/${{ matrix.branch }}
uses: asterisk/asterisk-ci-actions/AsteriskGateComposite@main
with:
test_type: Nightly
asterisk_repo: ${{env.ASTERISK_REPO}}
pr_number: ${{env.PR_NUMBER}}
base_branch: ${{matrix.branch}}
modules_blacklist: ${{env.MODULES_BLACKLIST}}
github_token: ${{secrets.GITHUB_TOKEN}}
testsuite_repo: ${{vars.TESTSUITE_REPO}}
gatetest_group: ${{matrix.group}}
gatetest_command: ${{ toJSON(fromJSON(vars.GATETEST_COMMANDS)[matrix.group]) }}
AsteriskNightlyTests:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: AsteriskNightly
steps:
- name: Check test matrix status
env:
RESULT: ${{needs.AsteriskNightly.result}}
run: |
case $RESULT in
success)
echo "::notice::All Testsuite tests passed"
exit 0
;;
skipped)
echo "::error::Testsuite tests were skipped because of an earlier failure"
exit 1
;;
*)
echo "::error::One or more Testsuite tests failed"
exit 1
esac

32
.github/workflows/PRMerged.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: PRMerged
run-name: "PR ${{github.event.number || inputs.pr_number}} ${{github.event.action || 'MANUAL POST MERGE'}} by ${{ github.actor }}"
on:
pull_request_target:
types: [closed]
workflow_dispatch:
inputs:
pr_number:
description: 'PR number'
required: true
type: number
concurrency:
group: ${{github.workflow}}-${{github.event.number || inputs.pr_number}}
cancel-in-progress: true
env:
REPO: ${{github.repository}}
PR_NUMBER: ${{github.event.number || inputs.pr_number}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
jobs:
CloseIssues:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: wow-actions/auto-close-fixed-issues@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

149
.github/workflows/PRSubmitActions.yml vendored Normal file
View File

@ -0,0 +1,149 @@
name: PRSubmitActions
run-name: "PRSubmitActions: Test ${{github.event.action}}"
on:
workflow_run:
workflows: [PRSubmitTests]
types:
- requested
- completed
env:
ACTION: ${{ github.event.action }}
CONCLUSION: ${{ github.event.workflow_run.conclusion }}
REPO: ${{ github.repository }}
jobs:
PRSubmitActions:
runs-on: ubuntu-latest
steps:
- name: Get PR Number
id: getpr
uses: actions/github-script@v7
with:
retries: 5
script: |
let search = `repo:${context.repo.owner}/${context.repo.repo} ${context.payload.workflow_run.head_sha}`;
let prs = await github.rest.search.issuesAndPullRequests({
q: search,
});
if (prs.data.total_count == 0) {
core.setFailed(`Unable to get PR for ${context.payload.workflow_run.head_sha}`);
return;
}
let pr_number = prs.data.items[0].number;
core.setOutput('pr_number', pr_number);
return;
- name: Set Label
id: setlabel
uses: actions/github-script@v7
env:
PR_NUMBER: ${{ steps.getpr.outputs.PR_NUMBER }}
LABEL_TIP: ${{ vars.PR_SUBMIT_TESTING_IN_PROGRESS }}
LABEL_PASS: ${{ vars.PR_SUBMIT_TESTS_PASSED }}
LABEL_FAIL: ${{ vars.PR_SUBMIT_TESTS_FAILED }}
with:
retries: 5
script: |
let label;
if (process.env.ACTION === 'requested') {
label = process.env.LABEL_TIP;
} else {
if ( process.env.CONCLUSION === 'success' ) {
label = process.env.LABEL_PASS;
} else {
label = process.env.LABEL_FAIL;
}
}
core.info(`Setting label ${label}`);
github.rest.issues.setLabels({
issue_number: process.env.PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [ label ]
});
return;
- name: Get cherry-pick branches
if: github.event.action == 'completed'
id: getbranches
uses: asterisk/asterisk-ci-actions/GetCherryPickBranchesFromPR@main
with:
repo: ${{env.REPO}}
pr_number: ${{steps.getpr.outputs.PR_NUMBER}}
cherry_pick_regex: ${{vars.CHERRY_PICK_REGEX}}
github_token: ${{secrets.GITHUB_TOKEN}}
- name: Add cherry-pick reminder
if: github.event.action == 'completed'
uses: actions/github-script@v7
env:
PR_NUMBER: ${{steps.getpr.outputs.PR_NUMBER}}
CHERRY_PICK_REMINDER: ${{vars.CHERRY_PICK_REMINDER}}
BRANCHES_OUTPUT: ${{toJSON(steps.getbranches.outputs)}}
BRANCH_COUNT: ${{steps.getbranches.outputs.branch_count}}
FORCED_NONE: ${{steps.getbranches.outputs.forced_none}}
with:
retries: 5
script: |
if (process.env.FORCED_NONE === 'true' ||
process.env.BRANCH_COUNT > 0) {
core.info("No cherry-pick reminder needed.");
return;
}
let comments = await github.rest.issues.listComments({
issue_number: process.env.PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
});
let found = false;
for (const c of comments.data) {
if (c.body.startsWith("<!--CPR-->")) {
found = true;
break;
}
}
if (found) {
core.info("Cherry-pick reminder already exists.");
return;
}
core.info("Adding cherry-pick reminder.");
await github.rest.issues.createComment({
issue_number: process.env.PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.CHERRY_PICK_REMINDER
})
return;
- name: Add reviewers
if: github.event.action == 'completed'
uses: actions/github-script@v7
env:
PR_NUMBER: ${{steps.getpr.outputs.PR_NUMBER}}
REVIEWERS: ${{vars.PR_REVIEWERS}}
with:
retries: 5
github-token: ${{ secrets.ASTERISKTEAM_PAT }}
script: |
let rs = JSON.parse(process.env.REVIEWERS.length ? process.env.REVIEWERS : '[]');
let users = [];
let teams = [];
for (const r of rs) {
if (r.indexOf("/") > 0) {
teams.push(r.split('/')[1]);
} else {
users.push(r);
}
}
if (teams.length > 0 || users.length > 0) {
core.info(`Adding user reviewers ${users}`);
core.info(`Adding team reviewers ${teams}`);
await github.rest.pulls.requestReviewers({
pull_number: process.env.PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
reviewers: users,
team_reviewers: teams
});
}
return;

114
.github/workflows/PRSubmitTests.yml vendored Normal file
View File

@ -0,0 +1,114 @@
name: PRSubmitTests
run-name: "PR ${{github.event.number}} ${{github.event.action}} by ${{ github.actor }}"
on:
pull_request:
types: [opened, reopened, synchronize]
concurrency:
group: ${{github.workflow}}-${{github.event.number}}
cancel-in-progress: true
env:
ASTERISK_REPO: ${{github.repository}}
PR_NUMBER: ${{github.event.number}}
PR_COMMIT: ${{github.event.pull_request.head.sha}}
BRANCH: ${{github.event.pull_request.base.ref}}
jobs:
#
# Pull requests created from forked respositories don't have access to
# the "Action Variables" ('vars' context) so we need to retrieve control
# data from an action.
#
PRSGetControlData:
runs-on: ubuntu-latest
outputs:
control_data: ${{ steps.setvars.outputs.control_data }}
steps:
- id: setvars
uses: asterisk/asterisk-ci-actions/GetRepoControlData@main
with:
repo: ${{ github.event.repository.name}}
- name: DumpEnvironment
uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
with:
action-inputs: ${{toJSON(inputs)}}
action-vars: ${{ toJSON(steps.setvars.outputs) }}
PRSUnitTests:
needs: PRSGetControlData
runs-on: ubuntu-latest
env:
UNITTEST_COMMAND: ${{ fromJSON(needs.PRSGetControlData.outputs.control_data).UNITTEST_COMMAND }}
steps:
- name: Run Unit Tests
uses: asterisk/asterisk-ci-actions/AsteriskUnitComposite@main
with:
asterisk_repo: ${{env.ASTERISK_REPO}}
pr_number: ${{env.PR_NUMBER}}
base_branch: ${{env.BRANCH}}
unittest_command: ${{env.UNITTEST_COMMAND}}
PRSGateTestMatrix:
runs-on: ubuntu-latest
needs: PRSGetControlData
continue-on-error: false
strategy:
fail-fast: false
matrix:
group: ${{ fromJSON(fromJSON(needs.PRSGetControlData.outputs.control_data).GATETEST_LIST) }}
env:
TESTSUITE_REPO: "${{ fromJSON(needs.PRSGetControlData.outputs.control_data).TESTSUITE_REPO }}"
GATETEST_COMMANDS: "${{ fromJSON(needs.PRSGetControlData.outputs.control_data).GATETEST_COMMANDS }}"
GATETEST_COMMAND: "${{ toJSON(fromJSON(fromJSON(needs.PRSGetControlData.outputs.control_data).GATETEST_COMMANDS)[matrix.group]) }}"
steps:
- id: runtest
name: Run Gate Tests for ${{ matrix.group }}
uses: asterisk/asterisk-ci-actions/AsteriskGateComposite@main
with:
test_type: Gate
asterisk_repo: ${{env.ASTERISK_REPO}}
pr_number: ${{env.PR_NUMBER}}
base_branch: ${{env.BRANCH}}
testsuite_repo: ${{env.TESTSUITE_REPO}}
gatetest_group: ${{matrix.group}}
gatetest_command: ${{env.GATETEST_COMMAND}}
PRSTestResults:
if: always()
runs-on: ubuntu-latest
needs: [PRSUnitTests,PRSGateTestMatrix]
steps:
- name: Check test matrix status
env:
RESULT_UNIT: ${{ needs.PRSUnitTests.result }}
RESULT_GATE: ${{ needs.PRSGateTestMatrix.result }}
run: |
declare -i rc=0
echo "all results: ${{ toJSON(needs.*.result) }}"
case $RESULT_UNIT in
success)
echo "::notice::Unit tests passed"
;;
skipped)
echo "::error::Unit tests were skipped because of an earlier failure"
rc+=1
;;
*)
echo "::error::One or more unit tests failed ($RESULT_UNIT)"
rc+=1
esac
case $RESULT_GATE in
success)
echo "::notice::Gate tests passed"
;;
skipped)
echo "::error::Gate tests were skipped because of an earlier failure"
rc+=1
;;
*)
echo "::error::One or more gate tests failed ($RESULT_GATE)"
rc+=1
esac
echo "::notice::Final result code: $rc"
exit $rc

99
.github/workflows/Releaser.yml vendored Normal file
View File

@ -0,0 +1,99 @@
name: Releaser
run-name: ${{ github.actor }} is creating ${{vars.PRODUCT_NAME}} release ${{inputs.new_version}}
on:
workflow_dispatch:
inputs:
new_version:
description: |
New Version:
Examples:
20.4.0-rc1, 20.4.0-rc2, 20.4.0, 20.4.1
certified-20.4-cert1-rc1, certified-20.4-cert1
required: true
type: string
is_security:
description: |
Security?
(No prev RCs)
required: true
type: boolean
default: false
advisories:
description: |
Comma separated list of advisories.
NO SPACES
Example: GHSA-4xjp-22g4-9fxm,GHSA-4xjp-22g4-zzzz
required: false
type: string
is_hotfix:
description: |
Hotfix?
(A patch release but not security. No prev RCs)
required: true
type: boolean
default: false
force_cherry_pick:
description: |
Force cherry-pick for non-RC1 releases? USE WITH CAUTION!
required: true
type: boolean
default: false
push_release_branches:
description: |
Push release branches live?
required: true
type: boolean
default: false
create_github_release:
description: |
Create the GitHub release?
required: true
type: boolean
default: false
push_tarballs:
description: |
Push tarballs to downloads server?
required: true
type: boolean
default: false
send_email:
description: |
Send announcement emails?
required: true
type: boolean
default: false
jobs:
ReleaseAsterisk:
runs-on: ubuntu-latest
steps:
- name: Run Releaser
uses: asterisk/asterisk-ci-actions/ReleaserComposite@main
with:
product: ${{vars.PRODUCT_NAME}}
is_security: ${{inputs.is_security}}
advisories: ${{inputs.advisories}}
is_hotfix: ${{inputs.is_hotfix}}
new_version: ${{inputs.new_version}}
force_cherry_pick: ${{inputs.force_cherry_pick}}
push_release_branches: ${{inputs.push_release_branches}}
create_github_release: ${{inputs.create_github_release}}
push_tarballs: ${{inputs.push_tarballs}}
send_email: ${{inputs.send_email}}
repo: ${{github.repository}}
mail_list_ga: ${{vars.MAIL_LIST_GA}}
mail_list_rc: ${{vars.MAIL_LIST_RC}}
mail_list_cert_ga: ${{vars.MAIL_LIST_CERT_GA}}
mail_list_cert_rc: ${{vars.MAIL_LIST_CERT_RC}}
mail_list_sec: ${{vars.MAIL_LIST_SEC_ADV}}
sec_adv_url_base: ${{vars.SEC_ADV_URL_BASE}}
gpg_private_key: ${{secrets.ASTDEV_GPG_PRIV_KEY}}
github_token: ${{secrets.GITHUB_TOKEN}}
application_id: ${{secrets.ASTERISK_ORG_ACCESS_APP_ID}}
application_private_key: ${{secrets.ASTERISK_ORG_ACCESS_APP_PRIV_KEY}}
asteriskteamsa_username: ${{secrets.ASTERISKTEAMSA_GMAIL_ACCT}}
asteriskteamsa_token: ${{secrets.ASTERISKTEAMSA_GMAIL_TOKEN}}
deploy_ssh_priv_key: ${{secrets.DOWNLOADS_DEPLOY_SSH_PRIV_KEY}}
deploy_ssh_username: ${{secrets.DOWNLOADS_DEPLOY_SSH_USERNAME}}
deploy_host: ${{vars.DEPLOY_HOST}}
deploy_dir: ${{vars.DEPLOY_DIR}}

View File

@ -1,10 +0,0 @@
[gerrit]
defaultbranch=master
#
# Intentional padding to ensure it is possible to point a commit
# to an alternative gerrit server/repository without breaking
# cherry-pick between branches.
#
host=gerrit.asterisk.org
port=29418
project=asterisk.git

10
BUGS
View File

@ -1,22 +1,22 @@
Asterisk Bug Tracking Information
=================================
To learn about and report Asterisk bugs, please visit
To learn about and report Asterisk bugs, please visit
the official Asterisk Bug Tracker at:
https://issues.asterisk.org/jira
https://github.com/asterisk/asterisk/issues/
For more information on using the bug tracker, or to
For more information on using the bug tracker, or to
learn how you can contribute by acting as a bug marshal
please see:
http://www.asterisk.org/developers/bug-guidelines
https://wiki.asterisk.org/wiki/x/RgAtAQ
If you would like to submit a feature request, please
resist the temptation to post it to the bug tracker.
Feature requests should be posted to the asterisk-dev
mailing list, located at:
http://lists.digium.com
http://lists.digium.com
Thank you!

7191
CHANGES

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,7 @@
rewrite of SIP transfers
=== WISHLIST CONTRIBUTERS ===
=== WISHLIST CONTRIBUTORS ===
We'd like to thank the following for contributing to our wishlist

159890
ChangeLog Normal file

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@
# on a single object just for that object
# SOLINK - linker flags used only for creating dynamically loadable modules
# as .so files
# DYLINK - linker flags used only for creating shared libaries
# DYLINK - linker flags used only for creating shared libraries
# (.so files on Unix-type platforms, .dylib on Darwin)
#
# Values for ASTCFLAGS and ASTLDFLAGS can be specified in the
@ -49,6 +49,7 @@ DESTDIR?=$(INSTALL_PATH)
export DESTDIR
export INSTALL_PATH # Additional prefix for the following paths
export ASTCACHEDIR
export ASTETCDIR # Path for config files
export ASTVARRUNDIR
export ASTSPOOLDIR
@ -134,7 +135,7 @@ empty:=
space:=$(empty) $(empty)
ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
# Overwite config files on "make samples" or other config installation targets
# Overwrite config files on "make samples" or other config installation targets
OVERWRITE=y
# Include debug and macro symbols in the executables (-g) and profiling info (-pg)
@ -249,7 +250,7 @@ else
endif
ifneq ($(AWK),)
ifneq ($(wildcard .version),)
ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
ASTERISKVERSIONNUM:=$(shell $(SED) -e 's/^certified\///' -e 's/-cert/./' .version | $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}')
endif
endif
@ -368,7 +369,7 @@ $(MOD_SUBDIRS_MENUSELECT_TREE):
+@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
+@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
$(SUBDIRS): makeopts .lastclean main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h
$(SUBDIRS): makeopts .lastclean main/version.c include/asterisk/build.h defaults.h
ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
main: third-party
@ -394,7 +395,7 @@ defaults.h: makeopts .lastclean build_tools/make_defaults_h
@cmp -s $@.tmp $@ || mv $@.tmp $@
@rm -f $@.tmp
main/version.c: FORCE menuselect.makeopts .lastclean
main/version.c: FORCE include/asterisk/buildopts.h menuselect.makeopts .lastclean
@build_tools/make_version_c > $@.tmp
@cmp -s $@.tmp $@ || mv $@.tmp $@
@rm -f $@.tmp
@ -474,53 +475,24 @@ endif
$(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/rest-api" ; \
done
ifeq ($(GREP),)
else ifeq ($(GREP),:)
else
XML_core_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
endif
DOC_MOD_SUBDIRS := $(filter-out third-party,$(MOD_SUBDIRS))
XML_core_en_US := $(shell build_tools/make_xml_documentation --command=print_dependencies --source-tree=. --mod-subdirs="$(DOC_MOD_SUBDIRS)")
# core-en_US.xml is the normal documentation created with asterisk builds.
doc/core-en_US.xml: makeopts .lastclean $(XML_core_en_US)
@printf "Building Documentation For: "
@echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
@echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
@echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" >> $@
@echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
@for x in $(MOD_SUBDIRS); do \
printf "$$x " ; \
for i in `find $$x -name '*.c'`; do \
$(AWK) -f build_tools/get_documentation $$i >> $@ ; \
done ; \
done
@echo
@echo "</docs>" >> $@
@build_tools/make_xml_documentation --command=create_xml --source-tree=. --mod-subdirs="$(DOC_MOD_SUBDIRS)" \
--with-moduleinfo --validate --output-file=$@
ifeq ($(GREP),)
else ifeq ($(GREP),:)
else
XML_full_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
endif
doc/full-en_US.xml: makeopts .lastclean $(XML_full_en_US)
# The full-en_US.xml target is only called by the wiki documentation generation process
# and does special post-processing in preparation for uploading to the wiki.
# It creates full-en_US.xml but then re-creates core-en_US.xml as well.
doc/full-en_US.xml: makeopts .lastclean $(XML_core_en_US)
ifeq ($(PYTHON),:)
@echo "--------------------------------------------------------------------------"
@echo "--- Please install python to build full documentation ---"
@echo "--------------------------------------------------------------------------"
else
@printf "Building Documentation For: "
@echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
@echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
@echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" >> $@
@echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
@for x in $(filter-out third-party,$(MOD_SUBDIRS)); do \
printf "$$x " ; \
for i in `find $$x -name '*.c'`; do \
$(PYTHON) build_tools/get_documentation.py < $$i >> $@ ; \
done ; \
done
@echo
@echo "</docs>" >> $@
@$(PYTHON) build_tools/post_process_documentation.py -i $@ -o "doc/core-en_US.xml"
@build_tools/make_xml_documentation --command=create_xml --source-tree=. --mod-subdirs="$(DOC_MOD_SUBDIRS)" \
--for-wiki --validate --output-file=$@ --core-output-file=./doc/core-en_US.xml
endif
validate-docs: doc/core-en_US.xml
@ -555,7 +527,7 @@ update:
NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
OLDHEADERS=$(filter-out $(NEWHEADERS) $(notdir $(DESTDIR)$(ASTHEADERDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \
INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTCACHEDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \
"$(ASTSPOOLDIR)" "$(ASTSPOOLDIR)/dictate" "$(ASTSPOOLDIR)/meetme" \
"$(ASTSPOOLDIR)/monitor" "$(ASTSPOOLDIR)/system" "$(ASTSPOOLDIR)/tmp" \
"$(ASTSPOOLDIR)/voicemail" "$(ASTSPOOLDIR)/recording" \
@ -779,7 +751,8 @@ define INSTALL_CONFIGS
done ; \
if [ "$(OVERWRITE)" = "y" ]; then \
echo "Updating asterisk.conf" ; \
sed -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
sed -e 's|^astcachedir.*$$|astcachedir => $(ASTCACHEDIR)|' \
-e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
-e 's|^astmoddir.*$$|astmoddir => $(ASTMODDIR)|' \
-e 's|^astvarlibdir.*$$|astvarlibdir => $(ASTVARLIBDIR)|' \
-e 's|^astdbdir.*$$|astdbdir => $(ASTDBDIR)|' \
@ -1119,7 +1092,8 @@ ifeq ($(PYTHON),:)
else
@$(INSTALL) -d doc/rest-api
$(PYTHON) rest-api-templates/make_ari_stubs.py \
rest-api/resources.json .
--resources rest-api/resources.json --source-dir $(ASTTOPDIR) \
--dest-dir $(ASTTOPDIR)/doc/rest-api --docs-prefix ../
endif
check-alembic: makeopts

View File

@ -204,4 +204,19 @@ endif
$(ECHO_PREFIX) echo " [LD] $^ -> $@"
$(CMD_PREFIX) $(CXX) -o $@ $(PTHREAD_CFLAGS) $(_ASTLDFLAGS) $^ $(CXX_LIBS) $(ASTLDFLAGS)
# These CC commands just create an object file with the input file embedded in it.
# It can be access from code as follows:
# If your input file is named abc_def.xml...
#
# extern const uint8_t _binary_abc_def_xml_start[];
# extern const uint8_t _binary_abc_def_xml_end[];
# extern const size_t _binary_abc_def_xml_size;
%.o: %.xml
$(ECHO_PREFIX) echo " [LD] $^ -> $@"
$(CMD_PREFIX) $(CC) -g -Wl,-znoexecstack -nostartfiles -nodefaultlibs -nostdlib -r -Wl,-b,binary -o $@ $^
%.o: %.xslt
$(ECHO_PREFIX) echo " [LD] $^ -> $@"
$(CMD_PREFIX) $(CC) -g -Wl,-znoexecstack -nostartfiles -nodefaultlibs -nostdlib -r -Wl,-b,binary -o $@ $^
dist-clean:: clean

View File

@ -1,7 +1,7 @@
# The Asterisk(R) Open Source PBX
```text
By Mark Spencer <markster@digium.com> and the Asterisk.org developer community.
Copyright (C) 2001-2019 Digium, Inc. and other copyright holders.
Copyright (C) 2001-2021 Sangoma Technologies Corporation and other copyright holders.
```
## SECURITY
@ -47,7 +47,7 @@ and the BSD variants.
ANY special hardware, not even a sound card) to install and run Asterisk.
Supported telephony hardware includes:
* All Analog and Digital Interface cards from [Digium]
* All Analog and Digital Interface cards from [Sangoma]
* QuickNet Internet PhoneJack and LineJack (http://www.quicknet.net)
* any full duplex sound card supported by ALSA, OSS, or PortAudio
* any ISDN card supported by mISDN on Linux
@ -251,7 +251,7 @@ Welcome to the growing worldwide community of Asterisk users!
---
Asterisk is a trademark of Digium, Inc.
Asterisk is a trademark of Sangoma Technologies Corporation
[home page]: https://www.asterisk.org
[support]: https://www.asterisk.org/support
@ -261,7 +261,7 @@ Asterisk is a trademark of Digium, Inc.
[voip-info.org]: http://www.voip-info.org/wiki-Asterisk
[asteriskdocs.org]: http://www.asteriskdocs.org
[NTP]: http://www.ntp.org/
[Digium]: https://www.digium.com/
[Sangoma]: https://www.sangoma.com/
[UPGRADE.txt]: UPGRADE.txt
[CHANGES]: CHANGES
[configs]: configs

9
SECURITY.md Normal file
View File

@ -0,0 +1,9 @@
# Security Policy
## Supported Versions
The Asterisk project maintains a [documentation page](https://docs.asterisk.org/About-the-Project/Asterisk-Versions/) of releases. Each version is listed with its release date, security fix only date, and end of life date. Consult this wiki page to see if the version of Asterisk you are reporting a security vulnerability against is still supported.
## Reporting a Vulnerability
To report a vulnerability use the "Report a vulnerability" button under the "Security" tab of this project.

File diff suppressed because it is too large Load Diff

View File

@ -64,6 +64,10 @@ chan_ooh323.so: _ASTCFLAGS+=$(H323CFLAGS)
$(call MOD_ADD_C,chan_ooh323,$(H323SOURCE))
ifneq ($(wildcard mp3/Makefile),)
# At the current time, the fate of mp3 is in flux so it didn't make sense to
# add configure/makeopts processing for array-bounds since this is the only
# source file that needs that warning suppressed.
mp3/layer3.o: _ASTCFLAGS+=-Wno-array-bounds
$(call MOD_ADD_C,format_mp3,mp3/common.c mp3/dct64_i386.c mp3/decode_ntom.c mp3/layer3.c mp3/tabinit.c mp3/interface.c)
.PHONY: check_mp3

View File

@ -37,6 +37,8 @@
<defaultenabled>no</defaultenabled>
<support_level>deprecated</support_level>
<replacement>func_odbc</replacement>
<deprecated_in>1.8</deprecated_in>
<removed_in>19</removed_in>
***/
#include "asterisk.h"

View File

@ -38,6 +38,8 @@
<defaultenabled>no</defaultenabled>
<support_level>deprecated</support_level>
<replacement>cdr_adaptive_odbc</replacement>
<deprecated_in>1.8</deprecated_in>
<removed_in>19</removed_in>
***/
#include "asterisk.h"

View File

@ -102,7 +102,7 @@ struct adapter_pvt {
char id[31]; /* the 'name' from mobile.conf */
bdaddr_t addr; /* adddress of adapter */
unsigned int inuse:1; /* are we in use ? */
unsigned int alignment_detection:1; /* do alignment detection on this adpater? */
unsigned int alignment_detection:1; /* do alignment detection on this adapter? */
struct io_context *io; /*!< io context for audio connections */
struct io_context *accept_io; /*!< io context for sco listener */
int *sco_id; /*!< the io context id of the sco listener socket */
@ -2006,7 +2006,7 @@ static int at_match_prefix(char *buf, char *prefix)
}
/*!
* \brief Read an AT message and clasify it.
* \brief Read an AT message and classify it.
* \param rsock an rfcomm socket
* \param buf the buffer to store the result in
* \param count the size of the buffer or the maximum number of characters to read
@ -2156,10 +2156,12 @@ static inline const char *at_msg2str(at_message_t msg)
* \param buf the buffer to parse (null terminated)
* \return -1 on error (parse error) or a ECAM value on success
*
* Example string: *ECAV: <ccid>,<ccstatus>,<calltype>[,<processid>]
* [,exitcause][,<number>,<type>]
* Example:
* \verbatim *ECAV: <ccid>,<ccstatus>,<calltype>[,<processid>]
[,exitcause][,<number>,<type>] \endverbatim
*
* Example indicating busy: *ECAV: 1,7,1
* Example indicating busy:
* \verbatim *ECAV: 1,7,1 \endverbatim
*/
static int hfp_parse_ecav(struct hfp_pvt *hfp, char *buf)
{
@ -2176,7 +2178,7 @@ static int hfp_parse_ecav(struct hfp_pvt *hfp, char *buf)
}
/*!
* \brief Enable Sony Erricson extensions / indications.
* \brief Enable Sony Ericsson extensions / indications.
* \param hfp an hfp_pvt struct
*/
static int hfp_send_ecam(struct hfp_pvt *hfp)
@ -3040,7 +3042,7 @@ static void msg_queue_free_and_pop(struct mbl_pvt *pvt)
}
/*!
* \brief Remove all itmes from the queue and free them.
* \brief Remove all items from the queue and free them.
* \param pvt a mbl_pvt structure
*/
static void msg_queue_flush(struct mbl_pvt *pvt)
@ -3347,7 +3349,7 @@ static int handle_response_ok(struct mbl_pvt *pvt, char *buf)
}
break;
case AT_CLIP:
ast_debug(1, "[%s] caling line indication enabled\n", pvt->id);
ast_debug(1, "[%s] calling line indication enabled\n", pvt->id);
if (hfp_send_ecam(pvt->hfp) || msg_queue_push(pvt, AT_OK, AT_ECAM)) {
ast_debug(1, "[%s] error enabling Sony Ericsson call monitoring extensions\n", pvt->id);
goto e_return;
@ -3567,7 +3569,7 @@ static int handle_response_ciev(struct mbl_pvt *pvt, char *buf)
if (pvt->owner) {
ast_debug(1, "[%s] hanging up owner\n", pvt->id);
if (mbl_queue_hangup(pvt)) {
ast_log(LOG_ERROR, "[%s] error queueing hangup, disconnectiong...\n", pvt->id);
ast_log(LOG_ERROR, "[%s] error queueing hangup, disconnecting...\n", pvt->id);
return -1;
}
}
@ -3601,7 +3603,7 @@ static int handle_response_ciev(struct mbl_pvt *pvt, char *buf)
handle_response_busy(pvt);
}
if (mbl_queue_hangup(pvt)) {
ast_log(LOG_ERROR, "[%s] error queueing hangup, disconnectiong...\n", pvt->id);
ast_log(LOG_ERROR, "[%s] error queueing hangup, disconnecting...\n", pvt->id);
return -1;
}
}
@ -4431,7 +4433,7 @@ static struct adapter_pvt *mbl_load_adapter(struct ast_config *cfg, const char *
/* bind the sco listener socket */
if (sco_bind(adapter) < 0) {
ast_log(LOG_ERROR, "Skipping adapter %s. Error binding audio connection listerner socket.\n", adapter->id);
ast_log(LOG_ERROR, "Skipping adapter %s. Error binding audio connection listener socket.\n", adapter->id);
goto e_destroy_io;
}
@ -4443,7 +4445,7 @@ static struct adapter_pvt *mbl_load_adapter(struct ast_config *cfg, const char *
/* start the sco listener for this adapter */
if (ast_pthread_create_background(&adapter->sco_listener_thread, NULL, do_sco_listen, adapter)) {
ast_log(LOG_ERROR, "Skipping adapter %s. Error creating audio connection listerner thread.\n", adapter->id);
ast_log(LOG_ERROR, "Skipping adapter %s. Error creating audio connection listener thread.\n", adapter->id);
goto e_remove_sco;
}
@ -4499,7 +4501,7 @@ static struct mbl_pvt *mbl_load_device(struct ast_config *cfg, const char *cat)
}
AST_RWLIST_UNLOCK(&adapters);
if (!adapter) {
ast_log(LOG_ERROR, "Skiping device %s. Unknown adapter '%s' specified.\n", cat, adapter_str);
ast_log(LOG_ERROR, "Skipping device %s. Unknown adapter '%s' specified.\n", cat, adapter_str);
goto e_return;
}

View File

@ -2055,7 +2055,7 @@ int onOutgoingCall(ooCallData *call)
}
ooCallAddAliasDialedDigits(call, p->caller_dialedDigits);
} else if (!ast_strlen_zero(p->callerid_num)) {
if (ooIsDailedDigit(p->callerid_num)) {
if (ooIsDialedDigit(p->callerid_num)) {
if (gH323Debug) {
ast_verb(0, "setting callid number %s\n", p->callerid_num);
}
@ -2136,7 +2136,7 @@ int onNewCallCreated(ooCallData *call)
}
ooCallAddAliasDialedDigits(call, p->caller_dialedDigits);
} else if (!ast_strlen_zero(p->callerid_num)) {
if (ooIsDailedDigit(p->callerid_num)) {
if (ooIsDialedDigit(p->callerid_num)) {
if (gH323Debug) {
ast_verb(0, "setting callid number %s\n", p->callerid_num);
}
@ -2148,7 +2148,7 @@ int onNewCallCreated(ooCallData *call)
if (!ast_strlen_zero(p->exten)) {
if (ooIsDailedDigit(p->exten)) {
if (ooIsDialedDigit(p->exten)) {
ooCallSetCalledPartyNumber(call, p->exten);
ooCallAddRemoteAliasDialedDigits(call, p->exten);
} else {

View File

@ -75,7 +75,7 @@ To run the stack test application chansetup
3. For running calling instance
./h323peer [--use-ip ip] -n <number of calls> -duration <call duration>
-interval <inetrval between successive calls> destination
-interval <interval between successive calls> destination
where all times are in seconds. Interval of 0 means next call will be placed
after current call finishes. "destination" is the dotted ip address of the

View File

@ -417,7 +417,7 @@ int decodeDynBitString (OOCTXT* pctxt, ASN1DynBitStr* pBitStr)
ASN1OCTET* ptmp;
int nbits, stat = ASN_OK;
/* If "fast copy" option is not set (ASN1FATSCOPY) or if constructed,
/* If "fast copy" option is not set (ASN1FASTCOPY) or if constructed,
* copy the bit string value into a dynamic memory buffer;
* otherwise, store the pointer to the value in the decode
* buffer in the data pointer argument. */

View File

@ -1007,7 +1007,7 @@ int encode2sCompBinInt (OOCTXT* pctxt, ASN1INT value)
{
/* 10.4.6 A minimum octet 2's-complement-binary-integer encoding */
/* of the whole number has a field width that is a multiple of 8 */
/* bits and also satisifies the condition that the leading 9 bits */
/* bits and also satisfies the condition that the leading 9 bits */
/* field shall not be all zeros and shall not be all ones. */
/* first encode integer value into a local buffer */
@ -1048,7 +1048,7 @@ static int encodeNonNegBinInt (OOCTXT* pctxt, ASN1UINT value)
/* 10.3.6 A minimum octet non-negative binary integer encoding of */
/* the whole number (which does not predetermine the number of */
/* octets to be used for the encoding) has a field which is a */
/* multiple of 8 bits and also satisifies the condition that the */
/* multiple of 8 bits and also satisfies the condition that the */
/* leading eight bits of the field shall not be zero unless the */
/* field is precisely 8 bits long. */

View File

@ -49,7 +49,7 @@ extern "C" {
* SEQUENCE OF, SET OF, or CHOICE construct is parsed.
*
* @param name For SEQUENCE, SET, or CHOICE, this is the name of the
* element as defined in the ASN.1 defination. For
* element as defined in the ASN.1 definition. For
* SEQUENCE OF or SET OF, this is set to the name
* "element".
* @param index For SEQUENCE, SET, or CHOICE, this is not used and is
@ -68,7 +68,7 @@ typedef void (*StartElement) (const char* name, int index) ;
* SEQUENCE, SET, SEQUENCE OF, SET OF, or CHOICE construct.
*
* @param name For SEQUENCE, SET, or CHOICE, this is the name of the
* element as defined in the ASN.1 defination. For
* element as defined in the ASN.1 definition. For
* SEQUENCE OF or SET OF, this is set to the name
* "element".
* @param index For SEQUENCE, SET, or CHOICE, this is not used and is
@ -194,7 +194,7 @@ typedef void (*EnumValue) (ASN1UINT value) ;
* within a decode function when an ASN.1 open type is parsed.
*
* @param numocts Number of octets in the parsed value.
* @param data Pointer to byet array contain in tencoded ASN.1
* @param data Pointer to byte array contain in tencoded ASN.1
* value.
* @return - none
*/

View File

@ -1926,7 +1926,7 @@ typedef struct EXTERN H225SecurityCapabilities {
} m;
H225NonStandardParameter nonStandard;
H225SecurityServiceMode encryption;
H225SecurityServiceMode authenticaton;
H225SecurityServiceMode authentication;
H225SecurityServiceMode integrity;
} H225SecurityCapabilities;

View File

@ -6357,14 +6357,14 @@ EXTERN int asn1PD_H225SecurityCapabilities (OOCTXT* pctxt, H225SecurityCapabilit
invokeEndElement (pctxt, "encryption", -1);
/* decode authenticaton */
/* decode authentication */
invokeStartElement (pctxt, "authenticaton", -1);
invokeStartElement (pctxt, "authentication", -1);
stat = asn1PD_H225SecurityServiceMode (pctxt, &pvalue->authenticaton);
stat = asn1PD_H225SecurityServiceMode (pctxt, &pvalue->authentication);
if (stat != ASN_OK) return stat;
invokeEndElement (pctxt, "authenticaton", -1);
invokeEndElement (pctxt, "authentication", -1);
/* decode integrity */

View File

@ -4408,9 +4408,9 @@ EXTERN int asn1PE_H225SecurityCapabilities (OOCTXT* pctxt, H225SecurityCapabilit
stat = asn1PE_H225SecurityServiceMode (pctxt, &pvalue->encryption);
if (stat != ASN_OK) return stat;
/* encode authenticaton */
/* encode authentication */
stat = asn1PE_H225SecurityServiceMode (pctxt, &pvalue->authenticaton);
stat = asn1PE_H225SecurityServiceMode (pctxt, &pvalue->authentication);
if (stat != ASN_OK) return stat;
/* encode integrity */

View File

@ -265,7 +265,7 @@ void* memHeapAlloc (void** ppvMemHeap, int nbytes)
if (nunits <= (ASN1UINT)pElem_nunits (pElem)) {
RTMEMDIAG3
("memHeapAlloc: "
"found an exisiting free element 0x%x, size %d\n",
"found an existing free element 0x%x, size %d\n",
pElem, (pElem_nunits (pElem) * 8u));
if (pMemBlk->freeElemOff ==
@ -373,7 +373,7 @@ void* memHeapAlloc (void** ppvMemHeap, int nbytes)
CHECKMEMBLOCK (pMemHeap, pMemBlk);
}
else {
ast_mutex_unlock(&pMemHeap->pLock);
ast_mutex_unlock(&pMemHeap->pLock);
return NULL;
}
}
@ -753,9 +753,10 @@ void* memHeapRealloc (void** ppvMemHeap, void* mem_p, int nbytes_)
if (newMemBlk == 0)
return 0;
pMemLink->pMemBlk = newMemBlk;
}
else
}
else {
return 0;
}
*(int*)(((char*)pMemLink) + sizeof (OSMemLink)) = nbytes_;
return pMemLink->pMemBlk;
}
@ -1132,7 +1133,7 @@ void* memHeapMarkSaved (void** ppvMemHeap, const void* mem_p,
RTMEMDIAG2 ("memHeapMarkSaved: the element 0x%x is "
"already free!\n", pElem);
ast_mutex_unlock(&pMemHeap->pLock);
ast_mutex_unlock(&pMemHeap->pLock);
return 0;
}
@ -1151,9 +1152,10 @@ void* memHeapMarkSaved (void** ppvMemHeap, const void* mem_p,
CLEAR_SAVED (pMemBlk, pElem);
nsaved = pMemBlk->nsaved;
}
else
ast_mutex_unlock(&pMemHeap->pLock);
return 0;
else {
ast_mutex_unlock(&pMemHeap->pLock);
}
return 0;
}
if (saved && nsaved > 0)
pMemLink->blockType |= RTMEMSAVED;
@ -1212,7 +1214,7 @@ static OSMemLink* memHeapAddBlock (OSMemLink** ppMemLink,
/* if pMemBlk has RTMEMLINK flags it means that it is allocated
* cooperatively with OSMemLink, and we don't need to do additional
* allocations for it. Just use pointer's arithemtic. */
* allocations for it. Just use pointer's arithmetic. */
if (blockType & RTMEMLINK)
pMemLink = (OSMemLink*) (((ASN1OCTET*)pMemBlk) - sizeof (OSMemLink));

View File

@ -783,7 +783,7 @@ OOH323CallData* ooFindCallByToken(const char *callToken)
/* Checks whether session with suplied ID and direction is already active*/
/* Checks whether session with supplied ID and direction is already active*/
ASN1BOOL ooIsSessionEstablished(OOH323CallData *call, int sessionID, char* dir)
{
OOLogicalChannel * temp = NULL;

View File

@ -294,7 +294,7 @@ EXTERN int ooCapabilityDisableDTMFQ931Keypad(struct OOH323CallData *call);
* and txframes parameters to the endpoint or call.(ex. G711, G728, G723.1,
* G729)
* @param call Handle to a call. If this is not Null, then
* capability is added to call's remote enpoint
* capability is added to call's remote endpoint
* capability list, else it is added to local H323
* endpoint list.
* @param cap Type of G711 capability to be added.
@ -326,7 +326,7 @@ EXTERN int ooCapabilityAddSimpleCapability
* to local endpoints capability list or to remote endpoints capability list or
* to a call's capability list.
* @param call Handle to a call. If this is not Null, then
* capability is added to call's remote enpoint
* capability is added to call's remote endpoint
* capability list, else it is added to local H323
* endpoint list.
* @param cap Type of GSM capability to be added.
@ -357,7 +357,7 @@ int ooCapabilityAddGSMCapability(struct OOH323CallData *call, int cap,
* capability list or to remote endpoints capability list or to a call's
* capability list.
* @param call Handle to a call. If this is not Null, then
* capability is added to call's remote enpoint
* capability is added to call's remote endpoint
* capability list, else it is added to local H323
* endpoint list.
* @param sqcifMPI Minimum picture interval for encoding/decoding
@ -396,7 +396,7 @@ EXTERN int ooCapabilityAddH263VideoCapability(struct OOH323CallData *call,
/**
* This function is an helper function to ooCapabilityAddH263VideoCapability.
* @param call Handle to a call. If this is not Null, then
* capability is added to call's remote enpoint
* capability is added to call's remote endpoint
* capability list, else it is added to local H323
* endpoint list.
* @param sqcifMPI Minimum picture interval for encoding/decoding
@ -717,11 +717,11 @@ EXTERN int ooAppendCapToCapPrefs(struct OOH323CallData *call, int cap);
EXTERN int ooChangeCapPrefOrder(struct OOH323CallData *call, int cap, int pos);
/**
* This function is used to preppend a particular capability to preference
* This function is used to prepend a particular capability to preference
* list.
* @param call Handle to call, if call's preference list has to be modified
* else NULL, to modify endpoint's preference list.
* @param cap Capability to be preppended.
* @param cap Capability to be prepended.
*
* @return OO_OK, on success. OO_FAILED, otherwise.
*/

View File

@ -186,7 +186,7 @@ int ooReadAndProcessStackCommand()
if(!pCall) {
OOTRACEINFO2("Call \"%s\" does not exist\n",
(char*)cmd.param1);
OOTRACEINFO1("Call migth be cleared/closed\n");
OOTRACEINFO1("Call might be cleared/closed\n");
}
else {
ooSendProgress(ooFindCallByToken((char*)cmd.param1));
@ -200,7 +200,7 @@ int ooReadAndProcessStackCommand()
if(!pCall) {
OOTRACEINFO2("Call \"%s\" does not exist\n",
(char*)cmd.param1);
OOTRACEINFO1("Call migth be cleared/closed\n");
OOTRACEINFO1("Call might be cleared/closed\n");
}
else {
ooSendAlerting(ooFindCallByToken((char*)cmd.param1));

View File

@ -1231,7 +1231,7 @@ int ooGkClientHandleRegistrationConfirm
(&pGkClient->ctxt, sizeof(ooGkClientTimerCb));
if(!cbData)
{
OOTRACEERR1("Error:Failed to allocate memory for Regisration timer."
OOTRACEERR1("Error:Failed to allocate memory for Registration timer."
"\n");
pGkClient->state = GkClientFailed;
return OO_FAILED;
@ -1927,7 +1927,7 @@ int ooGkClientSendAdmissionRequest
(&pGkClient->ctxt, sizeof(ooGkClientTimerCb));
if(!cbData)
{
OOTRACEERR1("Error:Failed to allocate memory for Regisration timer."
OOTRACEERR1("Error:Failed to allocate memory for Registration timer."
"\n");
pGkClient->state = GkClientFailed;
ast_mutex_unlock(&pGkClient->Lock);

View File

@ -318,7 +318,7 @@ EXTERN int ooGkClientHandleRASMessage
/**
* This function is used to send a message on Gatekeeper clien't RAS channel.
* This function is used to send a message on Gatekeeper client RAS channel.
* @param pGkClient Handle to the gatekeeper client.
* @param pRasMsg Handle to Ras message to be sent.
*

View File

@ -78,7 +78,7 @@ OOLogicalChannel* ooAddNewLogicalChannel(OOH323CallData *call, int channelNo,
OOTRACEDBGC3("Using configured media info (%s, %s)\n", call->callType,
call->callToken);
pNewChannel->localRtpPort = pMediaInfo->lMediaRedirPort ? pMediaInfo->lMediaRedirPort : pMediaInfo->lMediaPort;
/* check MediaRedirPort here because RedirCPort is ReditPort + 1 and can't be 0 ;) */
/* check MediaRedirPort here because RedirCPort is RedirPort + 1 and can't be 0 ;) */
pNewChannel->localRtcpPort = pMediaInfo->lMediaRedirPort ? pMediaInfo->lMediaRedirCPort : pMediaInfo->lMediaCntrlPort;
/* If user application has not specified a specific ip and is using
multihomed mode, substitute appropriate ip.

View File

@ -318,7 +318,7 @@ EXTERN int ooSocketSendTo(OOSOCKET socket, const ASN1OCTET* pdata,
/**
* This function is used for synchronous monitoring of multiple sockets.
* For more information refer to documnetation of "select" system call.
* For more information refer to documentation of "select" system call.
*
* @param nfds The highest numbered descriptor to be monitored
* plus one.

View File

@ -30,7 +30,7 @@ OOBOOL ooUtilsIsStrEmpty (const char* str)
}
OOBOOL ooIsDailedDigit(const char* str)
OOBOOL ooIsDialedDigit(const char* str)
{
if(str == NULL || *str =='\0') { return FALSE; }
while(*str != '\0')

View File

@ -48,6 +48,6 @@ EXTERN OOBOOL ooUtilsIsStrEmpty (const char * str);
* @param str String to test
* @return TRUE if string contains all digits; FALSE otherwise
*/
EXTERN OOBOOL ooIsDailedDigit(const char* str);
EXTERN OOBOOL ooIsDialedDigit(const char* str);
#endif

View File

@ -607,7 +607,7 @@ EXTERN int initContextBuffer
/**
* This function initializes a context block. It makes sure that if the block
* was not previosly initialized, that all key working parameters are set to
* thier correct initial state values (i.e. declared within a function as a
* their correct initial state values (i.e. declared within a function as a
* normal working variable), it is required that they invoke this function
* before using it.
*

View File

@ -297,7 +297,7 @@ int ooCreateH225Connection(OOH323CallData *call)
{
call->pH225Channel->sock = channelSocket;
OOTRACEINFO3("H2250 transmiter channel creation - successful "
OOTRACEINFO3("H2250 transmitter channel creation - successful "
"(%s, %s)\n", call->callType, call->callToken);
/* If multihomed, get ip from socket */

View File

@ -2559,7 +2559,7 @@ int ooOnReceivedRequestChannelClose(OOH323CallData *call,
if (lChannel->state == OO_LOGICALCHAN_ESTABLISHED) {
ret = ooSendCloseLogicalChannel(call, lChannel);
if (ret != OO_OK) {
OOTRACEERR3("ERROR:Failed to build CloseLgicalChannel message(%s, %s)\n",
OOTRACEERR3("ERROR:Failed to build CloseLogicalChannel message(%s, %s)\n",
call->callType, call->callToken);
return OO_FAILED;
}

View File

@ -174,7 +174,7 @@ EXTERN int ooSendMasterSlaveDeterminationReject (struct OOH323CallData* call);
* MasterSlaveDetermination procedure.
* @param call Handle to the call for which MasterSlaveReject is
* received.
* @param reject Poinetr to the received reject message.
* @param reject Pointer to the received reject message.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/
@ -271,7 +271,7 @@ EXTERN int ooOnReceivedUserInputIndication
(OOH323CallData *call, H245UserInputIndication *indication);
/**
* This function is called on receiving a TreminalCapabilitySetAck message.
* This function is called on receiving a TerminalCapabilitySetAck message.
* If the MasterSlaveDetermination process is also over, this function
* initiates the process of opening logical channels.
* @param call Pointer to call for which TCSAck is received.

View File

@ -616,7 +616,7 @@ int ooOnReceivedSetup(OOH323CallData *call, Q931Message *q931Msg)
removeEventHandler(call->pctxt);
return OO_FAILED;
}
/* For now, just add decoded fast start elemts to list. This list
/* For now, just add decoded fast start elements to list. This list
will be processed at the time of sending CONNECT message. */
dListAppend(call->pctxt, &call->remoteFastStartOLCs, olc);
}
@ -1062,16 +1062,17 @@ int ooOnReceivedAlerting(OOH323CallData *call, Q931Message *q931Msg)
if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent &&
q931Msg->userInfo->h323_uu_pdu.h245Tunneling &&
OO_TESTFLAG (call->flags, OO_M_TUNNELING)) {
if (alerting->m.h245AddressPresent)
if (alerting->m.h245AddressPresent) {
OOTRACEINFO3("Tunneling and h245address provided."
"Giving preference to Tunneling (%s, %s)\n",
call->callType, call->callToken);
if (call->h225version >= 4) {
ret =ooSendTCSandMSD(call);
}
if (ret != OO_OK)
return ret;
}
if (call->h225version >= 4) {
ret =ooSendTCSandMSD(call);
}
if (ret != OO_OK) {
return ret;
}
} else if(alerting->m.h245AddressPresent) {
if (OO_TESTFLAG (call->flags, OO_M_TUNNELING))
{
@ -1314,15 +1315,17 @@ int ooOnReceivedProgress(OOH323CallData *call, Q931Message *q931Msg)
if(q931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent &&
q931Msg->userInfo->h323_uu_pdu.h245Tunneling &&
OO_TESTFLAG (call->flags, OO_M_TUNNELING)) {
if (progress->m.h245AddressPresent)
if (progress->m.h245AddressPresent) {
OOTRACEINFO3("Tunneling and h245address provided."
"Giving preference to Tunneling (%s, %s)\n",
call->callType, call->callToken);
if (call->h225version >= 4) {
ret =ooSendTCSandMSD(call);
}
if (ret != OO_OK)
}
if (call->h225version >= 4) {
ret =ooSendTCSandMSD(call);
}
if (ret != OO_OK) {
return ret;
}
} else if(progress->m.h245AddressPresent) {
if (OO_TESTFLAG (call->flags, OO_M_TUNNELING))
{

View File

@ -65,7 +65,7 @@ int ooH323EpInitialize
}
/* Initialize default port ranges that will be used by stack.
Apps can override these by explicitely setting port ranges
Apps can override these by explicitly setting port ranges
*/
gH323ep.tcpPorts.start = TCPPORTSSTART;

View File

@ -192,11 +192,13 @@ EXTERN int ooQ931Decode
screening indicators ;-) */
if(ie->discriminator == Q931CallingPartyNumberIE)
{
int numoffset=1;
OOTRACEDBGB1(" CallingPartyNumber IE = {\n");
if(ie->length < OO_MAX_NUMBER_LENGTH)
if(!(0x80 & ie->data[0])) numoffset = 2;
if( (ie->length >= numoffset) &&
(ie->length < OO_MAX_NUMBER_LENGTH) )
{
int numoffset=1;
if(!(0x80 & ie->data[0])) numoffset = 2;
memcpy(number, ie->data+numoffset,ie->length-numoffset);
number[ie->length-numoffset]='\0';
OOTRACEDBGB2(" %s\n", number);
@ -204,7 +206,7 @@ EXTERN int ooQ931Decode
ooCallSetCallingPartyNumber(call, number);
}
else{
OOTRACEERR3("Error:Calling party number too long. (%s, %s)\n",
OOTRACEERR3("Error:Calling party number outside range. (%s, %s)\n",
call->callType, call->callToken);
}
OOTRACEDBGB1(" }\n");
@ -214,7 +216,8 @@ EXTERN int ooQ931Decode
if(ie->discriminator == Q931CalledPartyNumberIE)
{
OOTRACEDBGB1(" CalledPartyNumber IE = {\n");
if(ie->length < OO_MAX_NUMBER_LENGTH)
if( (ie->length >= 1) &&
(ie->length < OO_MAX_NUMBER_LENGTH) )
{
memcpy(number, ie->data+1,ie->length-1);
number[ie->length-1]='\0';
@ -223,7 +226,7 @@ EXTERN int ooQ931Decode
ooCallSetCalledPartyNumber(call, number);
}
else{
OOTRACEERR3("Error:Calling party number too long. (%s, %s)\n",
OOTRACEERR3("Error:Calling party number outside range. (%s, %s)\n",
call->callType, call->callToken);
}
OOTRACEDBGB1(" }\n");
@ -585,7 +588,7 @@ int ooDecodeUUIE(OOCTXT* pctxt, Q931Message *q931Msg)
unsigned int i;
ASN1BOOL aligned=TRUE;
int stat;
Q931InformationElement *ie;
Q931InformationElement *ie=NULL;
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
if(q931Msg ==NULL)
{
@ -1210,7 +1213,7 @@ int ooSetFastStartResponse(OOH323CallData *pCall, Q931Message *pQ931msg,
pChannel = ooFindLogicalChannelByLogicalChannelNo
(pCall, olc->forwardLogicalChannelNumber);
/* start receive and tramsmit channel listening */
/* start receive and transmit channel listening */
if(dir & OORX)
{
strcpy(pChannel->remoteIP, remoteMediaControlIP);
@ -2025,7 +2028,7 @@ int ooSendStatusInquiry(OOH323CallData *call)
/* OOCTXT *pctxt = &gH323ep.msgctxt; */
OOCTXT *pctxt = call->msgctxt;
OOTRACEDBGC3("Building StatusInquryMsg (%s, %s)\n", call->callType,
OOTRACEDBGC3("Building StatusInquiryMsg (%s, %s)\n", call->callType,
call->callToken);
ret = ooCreateQ931Message(pctxt, &q931msg, Q931StatusEnquiryMsg);
if(ret != OO_OK)
@ -2987,7 +2990,7 @@ int ooH323MakeCall_helper(OOH323CallData *call)
}
if(!epCap)
{
OOTRACEWARN4("Warn:Preferred capability %s is abscent in "
OOTRACEWARN4("Warn:Preferred capability %s is absent in "
"capability list. (%s, %s)\n",
ooGetCapTypeText(call->capPrefs.order[k]),
call->callType, call->callToken);

View File

@ -582,7 +582,7 @@ EXTERN int ooH323MakeCall_helper(struct OOH323CallData *call);
* @param dest Destination string to be parsed.
* @param parsedIP Pointer to buffer in which parsed ip:port will be returned.
* @param len Length of the buffer passed.
* @param aliasList Aliase List in which new aliases will be added.
* @param aliasList Aliases List in which new aliases will be added.
*
* @return OO_OK, on success. OO_FAILED, on failure.
*/

View File

@ -6,6 +6,7 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
@ -93,7 +94,7 @@ static char *wait_result(void)
fprintf(stderr, "Got %d/%d bytes of audio\n", res, bytes);
#endif
bytes += res;
/* Prentend we detected some audio after 3 seconds */
/* Pretend we detected some audio after 3 seconds */
if (bytes > 16000 * 3) {
return "Sample Message";
bytes = 0;

View File

@ -348,7 +348,7 @@ sub music_dir_cache {
}
# this function will fill the @masterCacheList of all the files that
# need to have text2speeced ulaw files of their names generated
# need to have text2speech ulaw files of their names generated
sub music_dir_cache_genlist {
my $dir = shift;
if (!opendir(THEDIR, rmts($MUSIC.$dir))) {

View File

@ -36,6 +36,7 @@
/*** MODULEINFO
<depend>res_adsi</depend>
<defaultenabled>no</defaultenabled>
<support_level>deprecated</support_level>
***/

View File

@ -24,8 +24,14 @@
*
* See Also:
* \arg \ref AstCREDITS
* \arg \ref Config_agent
* \arg \ref agents.conf "Config_agent"
*/
/*!
* \page agents.conf agents.conf
* \verbinclude agents.conf.sample
*/
/*** MODULEINFO
<support_level>core</support_level>
***/
@ -456,17 +462,11 @@ struct agents_cfg {
struct ao2_container *agents;
};
static const char *agent_type_blacklist[] = {
"general",
"agents",
NULL,
};
static struct aco_type agent_type = {
.type = ACO_ITEM,
.name = "agent-id",
.category_match = ACO_BLACKLIST_ARRAY,
.category = (const char *)agent_type_blacklist,
.category_match = ACO_BLACKLIST_EXACT,
.category = "general",
.item_alloc = agent_cfg_alloc,
.item_find = agent_cfg_find,
.item_offset = offsetof(struct agents_cfg, agents),
@ -652,8 +652,6 @@ static struct ao2_container *agents;
* \brief Lock the agent.
*
* \param agent Agent to lock
*
* \return Nothing
*/
#define agent_lock(agent) _agent_lock(agent, __FILE__, __PRETTY_FUNCTION__, __LINE__, #agent)
static inline void _agent_lock(struct agent_pvt *agent, const char *file, const char *function, int line, const char *var)
@ -665,8 +663,6 @@ static inline void _agent_lock(struct agent_pvt *agent, const char *file, const
* \brief Unlock the agent.
*
* \param agent Agent to unlock
*
* \return Nothing
*/
#define agent_unlock(agent) _agent_unlock(agent, __FILE__, __PRETTY_FUNCTION__, __LINE__, #agent)
static inline void _agent_unlock(struct agent_pvt *agent, const char *file, const char *function, int line, const char *var)
@ -684,8 +680,6 @@ static inline void _agent_unlock(struct agent_pvt *agent, const char *file, cons
* \note Assumes the agent lock is already obtained.
*
* \note Defined locking order is channel lock then agent lock.
*
* \return Nothing
*/
static struct ast_channel *agent_lock_logged(struct agent_pvt *agent)
{
@ -750,8 +744,6 @@ static enum ast_device_state agent_pvt_devstate_get(const char *agent_id)
* \since 12.0.0
*
* \param agent_id Which agent needs the device state updated.
*
* \return Nothing
*/
static void agent_devstate_changed(const char *agent_id)
{
@ -1011,8 +1003,6 @@ AST_MUTEX_DEFINE_STATIC(agent_holding_lock);
* \param payload_size Size of the payload if payload is non-NULL. A number otherwise.
*
* \note The payload MUST NOT have any resources that need to be freed.
*
* \return Nothing
*/
static void clear_agent_status(struct ast_bridge_channel *bridge_channel, const void *payload, size_t payload_size)
{
@ -1028,8 +1018,6 @@ static void clear_agent_status(struct ast_bridge_channel *bridge_channel, const
* \param agent Which agent is connecting to the caller.
*
* \note The agent is locked on entry and not locked on exit.
*
* \return Nothing
*/
static void agent_connect_caller(struct ast_bridge_channel *bridge_channel, struct agent_pvt *agent)
{
@ -1363,8 +1351,6 @@ static int bridge_agent_hold_push(struct ast_bridge *self, struct ast_bridge_cha
* bridge_channel->bridge_pvt.
*
* \note On entry, self is already locked.
*
* \return Nothing
*/
static void bridge_agent_hold_pull(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel)
{
@ -1382,8 +1368,6 @@ static void bridge_agent_hold_pull(struct ast_bridge *self, struct ast_bridge_ch
* references to the bridge so it can be destroyed.
*
* \note On entry, self must NOT be locked.
*
* \return Nothing
*/
static void bridge_agent_hold_dissolving(struct ast_bridge *self)
{
@ -1475,8 +1459,6 @@ static void send_agent_logoff(struct ast_channel *chan, const char *agent, long
* \param agent Which agent logging out.
*
* \note On entry agent is already locked. On exit it is no longer locked.
*
* \return Nothing
*/
static void agent_logout(struct agent_pvt *agent)
{
@ -1514,8 +1496,6 @@ static void agent_logout(struct agent_pvt *agent)
*
* \param agent Which agent.
* \param logged The logged in channel.
*
* \return Nothing
*/
static void agent_run(struct agent_pvt *agent, struct ast_channel *logged)
{
@ -2034,8 +2014,6 @@ static int agent_request_exec(struct ast_channel *chan, const char *data)
*
* \param agent What to setup channel config values on.
* \param chan Channel logging in as an agent.
*
* \return Nothing
*/
static void agent_login_channel_config(struct agent_pvt *agent, struct ast_channel *chan)
{

View File

@ -40,6 +40,7 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
@ -158,7 +159,7 @@ static const char app[] = "AlarmReceiver";
events to the standard input of the application.
The configuration file also contains settings for DTMF timing, and for the loudness of the
acknowledgement tones.</para>
<note><para>Few Ademco DTMF signalling formats are detected automaticaly: Contact ID, Express 4+1,
<note><para>Few Ademco DTMF signalling formats are detected automatically: Contact ID, Express 4+1,
Express 4+2, High Speed and Super Fast.</para></note>
<para>The application is affected by the following variables:</para>
<variablelist>
@ -203,7 +204,6 @@ static char event_file[14] = "/event-XXXXXX";
* family, then create it and set its value to 1.
*
* \param key A database key to increment
* \return Nothing
*/
static void database_increment(char *key)
{

View File

@ -38,6 +38,7 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/

View File

@ -26,6 +26,7 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
@ -140,4 +141,4 @@ static int load_module(void)
return ast_register_application_xml(app, attended_transfer_exec);
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Attended transfer to the given extension");
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Attended transfer to the given extension");

View File

@ -27,6 +27,7 @@
/*** MODULEINFO
<depend>res_audiosocket</depend>
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/

View File

@ -26,6 +26,7 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
@ -134,4 +135,4 @@ static int load_module(void)
return ast_register_application_xml(app, blind_transfer_exec);
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Blind transfer channel to the given destination");
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Blind transfer channel to the given destination");

View File

@ -391,17 +391,6 @@ static void wait_wrapper_removal(struct wait_bridge_wrapper *wrapper)
ao2_cleanup(wrapper);
}
/*!
* \internal
* \since 12.0.0
* \brief Application callback for the bridgewait application
*
* \param chan channel running the application
* \param data Arguments to the application
*
* \retval 0 Ran successfully and the call didn't hang up
* \retval -1 Failed or the call was hung up by the time the channel exited the holding bridge
*/
static enum wait_bridge_roles validate_role(const char *role)
{
if (!strcmp(role, "participant")) {
@ -413,6 +402,17 @@ static enum wait_bridge_roles validate_role(const char *role)
}
}
/*!
* \internal
* \since 12.0.0
* \brief Application callback for the bridgewait application
*
* \param chan channel running the application
* \param data Arguments to the application
*
* \retval 0 Ran successfully and the call didn't hang up
* \retval -1 Failed or the call was hung up by the time the channel exited the holding bridge
*/
static int bridgewait_exec(struct ast_channel *chan, const char *data)
{
char *bridge_name = DEFAULT_BRIDGE_NAME;

View File

@ -28,6 +28,7 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/

View File

@ -245,6 +245,11 @@
</enum>
</enumlist>
</option>
<option name="D">
<para>Interleave the audio coming from the channel and the audio coming to the channel in
the output audio as a dual channel stream, rather than mix it. Does nothing if 'o'
is also set.</para>
</option>
<option name="e">
<argument name="ext" required="true" />
<para>Enable <emphasis>enforced</emphasis> mode, so the spying channel can
@ -393,6 +398,7 @@ enum {
OPTION_EXITONHANGUP = (1 << 18), /* Hang up when the spied-on channel hangs up. */
OPTION_UNIQUEID = (1 << 19), /* The chanprefix is a channel uniqueid or fully specified channel name. */
OPTION_LONG_QUEUE = (1 << 20), /* Allow usage of a long queue to store audio frames. */
OPTION_INTERLEAVED = (1 << 21), /* Interleave the Read and Write frames in the output frame. */
};
enum {
@ -411,6 +417,7 @@ AST_APP_OPTIONS(spy_opts, {
AST_APP_OPTION('B', OPTION_BARGE),
AST_APP_OPTION_ARG('c', OPTION_DTMF_CYCLE, OPT_ARG_CYCLE),
AST_APP_OPTION('d', OPTION_DTMF_SWITCH_MODES),
AST_APP_OPTION('D', OPTION_INTERLEAVED),
AST_APP_OPTION_ARG('e', OPTION_ENFORCED, OPT_ARG_ENFORCED),
AST_APP_OPTION('E', OPTION_EXITONHANGUP),
AST_APP_OPTION_ARG('g', OPTION_GROUP, OPT_ARG_GROUP),
@ -471,6 +478,56 @@ static int spy_generate(struct ast_channel *chan, void *data, int len, int sampl
if (ast_test_flag(&csth->flags, OPTION_READONLY)) {
/* Option 'o' was set, so don't mix channel audio */
f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_READ, ast_format_slin);
} else if (ast_test_flag(&csth->flags, OPTION_INTERLEAVED)) {
/* Option 'D' was set, so mix the spy frame as an interleaved dual channel frame. */
int i;
struct ast_frame *fr_read = NULL;
struct ast_frame *fr_write = NULL;
short read_buf[samples];
short write_buf[samples];
short stereo_buf[samples * 2];
struct ast_frame stereo_frame = {
.frametype = AST_FRAME_VOICE,
.datalen = sizeof(stereo_buf),
.samples = samples,
};
f = ast_audiohook_read_frame_all(&csth->spy_audiohook, samples, ast_format_slin, &fr_read, &fr_write);
if (f) {
ast_frame_free(f, 0);
f = NULL;
}
if (fr_read) {
memcpy(read_buf, fr_read->data.ptr, sizeof(read_buf));
} else {
/* silent out the output frame if we can't read the input */
memset(read_buf, 0, sizeof(read_buf));
}
if (fr_write) {
memcpy(write_buf, fr_write->data.ptr, sizeof(write_buf));
} else {
memset(write_buf, 0, sizeof(write_buf));
}
for (i = 0; i < samples; i++) {
stereo_buf[i*2] = read_buf[i];
stereo_buf[i*2+1] = write_buf[i];
}
stereo_frame.data.ptr = stereo_buf;
stereo_frame.subclass.format = ast_format_cache_get_slin_by_rate(samples);
f = ast_frdup(&stereo_frame);
if (fr_read) {
ast_frame_free(fr_read, 0);
}
if (fr_write) {
ast_frame_free(fr_write, 0);
}
} else {
f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, ast_format_slin);
}
@ -559,7 +616,7 @@ static int pack_channel_into_message(struct ast_channel *chan, const char *role,
* \brief Publish the chanspy message over Stasis-Core
* \param spyer The channel doing the spying
* \param spyee Who is being spied upon
* \start start If non-zero, the spying is starting. Otherwise, the spyer is
* \param start If non-zero, the spying is starting. Otherwise, the spyer is
* finishing
*/
static void publish_chanspy_message(struct ast_channel *spyer,
@ -845,13 +902,13 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto
ast_audiohook_unlock(&csth.spy_audiohook);
ast_audiohook_destroy(&csth.spy_audiohook);
ast_verb(2, "Done Spying on channel %s\n", name);
publish_chanspy_message(chan, spyee_autochan->chan, 0);
if (spyee_bridge_autochan) {
ast_autochan_destroy(spyee_bridge_autochan);
}
ast_verb(2, "Done Spying on channel %s\n", name);
publish_chanspy_message(chan, NULL, 0);
return running;
}
@ -899,7 +956,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
signed char zero_volume = 0;
int waitms;
int res;
int num_spyed_upon = 1;
int num_spied_upon = 1;
struct ast_channel_iterator *iter = NULL;
if (ast_test_flag(flags, OPTION_EXIT)) {
@ -926,7 +983,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
struct ast_autochan *autochan = NULL, *next_autochan = NULL;
struct ast_channel *prev = NULL;
if (!ast_test_flag(flags, OPTION_QUIET) && num_spyed_upon) {
if (!ast_test_flag(flags, OPTION_QUIET) && num_spied_upon) {
res = ast_streamfile(chan, "beep", ast_channel_language(chan));
if (!res)
res = ast_waitstream(chan, "");
@ -991,7 +1048,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
/* reset for the next loop around, unless overridden later */
waitms = 100;
num_spyed_upon = 0;
num_spied_upon = 0;
for (autochan = next_channel(iter, chan);
autochan;
@ -1146,7 +1203,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
}
res = channel_spy(chan, autochan, &volfactor, fd, user_options, flags, exitcontext);
num_spyed_upon++;
num_spied_upon++;
if (res == -1) {
ast_autochan_destroy(autochan);

View File

@ -124,6 +124,37 @@
</variable>
</variablelist>
</description>
<see-also>
<ref type="application">ConfKick</ref>
<ref type="function">CONFBRIDGE</ref>
<ref type="function">CONFBRIDGE_INFO</ref>
</see-also>
</application>
<application name="ConfKick" language="en_US">
<synopsis>
Kicks channel(s) from the requested ConfBridge.
</synopsis>
<syntax>
<parameter name="conference" required="true" />
<parameter name="channel">
<para>The channel to kick, <literal>all</literal>
to kick all users, or <literal>participants</literal>
to kick all non-admin participants. Default is all.</para>
</parameter>
</syntax>
<description>
<para>Kicks the requested channel(s) from a conference bridge.</para>
<variablelist>
<variable name="CONFKICKSTATUS">
<value name="FAILURE">
Could not kick any users with the provided arguments.
</value>
<value name="SUCCESS">
Successfully kicked users from specified conference bridge.
</value>
</variable>
</variablelist>
</description>
<see-also>
<ref type="application">ConfBridge</ref>
<ref type="function">CONFBRIDGE</ref>
@ -426,6 +457,7 @@
*/
static const char app[] = "ConfBridge";
static const char app2[] = "ConfKick";
/*! Number of buckets our conference bridges container can have */
#define CONFERENCE_BRIDGE_BUCKETS 53
@ -765,8 +797,8 @@ struct confbridge_conference *conf_find_bridge(const char *conference_name)
*
* \note Must be called with the conference locked
*
* \retval 1, conference is recording.
* \retval 0, conference is NOT recording.
* \retval 1 conference is recording.
* \retval 0 conference is NOT recording.
*/
static int conf_is_recording(struct confbridge_conference *conference)
{
@ -877,7 +909,7 @@ static int conf_start_record(struct confbridge_conference *conference)
return 0;
}
/* \brief Playback the given filename and monitor for any dtmf interrupts.
/*! \brief Playback the given filename and monitor for any dtmf interrupts.
*
* This function is used to playback sound files on a given channel and optionally
* allow dtmf interrupts to occur.
@ -891,7 +923,9 @@ static int conf_start_record(struct confbridge_conference *conference)
* \param channel Optional channel to play file on if bridge_channel not given
* \param filename The file name to playback
*
* \retval -1 failure during playback, 0 on file was fully played, 1 on dtmf interrupt.
* \retval -1 failure during playback.
* \retval 0 on file was fully played.
* \retval 1 on dtmf interrupt.
*/
static int play_file(struct ast_bridge_channel *bridge_channel, struct ast_channel *channel,
const char *filename)
@ -948,7 +982,8 @@ static int sound_file_exists(const char *filename)
* \param bridge_channel The bridged channel involved
*
* \note if caller is NULL, the announcment will be sent to all participants in the conference.
* \return Returns 0 on success, -1 if the user hung up
* \retval 0 on success.
* \retval -1 if the user hung up.
*/
static int announce_user_count(struct confbridge_conference *conference, struct confbridge_user *user,
struct ast_bridge_channel *bridge_channel)
@ -998,7 +1033,9 @@ static int announce_user_count(struct confbridge_conference *conference, struct
* \param user User to play audio prompt to
* \param filename Prompt to play
*
* \return Returns 0 on success, -1 if the user hung up
* \retval 0 on success.
* \retval -1 if the user hung up.
*
* \note Generally this should be called when the conference is unlocked to avoid blocking
* the entire conference while the sound is played. But don't unlock the conference bridge
* in the middle of a state transition.
@ -1135,8 +1172,6 @@ static void hangup_data_destroy(struct hangup_data *hangup)
* \brief Destroy a conference bridge
*
* \param obj The conference bridge object
*
* \return Returns nothing
*/
static void destroy_conference_bridge(void *obj)
{
@ -1273,7 +1308,7 @@ void conf_update_user_mute(struct confbridge_user *user)
ast_channel_name(user->chan));
}
/*
/*!
* \internal
* \brief Mute/unmute a single user.
*/
@ -1357,8 +1392,6 @@ void conf_moh_start(struct confbridge_user *user)
* \brief Unsuspend MOH for the conference user.
*
* \param user Conference user to unsuspend MOH on.
*
* \return Nothing
*/
static void conf_moh_unsuspend(struct confbridge_user *user)
{
@ -1374,8 +1407,6 @@ static void conf_moh_unsuspend(struct confbridge_user *user)
* \brief Suspend MOH for the conference user.
*
* \param user Conference user to suspend MOH on.
*
* \return Nothing
*/
static void conf_moh_suspend(struct confbridge_user *user)
{
@ -1650,7 +1681,7 @@ static struct confbridge_conference *join_conference_bridge(const char *conferen
struct post_join_action *action;
int max_members_reached = 0;
/* We explictly lock the conference bridges container ourselves so that other callers can not create duplicate conferences at the same */
/* We explicitly lock the conference bridges container ourselves so that other callers can not create duplicate conferences at the same */
ao2_lock(conference_bridges);
ast_debug(1, "Trying to find conference bridge '%s'\n", conference_name);
@ -1730,6 +1761,9 @@ static struct confbridge_conference *join_conference_bridge(const char *conferen
ast_brige_set_remb_behavior(conference->bridge, AST_BRIDGE_VIDEO_SFU_REMB_LOWEST_ALL);
} else if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_REMB_BEHAVIOR_HIGHEST_ALL)) {
ast_brige_set_remb_behavior(conference->bridge, AST_BRIDGE_VIDEO_SFU_REMB_HIGHEST_ALL);
} else if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_REMB_BEHAVIOR_FORCE)) {
ast_brige_set_remb_behavior(conference->bridge, AST_BRIDGE_VIDEO_SFU_REMB_FORCE);
ast_bridge_set_remb_estimated_bitrate(conference->bridge, conference->b_profile.remb_estimated_bitrate);
}
}
@ -2532,10 +2566,6 @@ static int confbridge_exec(struct ast_channel *chan, const char *data)
AST_APP_ARG(menu_profile_name);
);
if (ast_channel_state(chan) != AST_STATE_UP) {
ast_answer(chan);
}
if (ast_bridge_features_init(&user.features)) {
pbx_builtin_setvar_helper(chan, "CONFBRIDGE_RESULT", "FAILED");
res = -1;
@ -2585,6 +2615,11 @@ static int confbridge_exec(struct ast_channel *chan, const char *data)
goto confbridge_cleanup;
}
/* If channel hasn't been answered already, answer it, unless we're explicitly not supposed to */
if ((ast_channel_state(chan) != AST_STATE_UP) && (ast_test_flag(&user.u_profile, USER_OPT_ANSWER_CHANNEL))) {
ast_answer(chan);
}
quiet = ast_test_flag(&user.u_profile, USER_OPT_QUIET);
/* ask for a PIN immediately after finding user profile. This has to be
@ -3458,7 +3493,7 @@ static char *handle_cli_confbridge_list(struct ast_cli_entry *e, int cmd, struct
return CLI_SHOWUSAGE;
}
/* \internal
/*! \internal
* \brief finds a conference by name and locks/unlocks.
*
* \retval 0 success
@ -3482,7 +3517,7 @@ static int generic_lock_unlock_helper(int lock, const char *conference_name)
return res;
}
/* \internal
/*! \internal
* \brief finds a conference user by channel name and mutes/unmutes them.
*
* \retval 0 success
@ -4217,6 +4252,53 @@ static int func_confbridge_info(struct ast_channel *chan, const char *cmd, char
return 0;
}
static int confkick_exec(struct ast_channel *chan, const char *data)
{
char *parse;
struct confbridge_conference *conference;
int not_found;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(confbridge);
AST_APP_ARG(channel);
);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "No conference bridge specified.\n");
pbx_builtin_setvar_helper(chan, "CONFKICKSTATUS", "FAILURE");
return 0;
}
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
conference = ao2_find(conference_bridges, args.confbridge, OBJ_KEY);
if (!conference) {
ast_log(LOG_WARNING, "No conference bridge named '%s' found!\n", args.confbridge);
pbx_builtin_setvar_helper(chan, "CONFKICKSTATUS", "FAILURE");
return 0;
}
if (ast_strlen_zero(args.channel)) {
not_found = kick_conference_participant(conference, "all");
} else {
not_found = kick_conference_participant(conference, args.channel);
}
ao2_ref(conference, -1);
if (not_found) {
if (ast_strlen_zero(args.channel) || !strcasecmp("all", args.channel) || !strcasecmp("participants", args.channel)) {
ast_log(LOG_WARNING, "No participants found in conference bridge '%s'!\n", args.confbridge);
} else {
ast_log(LOG_WARNING, "No participant named '%s' found in conference bridge '%s'!\n", args.channel, args.confbridge);
}
pbx_builtin_setvar_helper(chan, "CONFKICKSTATUS", "FAILURE");
return 0;
}
ast_debug(1, "Kicked '%s' out of conference '%s'\n", args.channel, args.confbridge);
pbx_builtin_setvar_helper(chan, "CONFKICKSTATUS", "SUCCESS");
return 0;
}
void conf_add_user_active(struct confbridge_conference *conference, struct confbridge_user *user)
{
AST_LIST_INSERT_TAIL(&conference->active_list, user, list);
@ -4272,8 +4354,6 @@ void conf_remove_user_waiting(struct confbridge_conference *conference, struct c
* \since 12.0.0
*
* \param tech What to unregister.
*
* \return Nothing
*/
static void unregister_channel_tech(struct ast_channel_tech *tech)
{
@ -4310,6 +4390,7 @@ static int register_channel_tech(struct ast_channel_tech *tech)
static int unload_module(void)
{
ast_unregister_application(app);
ast_unregister_application(app2);
ast_custom_function_unregister(&confbridge_function);
ast_custom_function_unregister(&confbridge_info_function);
@ -4380,6 +4461,7 @@ static int load_module(void)
res |= manager_confbridge_init();
res |= ast_register_application_xml(app, confbridge_exec);
res |= ast_register_application_xml(app2, confkick_exec);
res |= ast_custom_function_register_escalating(&confbridge_function, AST_CFE_WRITE);
res |= ast_custom_function_register(&confbridge_info_function);

View File

@ -27,7 +27,10 @@
/*** MODULEINFO
<depend>dahdi</depend>
<defaultenabled>no</defaultenabled>
<support_level>deprecated</support_level>
<deprecated_in>16</deprecated_in>
<removed_in>19</removed_in>
***/
#include "asterisk.h"

View File

@ -93,11 +93,17 @@
</parameter>
<parameter name="options" required="false">
<optionlist>
<option name="A">
<argument name="x" required="true">
<option name="A" argsep=":">
<argument name="x">
<para>The file to play to the called party</para>
</argument>
<para>Play an announcement to the called party, where <replaceable>x</replaceable> is the prompt to be played</para>
<argument name="y">
<para>The file to play to the calling party</para>
</argument>
<para>Play an announcement to the called and/or calling parties, where <replaceable>x</replaceable>
is the prompt to be played to the called party and <replaceable>y</replaceable> is the prompt
to be played to the caller. The files may be different and will be played to each party
simultaneously.</para>
</option>
<option name="a">
<para>Immediately answer the calling channel when the called channel answers in
@ -924,7 +930,7 @@ static const char *get_cid_name(char *name, int namelen, struct ast_channel *cha
* XXX this code is highly suspicious, as it essentially overwrites
* the outgoing channel without properly deleting it.
*
* \todo eventually this function should be intergrated into and replaced by ast_call_forward()
* \todo eventually this function should be integrated into and replaced by ast_call_forward()
*/
static void do_forward(struct chanlist *o, struct cause_args *num,
struct ast_flags64 *peerflags, int single, int caller_entertained, int *to,
@ -1161,8 +1167,6 @@ static void publish_dial_end_event(struct ast_channel *in, struct dial_head *out
* \param chan Channel to get connected line updated.
* \param peer Channel providing connected line information.
* \param is_caller Non-zero if chan is the calling channel.
*
* \return Nothing
*/
static void update_connected_line_from_peer(struct ast_channel *chan, struct ast_channel *peer, int is_caller)
{
@ -1204,7 +1208,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
struct privacy_args *pa,
const struct cause_args *num_in, int *result, char *dtmf_progress,
const int ignore_cc,
struct ast_party_id *forced_clid, struct ast_party_id *stored_clid)
struct ast_party_id *forced_clid, struct ast_party_id *stored_clid,
struct ast_bridge_config *config)
{
struct cause_args num = *num_in;
int prestart = num.busy + num.congestion + num.nochan;
@ -1223,7 +1228,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
int sent_ring = 0;
int sent_progress = 0;
struct timeval start = ast_tvnow();
SCOPE_TRACE(1, "%s\n", ast_channel_name(in));
SCOPE_ENTER(3, "%s\n", ast_channel_name(in));
if (single) {
/* Turn off hold music, etc */
@ -1239,7 +1244,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
*to = -1;
strcpy(pa->status, "CONGESTION");
ast_channel_publish_dial(in, outgoing->chan, NULL, pa->status);
return NULL;
SCOPE_EXIT_RTN_VALUE(NULL, "%s: can't be made compat with %s\n",
ast_channel_name(in), ast_channel_name(outgoing->chan));
}
}
@ -1281,7 +1287,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
if (is_cc_recall) {
ast_cc_failed(cc_recall_core_id, "Everyone is busy/congested for the recall. How sad");
}
return NULL;
SCOPE_EXIT_RTN_VALUE(NULL, "%s: No outging channels available\n", ast_channel_name(in));
}
winner = ast_waitfor_n(watchers, pos, to);
AST_LIST_TRAVERSE(out_chans, o, node) {
@ -1390,7 +1396,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
case AST_CONTROL_ANSWER:
/* This is our guy if someone answered. */
if (!peer) {
ast_trace(1, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
ast_trace(-1, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
ast_verb(3, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
if (o->orig_chan_name
&& strcmp(o->orig_chan_name, ast_channel_name(c))) {
@ -1418,6 +1424,18 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
}
}
peer = c;
/* Answer can optionally include a topology */
if (f->subclass.topology) {
/*
* We need to bump the refcount on the topology to prevent it
* from being cleaned up when the frame is cleaned up.
*/
config->answer_topology = ao2_bump(f->subclass.topology);
ast_trace(-1, "%s Found topology in frame: %p %p %s\n",
ast_channel_name(peer), f, config->answer_topology,
ast_str_tmp(256, ast_stream_topology_to_str(config->answer_topology, &STR_TMP)));
}
/* Inform everyone else that they've been canceled.
* The dial end event for the peer will be sent out after
* other Dial options have been handled.
@ -1545,12 +1563,14 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
ast_channel_stage_snapshot_done(in);
ast_channel_unlock(in);
sent_progress = 1;
}
if (!ast_strlen_zero(dtmf_progress)) {
ast_verb(3,
"Sending DTMF '%s' to the called party as result of receiving a PROGRESS message.\n",
dtmf_progress);
ast_dtmf_stream(c, in, dtmf_progress, 250, 0);
if (!ast_strlen_zero(dtmf_progress)) {
ast_verb(3,
"Sending DTMF '%s' to the called party as result of "
"receiving a PROGRESS message.\n",
dtmf_progress);
ast_dtmf_stream(c, in, dtmf_progress, 250, 0);
}
}
ast_channel_publish_dial(in, c, NULL, "PROGRESS");
break;
@ -1708,7 +1728,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
if (is_cc_recall) {
ast_cc_completed(in, "CC completed, although the caller hung up (cancelled)");
}
return NULL;
SCOPE_EXIT_RTN_VALUE(NULL, "%s: Caller hung up\n", ast_channel_name(in));
}
/* now f is guaranteed non-NULL */
@ -1728,7 +1748,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
if (is_cc_recall) {
ast_cc_completed(in, "CC completed, but the caller used DTMF to exit");
}
return NULL;
SCOPE_EXIT_RTN_VALUE(NULL, "%s: Caller pressed %c to end call\n",
ast_channel_name(in), f->subclass.integer);
}
ast_channel_unlock(in);
}
@ -1743,7 +1764,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
if (is_cc_recall) {
ast_cc_completed(in, "CC completed, but the caller hung up with DTMF");
}
return NULL;
SCOPE_EXIT_RTN_VALUE(NULL, "%s: Caller requested disconnect\n",
ast_channel_name(in));
}
}
@ -1849,7 +1871,8 @@ skip_frame:;
if (is_cc_recall) {
ast_cc_completed(in, "Recall completed!");
}
return peer;
SCOPE_EXIT_RTN_VALUE(peer, "%s: %s%s\n", ast_channel_name(in),
peer ? "Answered by " : "No answer", peer ? ast_channel_name(peer) : "");
}
static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str **featurecode)
@ -2185,8 +2208,6 @@ static int dial_handle_playtones(struct ast_channel *chan, const char *data)
* \param peer Peer channel for bridge.
* \param opts Dialing option flags.
* \param opt_args Dialing option argument strings.
*
* \return Nothing
*/
static void setup_peer_after_bridge_goto(struct ast_channel *chan, struct ast_channel *peer, struct ast_flags64 *opts, char *opt_args[])
{
@ -2217,7 +2238,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
struct dial_head out_chans = AST_LIST_HEAD_NOLOCK_INIT_VALUE; /* list of destinations */
struct chanlist *outgoing;
struct chanlist *tmp;
struct ast_channel *peer;
struct ast_channel *peer = NULL;
int to; /* timeout */
struct cause_args num = { chan, 0, 0, 0 };
int cause;
@ -2271,7 +2292,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
*/
struct ast_party_caller caller;
int max_forwards;
SCOPE_TRACE(1, "%s Data: %s\n", ast_channel_name(chan), data);
SCOPE_ENTER(1, "%s: Data: %s\n", ast_channel_name(chan), data);
/* Reset all DIAL variables back to blank, to prevent confusion (in case we don't reset all of them). */
ast_channel_lock(chan);
@ -2295,7 +2316,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
ast_log(LOG_WARNING, "Cannot place outbound call from channel '%s'. Max forwards exceeded\n",
ast_channel_name(chan));
pbx_builtin_setvar_helper(chan, "DIALSTATUS", "BUSY");
return -1;
SCOPE_EXIT_RTN_VALUE(-1, "%s: Max forwards exceeded\n", ast_channel_name(chan));
}
if (ast_check_hangup_locked(chan)) {
@ -2313,7 +2334,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
*/
ast_verb(3, "Caller hung up before dial.\n");
pbx_builtin_setvar_helper(chan, "DIALSTATUS", "CANCEL");
return -1;
SCOPE_EXIT_RTN_VALUE(-1, "%s: Caller hung up before dial\n", ast_channel_name(chan));
}
parse = ast_strdupa(data ?: "");
@ -2838,7 +2859,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
}
peer = wait_for_answer(chan, &out_chans, &to, peerflags, opt_args, &pa, &num, &result,
dtmf_progress, ignore_cc, &forced_clid, &stored_clid);
dtmf_progress, ignore_cc, &forced_clid, &stored_clid, &config);
if (!peer) {
if (result) {
@ -2922,33 +2943,71 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
int digit = 0;
struct ast_channel *chans[2];
struct ast_channel *active_chan;
char *calledfile = NULL, *callerfile = NULL;
int calledstream = 0, callerstream = 0;
chans[0] = chan;
chans[1] = peer;
/* we need to stream the announcement to the called party when the OPT_ARG_ANNOUNCE (-A) is setted */
/* we need to stream the announcement(s) when the OPT_ARG_ANNOUNCE (-A) is set */
callerfile = opt_args[OPT_ARG_ANNOUNCE];
calledfile = strsep(&callerfile, ":");
/* stream the file */
res = ast_streamfile(peer, opt_args[OPT_ARG_ANNOUNCE], ast_channel_language(peer));
if (res) {
res = 0;
ast_log(LOG_ERROR, "error streaming file '%s' to callee\n", opt_args[OPT_ARG_ANNOUNCE]);
/* stream the file(s) */
if (!ast_strlen_zero(calledfile)) {
res = ast_streamfile(peer, calledfile, ast_channel_language(peer));
if (res) {
res = 0;
ast_log(LOG_ERROR, "error streaming file '%s' to callee\n", calledfile);
} else {
calledstream = 1;
}
}
if (!ast_strlen_zero(callerfile)) {
res = ast_streamfile(chan, callerfile, ast_channel_language(chan));
if (res) {
res = 0;
ast_log(LOG_ERROR, "error streaming file '%s' to caller\n", callerfile);
} else {
callerstream = 1;
}
}
/* can't use ast_waitstream, because we're streaming two files at once, and can't block
We'll need to handle both channels at once. */
ast_channel_set_flag(peer, AST_FLAG_END_DTMF_ONLY);
while (ast_channel_stream(peer)) {
int ms;
while (ast_channel_stream(peer) || ast_channel_stream(chan)) {
int mspeer, mschan;
ms = ast_sched_wait(ast_channel_sched(peer));
mspeer = ast_sched_wait(ast_channel_sched(peer));
mschan = ast_sched_wait(ast_channel_sched(chan));
if (ms < 0 && !ast_channel_timingfunc(peer)) {
ast_stopstream(peer);
if (calledstream) {
if (mspeer < 0 && !ast_channel_timingfunc(peer)) {
ast_stopstream(peer);
calledstream = 0;
}
}
if (callerstream) {
if (mschan < 0 && !ast_channel_timingfunc(chan)) {
ast_stopstream(chan);
callerstream = 0;
}
}
if (!calledstream && !callerstream) {
break;
}
if (ms < 0)
ms = 1000;
active_chan = ast_waitfor_n(chans, 2, &ms);
if (mspeer < 0)
mspeer = 1000;
if (mschan < 0)
mschan = 1000;
/* wait for the lowest maximum of the two */
active_chan = ast_waitfor_n(chans, 2, (mspeer > mschan ? &mschan : &mspeer));
if (active_chan) {
struct ast_channel *other_chan;
struct ast_frame *fr = ast_read(active_chan);
@ -2998,6 +3057,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
ast_frfree(fr);
}
ast_sched_runq(ast_channel_sched(peer));
ast_sched_runq(ast_channel_sched(chan));
}
ast_channel_clear_flag(peer, AST_FLAG_END_DTMF_ONLY);
}
@ -3267,6 +3327,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
ast_channel_setoption(chan, AST_OPTION_OPRMODE, &oprmode, sizeof(oprmode), 0);
}
setup_peer_after_bridge_goto(chan, peer, &opts, opt_args);
res = ast_bridge_call(chan, peer, &config);
}
}
@ -3304,6 +3365,18 @@ out:
}
done:
if (config.answer_topology) {
ast_trace(2, "%s Cleaning up topology: %p %s\n",
peer ? ast_channel_name(peer) : "<no channel>", &config.answer_topology,
ast_str_tmp(256, ast_stream_topology_to_str(config.answer_topology, &STR_TMP)));
/*
* At this point, the channel driver that answered should have bumped the
* topology refcount for itself. Here we're cleaning up the reference we added
* in wait_for_answer().
*/
ast_stream_topology_free(config.answer_topology);
}
if (config.warning_sound) {
ast_free((char *)config.warning_sound);
}
@ -3314,7 +3387,7 @@ done:
ast_free((char *)config.start_sound);
}
ast_ignore_cc(chan);
return res;
SCOPE_EXIT_RTN_VALUE(res, "%s: Done\n", ast_channel_name(chan));
}
static int dial_exec(struct ast_channel *chan, const char *data)

View File

@ -28,6 +28,7 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/

View File

@ -103,6 +103,14 @@
receiver to their ear while entering DTMF.</para>
<argument name="n" required="true" />
</option>
<option name="c">
<para>Load the specified config file instead of voicemail.conf</para>
<argument name="filename" required="true" />
</option>
<option name="s">
<para>Skip calling the extension, instead set it in the <variable>DIRECTORY_EXTEN</variable>
channel variable.</para>
</option>
</optionlist>
<note><para>Only one of the <replaceable>f</replaceable>, <replaceable>l</replaceable>, or <replaceable>b</replaceable>
options may be specified. <emphasis>If more than one is specified</emphasis>, then Directory will act as
@ -114,12 +122,12 @@
<description>
<para>This application will present the calling channel with a directory of extensions from which they can search
by name. The list of names and corresponding extensions is retrieved from the
voicemail configuration file, <filename>voicemail.conf</filename>.</para>
voicemail configuration file, <filename>voicemail.conf</filename>, or from the specified filename.</para>
<para>This application will immediately exit if one of the following DTMF digits are
received and the extension to jump to exists:</para>
<para><literal>0</literal> - Jump to the 'o' extension, if it exists.</para>
<para><literal>*</literal> - Jump to the 'a' extension, if it exists.</para>
<para>This application will set the following channel variable before completion:</para>
<para>This application will set the following channel variables before completion:</para>
<variablelist>
<variable name="DIRECTORY_RESULT">
<para>Reason Directory application exited.</para>
@ -131,6 +139,10 @@
<value name="USEREXIT">User exited with '#' during selection</value>
<value name="FAILED">The application failed</value>
</variable>
<variable name="DIRECTORY_EXTEN">
<para>If the skip calling option is set this will be set to the selected extension
provided one is selected.</para>
</variable>
</variablelist>
</description>
</application>
@ -153,6 +165,8 @@ enum {
OPT_PAUSE = (1 << 5),
OPT_NOANSWER = (1 << 6),
OPT_ALIAS = (1 << 7),
OPT_CONFIG_FILE = (1 << 8),
OPT_SKIP = (1 << 9),
};
enum {
@ -160,8 +174,9 @@ enum {
OPT_ARG_LASTNAME = 1,
OPT_ARG_EITHER = 2,
OPT_ARG_PAUSE = 3,
OPT_ARG_FILENAME = 4,
/* This *must* be the last value in this enum! */
OPT_ARG_ARRAY_SIZE = 4,
OPT_ARG_ARRAY_SIZE = 5,
};
struct directory_item {
@ -183,6 +198,8 @@ AST_APP_OPTIONS(directory_app_options, {
AST_APP_OPTION('m', OPT_SELECTFROMMENU),
AST_APP_OPTION('n', OPT_NOANSWER),
AST_APP_OPTION('a', OPT_ALIAS),
AST_APP_OPTION_ARG('c', OPT_CONFIG_FILE, OPT_ARG_FILENAME),
AST_APP_OPTION('s', OPT_SKIP),
});
static int compare(const char *text, const char *template)
@ -318,6 +335,9 @@ static int select_entry(struct ast_channel *chan, const char *dialcontext, const
if (ast_test_flag(flags, OPT_FROMVOICEMAIL)) {
/* We still want to set the exten though */
ast_channel_exten_set(chan, item->exten);
} else if (ast_test_flag(flags, OPT_SKIP)) {
/* Skip calling the extension, only set it in the channel variable. */
pbx_builtin_setvar_helper(chan, "DIRECTORY_EXTEN", item->exten);
} else if (ast_goto_if_exists(chan, S_OR(dialcontext, item->context), item->exten, 1)) {
ast_log(LOG_WARNING,
"Can't find extension '%s' in context '%s'. "
@ -396,7 +416,7 @@ static int select_item_menu(struct ast_channel *chan, struct directory_item **it
{
struct directory_item **block, *item;
int i, limit, res = 0;
char buf[9];
char buf[7+12]; /* INT_MIN has a length of 12 chars */
/* option p(n): cellphone pause option */
select_item_pause(chan, flags, opts);
@ -458,7 +478,7 @@ static int select_item_menu(struct ast_channel *chan, struct directory_item **it
AST_THREADSTORAGE(commonbuf);
static struct ast_config *realtime_directory(char *context)
static struct ast_config *realtime_directory(char *context, const char *filename)
{
struct ast_config *cfg;
struct ast_config *rtdata = NULL;
@ -475,14 +495,14 @@ static struct ast_config *realtime_directory(char *context)
}
/* Load flat file config. */
cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags);
cfg = ast_config_load(filename, config_flags);
if (!cfg) {
/* Loading config failed. */
ast_log(LOG_WARNING, "Loading config failed.\n");
return NULL;
} else if (cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", VOICEMAIL_CONFIG);
ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", filename);
return NULL;
}
@ -867,7 +887,9 @@ static int directory_exec(struct ast_channel *chan, const char *data)
if (args.options && ast_app_parse_options(directory_app_options, &flags, opts, args.options))
return -1;
if (!(cfg = realtime_directory(args.vmcontext))) {
cfg = realtime_directory(args.vmcontext, S_OR(opts[OPT_ARG_FILENAME], VOICEMAIL_CONFIG));
if (!cfg) {
ast_log(LOG_ERROR, "Unable to read the configuration data!\n");
return -1;
}

293
apps/app_dtmfstore.c Normal file
View File

@ -0,0 +1,293 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2021, Naveen Albert
*
* Naveen Albert <asterisk@phreaknet.org>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*! \file
*
* \brief Technology independent asynchronous DTMF collection
*
* \author Naveen Albert <asterisk@phreaknet.org>
*
* \ingroup functions
*
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/framehook.h"
#include "asterisk/app.h"
#include "asterisk/conversions.h"
/*** DOCUMENTATION
<application name="StoreDTMF" language="en_US">
<synopsis>
Stores DTMF digits transmitted or received on a channel.
</synopsis>
<syntax>
<parameter name="direction" required="true">
<para>Must be <literal>TX</literal> or <literal>RX</literal> to
store digits, or <literal>remove</literal> to disable.</para>
</parameter>
</syntax>
<description>
<para>The StoreDTMF function can be used to obtain digits sent in the
<literal>TX</literal> or <literal>RX</literal> direction of any channel.</para>
<para>The arguments are:</para>
<para><replaceable>var_name</replaceable>: Name of variable to which to append
digits.</para>
<para><replaceable>max_digits</replaceable>: The maximum number of digits to
store in the variable. Defaults to 0 (no maximum). After reading <literal>
maximum</literal> digits, no more digits will be stored.</para>
<example title="Store digits in CDR variable">
same => n,StoreDTMF(TX,CDR(digits))
</example>
<example title="Store up to 24 digits">
same => n,StoreDTMF(RX,testvar,24)
</example>
<example title="Disable digit collection">
same => n,StoreDTMF(remove)
</example>
</description>
</application>
***/
static char *app = "StoreDTMF";
/*! \brief Private data structure used with the function's datastore */
struct dtmf_store_data {
int framehook_id;
char *rx_var;
char *tx_var;
int maxdigits;
};
static void datastore_destroy_cb(void *data) {
struct dtmf_store_data *d;
d = data;
if (d) {
if (d->rx_var) {
ast_free(d->rx_var);
}
if (d->tx_var) {
ast_free(d->tx_var);
}
ast_free(data);
}
}
/*! \brief The channel datastore the function uses to store state */
static const struct ast_datastore_info dtmf_store_datastore = {
.type = "dtmf_store",
.destroy = datastore_destroy_cb
};
/*! \internal \brief Store digits tx/rx on the channel */
static int remove_dtmf_store(struct ast_channel *chan)
{
struct ast_datastore *datastore = NULL;
struct dtmf_store_data *data;
SCOPED_CHANNELLOCK(chan_lock, chan);
datastore = ast_channel_datastore_find(chan, &dtmf_store_datastore, NULL);
if (!datastore) {
ast_log(AST_LOG_WARNING, "Cannot remove StoreDTMF from %s: StoreDTMF not currently enabled\n",
ast_channel_name(chan));
return -1;
}
data = datastore->data;
if (ast_framehook_detach(chan, data->framehook_id)) {
ast_log(AST_LOG_WARNING, "Failed to remove StoreDTMF framehook from channel %s\n",
ast_channel_name(chan));
return -1;
}
if (ast_channel_datastore_remove(chan, datastore)) {
ast_log(AST_LOG_WARNING, "Failed to remove StoreDTMF datastore from channel %s\n",
ast_channel_name(chan));
return -1;
}
ast_datastore_free(datastore);
return 0;
}
/*! \brief Frame hook that is called to intercept digit/undigit */
static struct ast_frame *dtmf_store_framehook(struct ast_channel *chan,
struct ast_frame *f, enum ast_framehook_event event, void *data)
{
char currentdata[512];
char varnamesub[64];
char *varname = NULL;
struct dtmf_store_data *framedata = data;
int len;
if (!f || !framedata) {
return f;
}
if ((event != AST_FRAMEHOOK_EVENT_WRITE) && (event != AST_FRAMEHOOK_EVENT_READ)) {
return f;
}
if (f->frametype != AST_FRAME_DTMF_END) {
return f;
}
/* If this is DTMF then store the digits */
if (event == AST_FRAMEHOOK_EVENT_READ && framedata->rx_var) { /* coming from source */
varname = framedata->rx_var;
} else if (event == AST_FRAMEHOOK_EVENT_WRITE && framedata->tx_var) { /* going to source */
varname = framedata->tx_var;
}
if (!varname) {
return f;
}
sprintf(varnamesub, "${%s}", varname);
pbx_substitute_variables_helper(chan, varnamesub, currentdata, 511);
/* pbx_builtin_getvar_helper works for regular vars but not CDR vars */
if (ast_strlen_zero(currentdata)) { /* var doesn't exist yet */
ast_debug(3, "Creating new digit store: %s\n", varname);
}
len = strlen(currentdata);
if (framedata->maxdigits > 0 && len >= framedata->maxdigits) {
ast_debug(3, "Reached digit limit: %d\n", framedata->maxdigits);
remove_dtmf_store(chan); /* reached max digit count, stop now */
return f;
} else {
char newdata[len + 2]; /* one more char + terminator */
if (len > 0) {
ast_copy_string(newdata, currentdata, len + 2);
}
newdata[len] = (unsigned) f->subclass.integer;
newdata[len + 1] = '\0';
ast_debug(3, "Appending to digit store: now %s\n", newdata);
pbx_builtin_setvar_helper(chan, varname, newdata);
}
return f;
}
/*! \internal \brief Enable digit interception on the channel */
static int dtmfstore_exec(struct ast_channel *chan, const char *appdata)
{
struct ast_datastore *datastore;
struct dtmf_store_data *data;
static struct ast_framehook_interface digit_framehook_interface = {
.version = AST_FRAMEHOOK_INTERFACE_VERSION,
.event_cb = dtmf_store_framehook,
.disable_inheritance = 1,
};
char *parse = ast_strdupa(appdata);
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(direction);
AST_APP_ARG(varname);
AST_APP_ARG(maxdigits);
);
SCOPED_CHANNELLOCK(chan_lock, chan);
AST_STANDARD_APP_ARGS(args, parse);
if (ast_strlen_zero(appdata)) {
ast_log(AST_LOG_WARNING, "StoreDTMF requires an argument\n");
return -1;
}
if (!strcasecmp(args.direction, "remove")) {
return remove_dtmf_store(chan);
}
datastore = ast_channel_datastore_find(chan, &dtmf_store_datastore, NULL);
if (datastore) {
ast_log(AST_LOG_WARNING, "StoreDTMF already set on '%s'\n",
ast_channel_name(chan));
return 0;
}
datastore = ast_datastore_alloc(&dtmf_store_datastore, NULL);
if (!datastore) {
return -1;
}
data = ast_calloc(1, sizeof(*data));
if (!data) {
ast_datastore_free(datastore);
return -1;
}
digit_framehook_interface.data = data;
data->rx_var = NULL;
data->tx_var = NULL;
data->maxdigits = 0;
if (!strcasecmp(args.direction, "tx")) {
data->tx_var = ast_strdup(args.varname);
} else if (!strcasecmp(args.direction, "rx")) {
data->rx_var = ast_strdup(args.varname);
} else {
ast_log(LOG_ERROR, "Direction must be either RX or TX\n");
return -1;
}
if (!ast_strlen_zero(args.maxdigits)) {
if (ast_str_to_int(args.maxdigits,&(data->maxdigits))) {
ast_log(LOG_ERROR, "Invalid integer: %s\n", args.maxdigits);
return -1;
}
if (data->maxdigits < 0) {
ast_log(LOG_ERROR, "Invalid natural number: %d\n", data->maxdigits);
return -1;
} else if (data->maxdigits == 0) {
ast_log(LOG_WARNING, "No maximum digit count set\n");
}
}
data->framehook_id = ast_framehook_attach(chan, &digit_framehook_interface);
if (data->framehook_id < 0) {
ast_log(AST_LOG_WARNING, "Failed to attach StoreDTMF framehook to '%s'\n",
ast_channel_name(chan));
ast_datastore_free(datastore);
ast_free(data);
return -1;
}
datastore->data = data;
ast_channel_datastore_add(chan, datastore);
return 0;
}
static int unload_module(void)
{
return ast_unregister_application(app);
}
static int load_module(void)
{
return ast_register_application_xml(app, dtmfstore_exec);
}
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Technology independent async DTMF storage");

View File

@ -32,6 +32,7 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
@ -254,9 +255,9 @@ static struct ast_frame *gen_readframe(struct gen_state *state)
if (!(state->stream && (f = ast_readframe(state->stream)))) {
if (state->current) {
/* remove finished file from playlist */
AST_LIST_LOCK(&u->playlist);
AST_LIST_REMOVE_HEAD(&u->playlist, list);
AST_LIST_UNLOCK(&u->playlist);
AST_LIST_LOCK(&u->playlist);
AST_LIST_REMOVE_HEAD(&u->playlist, list);
AST_LIST_UNLOCK(&u->playlist);
/* add finished file to finishlist */
AST_LIST_LOCK(&u->finishlist);
AST_LIST_INSERT_TAIL(&u->finishlist, state->current, list);
@ -581,7 +582,7 @@ static int app_exec(struct ast_channel *chan, const char *data)
}
}
exit:
exit:
if (u->gen_active) {
ast_deactivate_generator(chan);
}
@ -622,21 +623,21 @@ static int app_exec(struct ast_channel *chan, const char *data)
}
static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
struct ast_iostream *eivr_events,
struct ast_iostream *eivr_commands,
struct ast_iostream *eivr_errors,
const struct ast_str *args, const struct ast_flags flags)
struct ast_iostream *eivr_events,
struct ast_iostream *eivr_commands,
struct ast_iostream *eivr_errors,
const struct ast_str *args, const struct ast_flags flags)
{
char input[1024];
struct playlist_entry *entry;
struct ast_frame *f;
int ms;
int exception;
int ready_fd;
int exception;
int ready_fd;
int waitfds[2];
int r;
struct ast_channel *rchan;
int res = -1;
struct ast_channel *rchan;
int res = -1;
int hangup_info_sent = 0;
waitfds[0] = ast_iostream_get_fd(eivr_commands);
@ -645,78 +646,78 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
while (1) {
if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE)) {
ast_chan_log(LOG_ERROR, chan, "Is a zombie\n");
break;
}
if (!hangup_info_sent && !(ast_test_flag(&flags, run_dead)) && ast_check_hangup(chan)) {
break;
}
if (!hangup_info_sent && !(ast_test_flag(&flags, run_dead)) && ast_check_hangup(chan)) {
if (ast_test_flag(&flags, ignore_hangup)) {
ast_verb(3, "Got check_hangup, but ignore_hangup set so sending 'I' command\n");
send_eivr_event(eivr_events, 'I', "HANGUP", chan);
hangup_info_sent = 1;
} else {
ast_verb(3, "Got check_hangup\n");
send_eivr_event(eivr_events, 'H', NULL, chan);
break;
ast_verb(3, "Got check_hangup\n");
send_eivr_event(eivr_events, 'H', NULL, chan);
break;
}
}
}
ready_fd = 0;
ms = 100;
errno = 0;
exception = 0;
ready_fd = 0;
ms = 100;
errno = 0;
exception = 0;
rchan = ast_waitfor_nandfds(&chan, 1, waitfds, (eivr_errors) ? 2 : 1, &exception, &ready_fd, &ms);
if (ast_channel_state(chan) == AST_STATE_UP && !AST_LIST_EMPTY(&u->finishlist)) {
AST_LIST_LOCK(&u->finishlist);
while ((entry = AST_LIST_REMOVE_HEAD(&u->finishlist, list))) {
send_eivr_event(eivr_events, 'F', entry->filename, chan);
ast_free(entry);
}
AST_LIST_UNLOCK(&u->finishlist);
}
if (ast_channel_state(chan) == AST_STATE_UP && !AST_LIST_EMPTY(&u->finishlist)) {
AST_LIST_LOCK(&u->finishlist);
while ((entry = AST_LIST_REMOVE_HEAD(&u->finishlist, list))) {
send_eivr_event(eivr_events, 'F', entry->filename, chan);
ast_free(entry);
}
AST_LIST_UNLOCK(&u->finishlist);
}
if (ast_channel_state(chan) == AST_STATE_UP && !(ast_check_hangup(chan)) && rchan) {
/* the channel has something */
f = ast_read(chan);
if (!f) {
ast_verb(3, "Returned no frame\n");
send_eivr_event(eivr_events, 'H', NULL, chan);
break;
}
if (f->frametype == AST_FRAME_DTMF) {
send_eivr_event(eivr_events, f->subclass.integer, NULL, chan);
if (u->option_autoclear) {
AST_LIST_LOCK(&u->playlist);
if (!u->abort_current_sound && !u->playing_silence) {
if (ast_channel_state(chan) == AST_STATE_UP && !(ast_check_hangup(chan)) && rchan) {
/* the channel has something */
f = ast_read(chan);
if (!f) {
ast_verb(3, "Returned no frame\n");
send_eivr_event(eivr_events, 'H', NULL, chan);
break;
}
if (f->frametype == AST_FRAME_DTMF) {
send_eivr_event(eivr_events, f->subclass.integer, NULL, chan);
if (u->option_autoclear) {
AST_LIST_LOCK(&u->playlist);
if (!u->abort_current_sound && !u->playing_silence) {
/* send interrupted file as T data */
if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'T', entry->filename, chan);
if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'T', entry->filename, chan);
ast_free(entry);
}
}
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'D', entry->filename, chan);
ast_free(entry);
}
if (!u->playing_silence)
u->abort_current_sound = 1;
AST_LIST_UNLOCK(&u->playlist);
}
} else if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) {
ast_verb(3, "Got AST_CONTROL_HANGUP\n");
send_eivr_event(eivr_events, 'H', NULL, chan);
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'D', entry->filename, chan);
ast_free(entry);
}
if (!u->playing_silence)
u->abort_current_sound = 1;
AST_LIST_UNLOCK(&u->playlist);
}
} else if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) {
ast_verb(3, "Got AST_CONTROL_HANGUP\n");
send_eivr_event(eivr_events, 'H', NULL, chan);
if (f->data.uint32) {
ast_channel_hangupcause_set(chan, f->data.uint32);
}
ast_frfree(f);
break;
}
ast_frfree(f);
} else if (ready_fd == waitfds[0]) {
if (exception) {
ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
break;
}
ast_frfree(f);
break;
}
ast_frfree(f);
} else if (ready_fd == waitfds[0]) {
if (exception) {
ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
break;
}
r = ast_iostream_gets(eivr_commands, input, sizeof(input));
if (r <= 0) {
@ -784,112 +785,112 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
u->abort_current_sound = 1;
}
AST_LIST_UNLOCK(&u->playlist);
} else if (input[0] == EIVR_CMD_SQUE) {
} else if (input[0] == EIVR_CMD_SQUE) {
if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) {
ast_chan_log(LOG_WARNING, chan, "Queue re'S'et called on unanswered channel\n");
send_eivr_event(eivr_events, 'Z', NULL, chan);
continue;
}
if (!ast_fileexists(&input[2], NULL, ast_channel_language(u->chan))) {
ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]);
send_eivr_event(eivr_events, 'Z', &input[2], chan);
} else {
AST_LIST_LOCK(&u->playlist);
if (!u->abort_current_sound && !u->playing_silence) {
if (!ast_fileexists(&input[2], NULL, ast_channel_language(u->chan))) {
ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]);
send_eivr_event(eivr_events, 'Z', &input[2], chan);
} else {
AST_LIST_LOCK(&u->playlist);
if (!u->abort_current_sound && !u->playing_silence) {
/* send interrupted file as T data */
if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'T', entry->filename, chan);
if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'T', entry->filename, chan);
ast_free(entry);
}
}
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'D', entry->filename, chan);
ast_free(entry);
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'D', entry->filename, chan);
ast_free(entry);
}
if (!u->playing_silence) {
u->abort_current_sound = 1;
if (!u->playing_silence) {
u->abort_current_sound = 1;
}
entry = make_entry(&input[2]);
if (entry) {
AST_LIST_INSERT_TAIL(&u->playlist, entry, list);
entry = make_entry(&input[2]);
if (entry) {
AST_LIST_INSERT_TAIL(&u->playlist, entry, list);
}
AST_LIST_UNLOCK(&u->playlist);
AST_LIST_UNLOCK(&u->playlist);
}
} else if (input[0] == EIVR_CMD_APND) {
} else if (input[0] == EIVR_CMD_APND) {
if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) {
ast_chan_log(LOG_WARNING, chan, "Queue 'A'ppend called on unanswered channel\n");
send_eivr_event(eivr_events, 'Z', NULL, chan);
continue;
}
if (!ast_fileexists(&input[2], NULL, ast_channel_language(u->chan))) {
ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]);
send_eivr_event(eivr_events, 'Z', &input[2], chan);
} else {
entry = make_entry(&input[2]);
if (entry) {
AST_LIST_LOCK(&u->playlist);
AST_LIST_INSERT_TAIL(&u->playlist, entry, list);
AST_LIST_UNLOCK(&u->playlist);
if (!ast_fileexists(&input[2], NULL, ast_channel_language(u->chan))) {
ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]);
send_eivr_event(eivr_events, 'Z', &input[2], chan);
} else {
entry = make_entry(&input[2]);
if (entry) {
AST_LIST_LOCK(&u->playlist);
AST_LIST_INSERT_TAIL(&u->playlist, entry, list);
AST_LIST_UNLOCK(&u->playlist);
}
}
} else if (input[0] == EIVR_CMD_GET) {
char response[2048];
}
} else if (input[0] == EIVR_CMD_GET) {
char response[2048];
ast_verb(4, "Retriving Variables from channel: %s\n", &input[2]);
ast_eivr_getvariable(chan, &input[2], response, sizeof(response));
send_eivr_event(eivr_events, 'G', response, chan);
} else if (input[0] == EIVR_CMD_SVAR) {
ast_eivr_getvariable(chan, &input[2], response, sizeof(response));
send_eivr_event(eivr_events, 'G', response, chan);
} else if (input[0] == EIVR_CMD_SVAR) {
ast_verb(4, "Setting Variables in channel: %s\n", &input[2]);
ast_eivr_setvariable(chan, &input[2]);
} else if (input[0] == EIVR_CMD_LOG) {
ast_chan_log(LOG_NOTICE, chan, "Log message from EIVR: %s\n", &input[2]);
} else if (input[0] == EIVR_CMD_XIT) {
ast_chan_log(LOG_NOTICE, chan, "Exiting: %s\n", &input[2]);
ast_eivr_setvariable(chan, &input[2]);
} else if (input[0] == EIVR_CMD_LOG) {
ast_chan_log(LOG_NOTICE, chan, "Log message from EIVR: %s\n", &input[2]);
} else if (input[0] == EIVR_CMD_XIT) {
ast_chan_log(LOG_NOTICE, chan, "Exiting: %s\n", &input[2]);
ast_chan_log(LOG_WARNING, chan, "e'X'it command is depricated, use 'E'xit instead\n");
res = 0;
break;
res = 0;
break;
} else if (input[0] == EIVR_CMD_EXIT) {
ast_chan_log(LOG_NOTICE, chan, "Exiting: %s\n", &input[2]);
send_eivr_event(eivr_events, 'E', NULL, chan);
res = 0;
break;
} else if (input[0] == EIVR_CMD_HGUP) {
ast_chan_log(LOG_NOTICE, chan, "Hanging up: %s\n", &input[2]);
send_eivr_event(eivr_events, 'H', NULL, chan);
break;
} else if (input[0] == EIVR_CMD_OPT) {
ast_chan_log(LOG_NOTICE, chan, "Exiting: %s\n", &input[2]);
send_eivr_event(eivr_events, 'E', NULL, chan);
res = 0;
break;
} else if (input[0] == EIVR_CMD_HGUP) {
ast_chan_log(LOG_NOTICE, chan, "Hanging up: %s\n", &input[2]);
send_eivr_event(eivr_events, 'H', NULL, chan);
break;
} else if (input[0] == EIVR_CMD_OPT) {
if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) {
ast_chan_log(LOG_WARNING, chan, "Option called on unanswered channel\n");
send_eivr_event(eivr_events, 'Z', NULL, chan);
continue;
}
if (!strcasecmp(&input[2], "autoclear"))
u->option_autoclear = 1;
else if (!strcasecmp(&input[2], "noautoclear"))
u->option_autoclear = 0;
else
ast_chan_log(LOG_WARNING, chan, "Unknown option requested: %s\n", &input[2]);
}
} else if (ready_fd == waitfds[1]) {
if (exception) {
ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
break;
}
r = ast_iostream_gets(eivr_errors, input, sizeof(input));
if (r > 0) {
ast_chan_log(LOG_NOTICE, chan, "stderr: %s\n", ast_strip(input));
} else if (r == 0) {
ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
break;
if (!strcasecmp(&input[2], "autoclear"))
u->option_autoclear = 1;
else if (!strcasecmp(&input[2], "noautoclear"))
u->option_autoclear = 0;
else
ast_chan_log(LOG_WARNING, chan, "Unknown option requested: %s\n", &input[2]);
}
} else if (ready_fd == waitfds[1]) {
if (exception) {
ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
break;
}
} else if ((ready_fd < 0) && ms) {
if (errno == 0 || errno == EINTR)
continue;
ast_chan_log(LOG_ERROR, chan, "Wait failed (%s)\n", strerror(errno));
break;
}
}
r = ast_iostream_gets(eivr_errors, input, sizeof(input));
if (r > 0) {
ast_chan_log(LOG_NOTICE, chan, "stderr: %s\n", ast_strip(input));
} else if (r == 0) {
ast_chan_log(LOG_ERROR, chan, "Child process went away\n");
break;
}
} else if ((ready_fd < 0) && ms) {
if (errno == 0 || errno == EINTR)
continue;
ast_chan_log(LOG_ERROR, chan, "Wait failed (%s)\n", strerror(errno));
break;
}
}
return res;
}

View File

@ -13,11 +13,13 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<depend>spandsp</depend>
<conflict>res_fax</conflict>
<defaultenabled>no</defaultenabled>
<support_level>deprecated</support_level>
<replacement>res_fax</replacement>
<deprecated_in>16</deprecated_in>
<removed_in>19</removed_in>
***/
/* Needed for spandsp headers */

View File

@ -37,6 +37,7 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
@ -433,7 +434,7 @@ static int festival_exec(struct ast_channel *chan, const char *vdata)
}
readcache = 0;
writecache = 0;
if (strlen(cachedir) + strlen(MD5Hex) + 1 <= MAXFESTLEN && (usecache == -1)) {
if (strlen(cachedir) + sizeof(MD5Hex) + 1 <= MAXFESTLEN && (usecache == -1)) {
snprintf(cachefile, sizeof(cachefile), "%s/%s", cachedir, MD5Hex);
fdesc = open(cachefile, O_RDWR);
if (fdesc == -1) {

View File

@ -2,7 +2,7 @@
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 1999 - 2005, Anthony Minessale anthmct@yahoo.com
* Development of this app Sponsered/Funded by TAAN Softworks Corp
* Development of this app Sponsored/Funded by TAAN Softworks Corp
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact

View File

@ -27,6 +27,7 @@
/*** MODULEINFO
<depend>res_adsi</depend>
<defaultenabled>no</defaultenabled>
<support_level>deprecated</support_level>
***/

View File

@ -28,7 +28,10 @@
*/
/*** MODULEINFO
<support_level>deprecated</support_level>
<defaultenabled>no</defaultenabled>
<support_level>deprecated</support_level>
<deprecated_in>16</deprecated_in>
<removed_in>19</removed_in>
***/
#include "asterisk.h"

View File

@ -26,7 +26,10 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>deprecated</support_level>
<deprecated_in>16</deprecated_in>
<removed_in>19</removed_in>
***/
#include "asterisk.h"

View File

@ -37,6 +37,7 @@
/*** MODULEINFO
<depend>jack</depend>
<depend>resample</depend>
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
@ -615,8 +616,6 @@ static int queue_voice_frame(struct jack_data *jack_data, struct ast_frame *f)
* Read data from the input ringbuffer, which is the properly resampled audio
* that was read from the jack input port. Write it to the channel in 20 ms frames,
* or fill up an output frame instead if one is provided.
*
* \return Nothing.
*/
static void handle_jack_audio(struct ast_channel *chan, struct jack_data *jack_data,
struct ast_frame *out_frame)

View File

@ -29,6 +29,8 @@
<defaultenabled>no</defaultenabled>
<support_level>deprecated</support_level>
<replacement>app_stack (GoSub)</replacement>
<deprecated_in>16</deprecated_in>
<removed_in>21</removed_in>
***/
#include "asterisk.h"
@ -73,7 +75,7 @@
of nesting (macro calling macro calling macro, etc.); It may be possible that stack-intensive
applications in deeply nested macros could cause asterisk to crash earlier than this limit.
It is advised that if you need to deeply nest macro calls, that you use the Gosub application
(now allows arguments like a Macro) with explict Return() calls instead.</para></warning>
(now allows arguments like a Macro) with explicit Return() calls instead.</para></warning>
<warning><para>Use of the application <literal>WaitExten</literal> within a macro will not function
as expected. Please use the <literal>Read</literal> application in order to read DTMF from a channel
currently executing a macro.</para></warning>

View File

@ -43,6 +43,8 @@
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
<replacement>app_confbridge</replacement>
<deprecated_in>19</deprecated_in>
<removed_in>21</removed_in>
***/
#include "asterisk.h"
@ -1334,7 +1336,7 @@ static struct ast_json *status_to_json(int on)
* \brief Generate a stasis message associated with a meetme event
* \since 12.0.0
*
* \param meetme_confere The conference responsible for generating this message
* \param meetme_conference The conference responsible for generating this message
* \param chan The channel involved in the message (NULL allowed)
* \param user The conference user involved in the message (NULL allowed)
* \param message_type the type the stasis message being generated
@ -2834,7 +2836,7 @@ static void meetme_menu_normal(enum menu_modes *menu_mode, int *dtmf, struct ast
}
/*! \internal
* \brief Processes menu options for the adminstrator menu (accessible through the 's' option for app_meetme)
* \brief Processes menu options for the administrator menu (accessible through the 's' option for app_meetme)
*
* \param menu_mode a pointer to the currently active menu_mode.
* \param dtmf a pointer to the dtmf value currently being processed against the menu.
@ -2961,7 +2963,8 @@ static void meetme_menu_admin(enum menu_modes *menu_mode, int *dtmf, struct ast_
* \param confflags flags used by conf for various options
* \param chan ast_channel belonging to the user who called the menu
* \param user which meetme conference user invoked the menu
* \param recordingtmp character buffer which may hold the name of the conference recording file
* \param recordingtmp, recordingtmp_size character buffer which may hold the name of the conference recording file
* \param cap_slin
*/
static void meetme_menu_admin_extended(enum menu_modes *menu_mode, int *dtmf,
struct ast_conference *conf, struct ast_flags64 *confflags, struct ast_channel *chan,
@ -3148,7 +3151,8 @@ static void meetme_menu_admin_extended(enum menu_modes *menu_mode, int *dtmf,
* \param confflags flags used by conf for various options
* \param chan ast_channel belonging to the user who called the menu
* \param user which meetme conference user invoked the menu
* \param recordingtmp character buffer which may hold the name of the conference recording file
* \param recordingtmp,recordingtmp_size character buffer which may hold the name of the conference recording file
* \param cap_slin
*/
static void meetme_menu(enum menu_modes *menu_mode, int *dtmf,
struct ast_conference *conf, struct ast_flags64 *confflags, struct ast_channel *chan,
@ -5219,7 +5223,7 @@ static int user_chan_cb(void *obj, void *args, int flags)
return 0;
}
/*! \brief The MeetMeadmin application
/*! \brief The MeetMeAdmin application
MeetMeAdmin(confno, command, caller) */
static int admin_exec(struct ast_channel *chan, const char *data) {

362
apps/app_mf.c Normal file
View File

@ -0,0 +1,362 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2021, Naveen Albert
*
* Naveen Albert <asterisk@phreaknet.org>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*! \file
*
* \brief App to send MF digits
*
* \author Naveen Albert <asterisk@phreaknet.org>
*
* \ingroup applications
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/channel.h"
#include "asterisk/indications.h"
/*** DOCUMENTATION
<application name="SendMF" language="en_US">
<synopsis>
Sends arbitrary MF digits
</synopsis>
<syntax>
<parameter name="digits" required="true">
<para>List of digits 0-9,*#ABC to send; also f or F for a flash-hook
if the channel supports flash-hook, and w or W for a wink if the channel
supports wink.</para>
<para>Key pulse and start digits are not included automatically.
* is used for KP, # for ST, A for STP, B for ST2P, and C for ST3P.</para>
</parameter>
<parameter name="timeout_ms" required="false">
<para>Amount of time to wait in ms between tones. (defaults to 50ms).</para>
</parameter>
<parameter name="duration_ms" required="false">
<para>Duration of each numeric digit (defaults to 55ms).</para>
</parameter>
<parameter name="duration_ms_kp" required="false">
<para>Duration of KP digits (defaults to 120ms).</para>
</parameter>
<parameter name="duration_ms_st" required="false">
<para>Duration of ST, STP, ST2P, and ST3P digits (defaults to 65ms).</para>
</parameter>
<parameter name="channel" required="false">
<para>Channel where digits will be played</para>
</parameter>
</syntax>
<description>
<para>It will send all digits or terminate if it encounters an error.</para>
</description>
<see-also>
<ref type="application">SendDTMF</ref>
</see-also>
</application>
<manager name="PlayMF" language="en_US">
<synopsis>
Play MF signal on a specific channel.
</synopsis>
<syntax>
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
<parameter name="Channel" required="true">
<para>Channel name to send digit to.</para>
</parameter>
<parameter name="Digit" required="true">
<para>The MF digit to play.</para>
</parameter>
<parameter name="Duration" required="false">
<para>The duration, in milliseconds, of the digit to be played.</para>
</parameter>
</syntax>
<description>
<para>Plays an MF digit on the specified channel.</para>
</description>
</manager>
***/
static const char sendmf_name[] = "SendMF";
#define DEFAULT_EMULATE_MF_DURATION 35
#define MF_BETWEEN_MS 50
#define MF_DURATION 55
#define MF_KP_DURATION 120
#define MF_ST_DURATION 65
static int senddigit_mf_begin(struct ast_channel *chan, char digit)
{
static const char * const mf_tones[] = {
"1300+1500", /* 0 */
"700+900", /* 1 */
"700+1100", /* 2 */
"900+1100", /* 3 */
"700+1300", /* 4 */
"900+1300", /* 5 */
"1100+1300", /* 6 */
"700+1500", /* 7 */
"900+1500", /* 8 */
"1100+1500", /* 9 */
"1100+1700", /* * (KP) */
"1500+1700", /* # (ST) */
"900+1700", /* A (STP) */
"1300+1700", /* B (ST2P) */
"700+1700" /* C (ST3P) */
};
if (digit >= '0' && digit <='9') {
ast_playtones_start(chan, 0, mf_tones[digit-'0'], 0);
} else if (digit == '*') {
ast_playtones_start(chan, 0, mf_tones[10], 0);
} else if (digit == '#') {
ast_playtones_start(chan, 0, mf_tones[11], 0);
} else if (digit == 'A') {
ast_playtones_start(chan, 0, mf_tones[12], 0);
} else if (digit == 'B') {
ast_playtones_start(chan, 0, mf_tones[13], 0);
} else if (digit == 'C') {
ast_playtones_start(chan, 0, mf_tones[14], 0);
} else {
/* not handled */
ast_log(LOG_WARNING, "Unable to generate MF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
}
return 0;
}
static int senddigit_mf_end(struct ast_channel *chan)
{
if (ast_channel_generator(chan)) {
ast_playtones_stop(chan);
return 0;
}
return -1;
}
static int mysleep(struct ast_channel *chan, int ms, int is_external)
{
return is_external ? usleep(ms * 1000) : ast_safe_sleep(chan, ms);
}
static int senddigit_mf(struct ast_channel *chan, char digit, unsigned int duration,
unsigned int durationkp, unsigned int durationst, int is_external)
{
if (duration < DEFAULT_EMULATE_MF_DURATION) {
duration = DEFAULT_EMULATE_MF_DURATION;
}
if (ast_channel_tech(chan)->send_digit_begin) {
if (digit == '*') {
duration = durationkp;
} else if (digit == '#' || digit == 'A' || digit == 'B' || digit == 'C') {
duration = durationst;
}
senddigit_mf_begin(chan, digit);
mysleep(chan, duration, is_external);
}
return senddigit_mf_end(chan);
}
static int mf_stream(struct ast_channel *chan, const char *digits, int between, unsigned int duration,
unsigned int durationkp, unsigned int durationst, int is_external)
{
const char *ptr;
int res;
struct ast_silence_generator *silgen = NULL;
if (!between) {
between = 100;
}
/* Need a quiet time before sending digits. */
if (ast_opt_transmit_silence) {
silgen = ast_channel_start_silence_generator(chan);
}
res = mysleep(chan, 100, is_external);
if (res) {
goto mf_stream_cleanup;
}
for (ptr = digits; *ptr; ptr++) {
if (strchr("0123456789*#ABCwWfF", *ptr)) {
if (*ptr == 'f' || *ptr == 'F') {
/* ignore return values if not supported by channel */
ast_indicate(chan, AST_CONTROL_FLASH);
} else if (*ptr == 'w' || *ptr == 'W') {
/* ignore return values if not supported by channel */
ast_indicate(chan, AST_CONTROL_WINK);
} else {
/* Character represents valid MF */
senddigit_mf(chan, *ptr, duration, durationkp, durationst, is_external);
}
/* pause between digits */
/* The DSP code in Asterisk does not currently properly receive repeated tones
if no audio is sent in the middle. Simply sending audio (even 0 Hz)
works around this limitation and guarantees the correct behavior.
*/
ast_playtones_start(chan, 0, "0", 0);
res = mysleep(chan, between, is_external);
senddigit_mf_end(chan);
if (res) {
break;
}
} else {
ast_log(LOG_WARNING, "Illegal MF character '%c' in string. (0-9*#ABCwWfF allowed)\n", *ptr);
}
}
mf_stream_cleanup:
if (silgen) {
ast_channel_stop_silence_generator(chan, silgen);
}
return res;
}
static int sendmf_exec(struct ast_channel *chan, const char *vdata)
{
int res;
char *data;
int dinterval = 0, duration = 0, durationkp = 0, durationst = 0;
struct ast_channel *chan_found = NULL;
struct ast_channel *chan_dest = chan;
struct ast_channel *chan_autoservice = NULL;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(digits);
AST_APP_ARG(dinterval);
AST_APP_ARG(duration);
AST_APP_ARG(durationkp);
AST_APP_ARG(durationst);
AST_APP_ARG(channel);
);
if (ast_strlen_zero(vdata)) {
ast_log(LOG_WARNING, "SendMF requires an argument\n");
return 0;
}
data = ast_strdupa(vdata);
AST_STANDARD_APP_ARGS(args, data);
if (ast_strlen_zero(args.digits)) {
ast_log(LOG_WARNING, "The digits argument is required (0-9,*#ABC,wf)\n");
return 0;
}
if (!ast_strlen_zero(args.dinterval)) {
ast_app_parse_timelen(args.dinterval, &dinterval, TIMELEN_MILLISECONDS);
}
if (!ast_strlen_zero(args.duration)) {
ast_app_parse_timelen(args.duration, &duration, TIMELEN_MILLISECONDS);
}
if (!ast_strlen_zero(args.durationkp)) {
ast_app_parse_timelen(args.durationkp, &durationkp, TIMELEN_MILLISECONDS);
}
if (!ast_strlen_zero(args.durationst)) {
ast_app_parse_timelen(args.durationst, &durationst, TIMELEN_MILLISECONDS);
}
if (!ast_strlen_zero(args.channel)) {
chan_found = ast_channel_get_by_name(args.channel);
if (!chan_found) {
ast_log(LOG_WARNING, "No such channel: %s\n", args.channel);
return 0;
}
chan_dest = chan_found;
if (chan_found != chan) {
chan_autoservice = chan;
}
}
if (chan_autoservice && ast_autoservice_start(chan_autoservice)) {
ast_channel_cleanup(chan_found);
return -1;
}
res = mf_stream(chan_dest, args.digits, dinterval <= 0 ? MF_BETWEEN_MS : dinterval,
duration <= 0 ? MF_DURATION : duration, durationkp <= 0 ? MF_KP_DURATION : durationkp,
durationst <= 0 ? MF_ST_DURATION : durationst, 0);
if (chan_autoservice && ast_autoservice_stop(chan_autoservice)) {
res = -1;
}
ast_channel_cleanup(chan_found);
return chan_autoservice ? 0 : res;
}
static int manager_play_mf(struct mansession *s, const struct message *m)
{
const char *channel = astman_get_header(m, "Channel");
const char *digit = astman_get_header(m, "Digit");
const char *duration = astman_get_header(m, "Duration");
struct ast_channel *chan;
unsigned int duration_ms = MF_DURATION;
if (!(chan = ast_channel_get_by_name(channel))) {
astman_send_error(s, m, "Channel not found");
return 0;
}
if (ast_strlen_zero(digit)) {
astman_send_error(s, m, "No digit specified");
chan = ast_channel_unref(chan);
return 0;
}
/* Override default duration with KP or ST-specific default durations */
if (!strcmp(digit, "*"))
duration_ms = MF_KP_DURATION;
if (!strcmp(digit, "#") || !strcmp(digit, "A") || !strcmp(digit, "B") || !strcmp(digit, "C"))
duration_ms = MF_ST_DURATION;
if (!ast_strlen_zero(duration) && (sscanf(duration, "%30u", &duration_ms) != 1)) {
astman_send_error(s, m, "Could not convert Duration parameter");
chan = ast_channel_unref(chan);
return 0;
}
senddigit_mf(chan, *digit, duration_ms, duration_ms, duration_ms, 1);
chan = ast_channel_unref(chan);
astman_send_ack(s, m, "MF successfully queued");
return 0;
}
static int unload_module(void)
{
int res;
res = ast_unregister_application(sendmf_name);
res |= ast_manager_unregister("PlayMF");
return res;
}
static int load_module(void)
{
int res;
res = ast_manager_register_xml("PlayMF", EVENT_FLAG_CALL, manager_play_mf);
res |= ast_register_application_xml(sendmf_name, sendmf_exec);
return res;
}
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Send MF digits Application");

View File

@ -40,19 +40,29 @@
/*** DOCUMENTATION
<application name="Milliwatt" language="en_US">
<synopsis>
Generate a Constant 1004Hz tone at 0dbm (mu-law).
Generates a 1004 Hz test tone at 0dbm (mu-law).
</synopsis>
<syntax>
<parameter name="options">
<optionlist>
<option name="m">
<para>Generate a 1004 Hz Milliwatt test tone at 0dbm, with a
1 second silent interval. This option must be specified
if you are using this for a milliwatt test line.</para>
</option>
<option name="o">
<para>Generate the tone at 1000Hz like previous version.</para>
<para>Generate a constant tone at 1000 Hz like previous version.</para>
</option>
</optionlist>
</parameter>
</syntax>
<description>
<para>Previous versions of this application generated the tone at 1000Hz. If for
<para>Generates a 1004 Hz test tone.</para>
<para>By default, this application does not provide a Milliwatt test tone. It simply
plays a 1004 Hz tone, which is not suitable for performing a milliwatt test.
The <literal>m</literal> option should be used so that a real Milliwatt test tone
is provided. This will include a 1 second silent interval every 10 seconds.</para>
<para>Previous versions of this application generated a constant tone at 1000 Hz. If for
some reason you would prefer that behavior, supply the <literal>o</literal> option to get the
old behavior.</para>
</description>
@ -155,8 +165,11 @@ static int milliwatt_exec(struct ast_channel *chan, const char *data)
if (!ast_strlen_zero(options) && strchr(options, 'o')) {
return old_milliwatt_exec(chan);
}
res = ast_playtones_start(chan, 23255, "1004/1000", 0);
if (!ast_strlen_zero(options) && strchr(options, 'm')) {
res = ast_playtones_start(chan, 23255, "1004/9000,0/1000", 0);
} else {
res = ast_playtones_start(chan, 23255, "1004/1000", 0);
}
while (!res) {
res = ast_safe_sleep(chan, 10000);

View File

@ -26,7 +26,7 @@
* based on the Comedian Mail voicemail system (app_voicemail.c).
*
* \par See also
* \arg \ref Config_minivm_examples
* \arg \ref minivm.conf "Config_minivm"
* \arg \ref App_minivm
*
* \ingroup applications
@ -78,16 +78,16 @@
* - English, GB en_gb
*
* \par See also
* \arg \ref Config_minivm
* \arg \ref minivm.conf "Config_minivm"
* \arg \ref Config_minivm_examples
* \arg \ref Minivm_directories
* \arg \ref app_minivm.c
* \arg Comedian mail: app_voicemail.c
* \arg \ref descrip_minivm_accmess
* \arg \ref descrip_minivm_greet
* \arg \ref descrip_minivm_record
* \arg \ref descrip_minivm_delete
* \arg \ref descrip_minivm_notify
* \arg \ref minivm_accmess_exec
* \arg \ref minivm_greet_exec
* \arg \ref minivm_record_exec
* \arg \ref minivm_delete_exec
* \arg \ref minivm_notify_exec
*
* \arg \ref App_minivm_todo
*/
@ -113,6 +113,13 @@
* Back: \ref App_minivm
*/
/*!
* \page minivm.conf minivm.conf
* \verbinclude minivm.conf.sample
*
* Back: \ref App_minivm
*/
/*! \page Config_minivm_examples Example dialplan for Mini-Voicemail
* \section Example dialplan scripts for Mini-Voicemail
* \verbinclude extensions_minivm.conf.sample
@ -141,6 +148,7 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
@ -154,7 +162,6 @@
#include <dirent.h>
#include <locale.h>
#include "asterisk/paths.h" /* use various paths */
#include "asterisk/lock.h"
#include "asterisk/file.h"
@ -535,8 +542,6 @@
#define SENDMAIL "/usr/sbin/sendmail -t"
#define SOUND_INTRO "vm-intro"
#define B64_BASEMAXINLINE 256 /*!< Buffer size for Base 64 attachment encoding */
#define B64_BASELINELEN 72 /*!< Line length for Base 64 endoded messages */
#define EOL "\r\n"
#define MAX_DATETIME_FORMAT 512
@ -652,15 +657,6 @@ struct leave_vm_options {
signed char record_gain;
};
/*! \brief Structure for base64 encoding */
struct b64_baseio {
int iocp;
int iolen;
int linelength;
int ateof;
unsigned char iobuf[B64_BASEMAXINLINE];
};
/*! \brief Voicemail time zones */
struct minivm_zone {
char name[80]; /*!< Name of this time zone */
@ -846,134 +842,6 @@ static void message_destroy_list(void)
AST_LIST_UNLOCK(&message_templates);
}
/*!\internal
* \brief read buffer from file (base64 conversion) */
static int b64_inbuf(struct b64_baseio *bio, FILE *fi)
{
int l;
if (bio->ateof)
return 0;
if ((l = fread(bio->iobuf, 1, B64_BASEMAXINLINE, fi)) != B64_BASEMAXINLINE) {
bio->ateof = 1;
if (l == 0) {
/* Assume EOF */
return 0;
}
}
bio->iolen = l;
bio->iocp = 0;
return 1;
}
/*!\internal
* \brief read character from file to buffer (base64 conversion) */
static int b64_inchar(struct b64_baseio *bio, FILE *fi)
{
if (bio->iocp >= bio->iolen) {
if (!b64_inbuf(bio, fi))
return EOF;
}
return bio->iobuf[bio->iocp++];
}
/*!\internal
* \brief write buffer to file (base64 conversion) */
static int b64_ochar(struct b64_baseio *bio, int c, FILE *so)
{
if (bio->linelength >= B64_BASELINELEN) {
if (fputs(EOL,so) == EOF)
return -1;
bio->linelength= 0;
}
if (putc(((unsigned char) c), so) == EOF)
return -1;
bio->linelength++;
return 1;
}
/*!\internal
* \brief Encode file to base64 encoding for email attachment (base64 conversion) */
static int base_encode(char *filename, FILE *so)
{
unsigned char dtable[B64_BASEMAXINLINE];
int i,hiteof= 0;
FILE *fi;
struct b64_baseio bio;
memset(&bio, 0, sizeof(bio));
bio.iocp = B64_BASEMAXINLINE;
if (!(fi = fopen(filename, "rb"))) {
ast_log(LOG_WARNING, "Failed to open file: %s: %s\n", filename, strerror(errno));
return -1;
}
for (i= 0; i<9; i++) {
dtable[i]= 'A'+i;
dtable[i+9]= 'J'+i;
dtable[26+i]= 'a'+i;
dtable[26+i+9]= 'j'+i;
}
for (i= 0; i < 8; i++) {
dtable[i+18]= 'S'+i;
dtable[26+i+18]= 's'+i;
}
for (i= 0; i < 10; i++) {
dtable[52+i]= '0'+i;
}
dtable[62]= '+';
dtable[63]= '/';
while (!hiteof){
unsigned char igroup[3], ogroup[4];
int c,n;
igroup[0]= igroup[1]= igroup[2]= 0;
for (n= 0; n < 3; n++) {
if ((c = b64_inchar(&bio, fi)) == EOF) {
hiteof= 1;
break;
}
igroup[n]= (unsigned char)c;
}
if (n> 0) {
ogroup[0]= dtable[igroup[0]>>2];
ogroup[1]= dtable[((igroup[0]&3)<<4) | (igroup[1]>>4)];
ogroup[2]= dtable[((igroup[1]&0xF)<<2) | (igroup[2]>>6)];
ogroup[3]= dtable[igroup[2]&0x3F];
if (n<3) {
ogroup[3]= '=';
if (n<2)
ogroup[2]= '=';
}
for (i= 0;i<4;i++)
b64_ochar(&bio, ogroup[i], so);
}
}
/* Put end of line - line feed */
if (fputs(EOL, so) == EOF)
return 0;
fclose(fi);
return 1;
}
static int get_date(char *s, int len)
{
struct ast_tm tm;
@ -1474,7 +1342,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
fprintf(p, "Content-Description: Voicemail sound attachment.\n");
fprintf(p, "Content-Disposition: attachment; filename=\"voicemail%s.%s\"\n\n", counter ? counter : "", format);
base_encode(fname, p);
ast_base64_encode_file_path(fname, p, EOL);
fprintf(p, "\n\n--%s--\n.\n", bound);
}
fclose(p);
@ -1737,7 +1605,7 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
}
return cmd;
default:
/* If the caller is an ouside caller, and the review option is enabled,
/* If the caller is an outside caller, and the review option is enabled,
allow them to review the message, but let the owner of the box review
their OGM's */
if (outsidecaller && !ast_test_flag(vmu, MVM_REVIEW))
@ -2827,7 +2695,7 @@ static int apply_general_options(struct ast_variable *var)
} else if (!strcmp(var->name, "externnotify")) {
/* External voicemail notify application */
ast_copy_string(global_externnotify, var->value, sizeof(global_externnotify));
} else if (!strcmp(var->name, "silencetreshold")) {
} else if (!strcmp(var->name, "silencethreshold") || !strcmp(var->name, "silencetreshold")) {
/* Silence treshold */
global_silencethreshold = atoi(var->value);
} else if (!strcmp(var->name, "maxmessage")) {
@ -2956,6 +2824,8 @@ static int load_config(int reload)
ast_copy_string(template->fromaddress, chanvar, sizeof(template->fromaddress));
if ((chanvar = ast_variable_retrieve(cfg, "general", "emailaaddress")))
ast_copy_string(template->serveremail, chanvar, sizeof(template->serveremail));
if ((chanvar = ast_variable_retrieve(cfg, "general", "emailaddress")))
ast_copy_string(template->serveremail, chanvar, sizeof(template->serveremail));
if ((chanvar = ast_variable_retrieve(cfg, "general", "emailcharset")))
ast_copy_string(template->charset, chanvar, sizeof(template->charset));
if ((chanvar = ast_variable_retrieve(cfg, "general", "emailsubject")))

View File

@ -51,6 +51,8 @@
#include "asterisk/channel.h"
#include "asterisk/autochan.h"
#include "asterisk/manager.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/callerid.h"
#include "asterisk/mod_format.h"
#include "asterisk/linkedlists.h"
@ -295,6 +297,51 @@
</parameter>
</syntax>
</function>
<managerEvent language="en_US" name="MixMonitorStart">
<managerEventInstance class="EVENT_FLAG_CALL">
<synopsis>Raised when monitoring has started on a channel.</synopsis>
<syntax>
<channel_snapshot/>
</syntax>
<see-also>
<ref type="managerEvent">MixMonitorStop</ref>
<ref type="application">MixMonitor</ref>
<ref type="manager">MixMonitor</ref>
</see-also>
</managerEventInstance>
</managerEvent>
<managerEvent language="en_US" name="MixMonitorStop">
<managerEventInstance class="EVENT_FLAG_CALL">
<synopsis>Raised when monitoring has stopped on a channel.</synopsis>
<syntax>
<channel_snapshot/>
</syntax>
<see-also>
<ref type="managerEvent">MixMonitorStart</ref>
<ref type="application">StopMixMonitor</ref>
<ref type="manager">StopMixMonitor</ref>
</see-also>
</managerEventInstance>
</managerEvent>
<managerEvent language="en_US" name="MixMonitorMute">
<managerEventInstance class="EVENT_FLAG_CALL">
<synopsis>Raised when monitoring is muted or unmuted on a channel.</synopsis>
<syntax>
<channel_snapshot/>
<parameter name="Direction">
<para>Which part of the recording was muted or unmuted: read, write or both
(from channel, to channel or both directions).</para>
</parameter>
<parameter name="State">
<para>If the monitoring was muted or unmuted: 1 when muted, 0 when unmuted.</para>
</parameter>
</syntax>
<see-also>
<ref type="manager">MixMonitorMute</ref>
</see-also>
</managerEventInstance>
</managerEvent>
***/
@ -584,6 +631,7 @@ static void mixmonitor_free(struct mixmonitor *mixmonitor)
* \brief Copies the mixmonitor to all voicemail recipients
* \param mixmonitor The mixmonitor that needs to forward its file to recipients
* \param ext Format of the file that was saved
* \param filename
*/
static void copy_to_voicemail(struct mixmonitor *mixmonitor, const char *ext, const char *filename)
{
@ -865,6 +913,24 @@ static int setup_mixmonitor_ds(struct mixmonitor *mixmonitor, struct ast_channel
return 0;
}
static void mixmonitor_ds_remove_and_free(struct ast_channel *chan, const char *datastore_id)
{
struct ast_datastore *datastore;
ast_channel_lock(chan);
datastore = ast_channel_datastore_find(chan, &mixmonitor_ds_info, datastore_id);
/*
* Currently the one place this function is called from guarantees a
* datastore is present, thus return checks can be avoided here.
*/
ast_channel_datastore_remove(chan, datastore);
ast_datastore_free(datastore);
ast_channel_unlock(chan);
}
static int launch_monitor_thread(struct ast_channel *chan, const char *filename,
unsigned int flags, int readvol, int writevol,
const char *post_process, const char *filename_write,
@ -940,7 +1006,6 @@ static int launch_monitor_thread(struct ast_channel *chan, const char *filename,
pbx_builtin_setvar_helper(chan, uid_channel_var, datastore_id);
}
}
ast_free(datastore_id);
mixmonitor->name = ast_strdup(ast_channel_name(chan));
@ -990,12 +1055,16 @@ static int launch_monitor_thread(struct ast_channel *chan, const char *filename,
if (startmon(chan, &mixmonitor->audiohook)) {
ast_log(LOG_WARNING, "Unable to add '%s' spy to channel '%s'\n",
mixmonitor_spy_type, ast_channel_name(chan));
mixmonitor_ds_remove_and_free(chan, datastore_id);
ast_free(datastore_id);
ast_autochan_destroy(mixmonitor->autochan);
ast_audiohook_destroy(&mixmonitor->audiohook);
mixmonitor_free(mixmonitor);
return -1;
}
ast_free(datastore_id);
/* reference be released at mixmonitor destruction */
mixmonitor->callid = ast_read_threadstorage_callid();
@ -1056,6 +1125,7 @@ static int mixmonitor_exec(struct ast_channel *chan, const char *data)
struct ast_flags flags = { 0 };
char *recipients = NULL;
char *parse;
RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(filename);
AST_APP_ARG(options);
@ -1176,6 +1246,12 @@ static int mixmonitor_exec(struct ast_channel *chan, const char *data)
ast_module_unref(ast_module_info->self);
}
message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan),
ast_channel_mixmonitor_start_type(), NULL);
if (message) {
stasis_publish(ast_channel_topic(chan), message);
}
return 0;
}
@ -1185,6 +1261,7 @@ static int stop_mixmonitor_full(struct ast_channel *chan, const char *data)
char *parse = "";
struct mixmonitor_ds *mixmonitor_ds;
const char *beep_id = NULL;
RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(mixmonid);
@ -1242,6 +1319,13 @@ static int stop_mixmonitor_full(struct ast_channel *chan, const char *data)
ast_beep_stop(chan, beep_id);
}
message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan),
ast_channel_mixmonitor_stop_type(),
NULL);
if (message) {
stasis_publish(ast_channel_topic(chan), message);
}
return 0;
}
@ -1319,6 +1403,50 @@ static char *handle_cli_mixmonitor(struct ast_cli_entry *e, int cmd, struct ast_
return CLI_SUCCESS;
}
/*! \brief Mute / unmute an individual MixMonitor by id */
static int mute_mixmonitor_instance(struct ast_channel *chan, const char *data,
enum ast_audiohook_flags flag, int clearmute)
{
struct ast_datastore *datastore = NULL;
char *parse = "";
struct mixmonitor_ds *mixmonitor_ds;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(mixmonid);
);
if (!ast_strlen_zero(data)) {
parse = ast_strdupa(data);
}
AST_STANDARD_APP_ARGS(args, parse);
ast_channel_lock(chan);
datastore = ast_channel_datastore_find(chan, &mixmonitor_ds_info,
S_OR(args.mixmonid, NULL));
if (!datastore) {
ast_channel_unlock(chan);
return -1;
}
mixmonitor_ds = datastore->data;
ast_mutex_lock(&mixmonitor_ds->lock);
if (mixmonitor_ds->audiohook) {
if (clearmute) {
ast_clear_flag(mixmonitor_ds->audiohook, flag);
} else {
ast_set_flag(mixmonitor_ds->audiohook, flag);
}
}
ast_mutex_unlock(&mixmonitor_ds->lock);
ast_channel_unlock(chan);
return 0;
}
/*! \brief Mute / unmute a MixMonitor channel */
static int manager_mute_mixmonitor(struct mansession *s, const struct message *m)
{
@ -1327,8 +1455,11 @@ static int manager_mute_mixmonitor(struct mansession *s, const struct message *m
const char *id = astman_get_header(m, "ActionID");
const char *state = astman_get_header(m, "State");
const char *direction = astman_get_header(m,"Direction");
int clearmute = 1;
const char *mixmonitor_id = astman_get_header(m, "MixMonitorID");
int clearmute = 1, mutedcount = 0;
enum ast_audiohook_flags flag;
RAII_VAR(struct stasis_message *, stasis_message, NULL, ao2_cleanup);
RAII_VAR(struct ast_json *, stasis_message_blob, NULL, ast_json_unref);
if (ast_strlen_zero(direction)) {
astman_send_error(s, m, "No direction specified. Must be read, write or both");
@ -1364,10 +1495,34 @@ static int manager_mute_mixmonitor(struct mansession *s, const struct message *m
return AMI_SUCCESS;
}
if (ast_audiohook_set_mute(c, mixmonitor_spy_type, flag, clearmute)) {
ast_channel_unref(c);
astman_send_error(s, m, "Cannot set mute flag");
return AMI_SUCCESS;
if (ast_strlen_zero(mixmonitor_id)) {
mutedcount = ast_audiohook_set_mute_all(c, mixmonitor_spy_type, flag, clearmute);
if (mutedcount < 0) {
ast_channel_unref(c);
astman_send_error(s, m, "Cannot set mute flag");
return AMI_SUCCESS;
}
} else {
if (mute_mixmonitor_instance(c, mixmonitor_id, flag, clearmute)) {
ast_channel_unref(c);
astman_send_error(s, m, "Cannot set mute flag");
return AMI_SUCCESS;
}
mutedcount = 1;
}
stasis_message_blob = ast_json_pack("{s: s, s: b, s: s, s: i}",
"direction", direction,
"state", ast_true(state),
"mixmonitorid", mixmonitor_id,
"count", mutedcount);
stasis_message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(c),
ast_channel_mixmonitor_mute_type(), stasis_message_blob);
if (stasis_message) {
stasis_publish(ast_channel_topic(c), stasis_message);
}
astman_append(s, "Response: Success\r\n");

View File

@ -3,6 +3,8 @@
*
* Copyright (c) 2006, Tilghman Lesher. All rights reserved.
*
* Updated by Naveen Albert <asterisk@phreaknet.org>
*
* Tilghman Lesher <app_morsecode__v001@the-tilghman.com>
*
* This code is released by the author with no restrictions on usage.
@ -20,11 +22,13 @@
* \brief Morsecode application
*
* \author Tilghman Lesher <app_morsecode__v001@the-tilghman.com>
* \author Naveen Albert <asterisk@phreaknet.org>
*
* \ingroup applications
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
@ -58,6 +62,14 @@
<variable name="MORSETONE">
<para>The pitch of the tone in (Hz), default is 800</para>
</variable>
<variable name="MORSESPACETONE">
<para>The pitch of the spaces in (Hz), default is 0</para>
</variable>
<variable name="MORSETYPE">
<para>The code type to use (AMERICAN for standard American Morse
or INTERNATIONAL for international code.
Default is INTERNATIONAL).</para>
</variable>
</variablelist>
</description>
<see-also>
@ -68,7 +80,7 @@
***/
static const char app_morsecode[] = "Morsecode";
static const char * const morsecode[] = {
static const char * const internationalcode[] = {
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", /* 0-15 */
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", /* 16-31 */
" ", /* 32 - <space> */
@ -95,16 +107,16 @@ static const char * const morsecode[] = {
"", /* 62 - > */
"..--..", /* 63 - ? */
".--.-.", /* 64 - @ */
".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--",
"-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..",
".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", /* A-M */
"-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", /* N-Z */
"-.--.-", /* 91 - [ (really '(') */
"-..-.", /* 92 - \ (really '/') */
"-.--.-", /* 93 - ] (really ')') */
"", /* 94 - ^ */
"..--.-", /* 95 - _ */
".----.", /* 96 - ` */
".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--",
"-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..",
".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", /* a-m */
"-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", /* n-z */
"-.--.-", /* 123 - { (really '(') */
"", /* 124 - | */
"-.--.-", /* 125 - } (really ')') */
@ -112,63 +124,159 @@ static const char * const morsecode[] = {
". . .", /* 127 - <del> (error) */
};
static void playtone(struct ast_channel *chan, int tone, int len)
static const char * const americanmorsecode[] = {
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", /* 0-15 */
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", /* 16-31 */
" ", /* 32 - <space> */
"---.", /* 33 - ! */
"..-. -.",/* 34 - " (QN)*/
"", /* 35 - # */
"... .-..",/* 36 - $ (SX) */
"", /* 37 - % */
". ...", /* 38 - & (ES) */
"..-. .-..",/* 39 - ' (QX) */
"..... -.", /* 40 - ( (PN) */
"..... .. ..", /* 41 - ) (PY) */
"", /* 42 - * */
"", /* 43 - + */
".-.-", /* 44 - , */
".... .-..",/* 45 - (HX) */
"..--..", /* 46 - . */
"..- -", /* 47 - / (UT) */
".--.", "..-..", "...-.", "....-", "---", "......", "--..", "-....", "-..-", "0", /* 48-57 - 0-9 */
"-.- . .",/* 58 - : (KO) */
"... ..", /* 59 - ; */
"", /* 60 - < */
"-...-", /* 61 - = (paragraph mark) */
"", /* 62 - > */
"-..-.", /* 63 - ? */
".--.-.", /* 64 - @ */
".-", "-...", ".. .", "-..", ".", ".-.", "--.", "....", "..", ".-.-", "-.-", "L", "--", /* A-M */
"-.", ". .", ".....", "..-.", ". ..", "...", "-", "..-", "...-", ".--", ".-..", ".. ..", "... .", /* N-Z */
"..... -.", /* 91 - [ (really '(') */
"..- -", /* 92 - \ (really '/') */
"..... .. ..", /* 93 - ] (really ')') */
"", /* 94 - ^ */
"..--.-", /* 95 - _ */
".----.", /* 96 - ` */
".-", "-...", ".. .", "-..", ".", ".-.", "--.", "....", "..", ".-.-", "-.-", "L", "--", /* a-m */
"-.", ". .", ".....", "..-.", ". ..", "...", "-", "..-", "...-", ".--", ".-..", ".. ..", "... .", /* n-z */
"..... -.", /* 123 - { (really '(') */
"", /* 124 - | */
"..... .. ..", /* 125 - } (really ')') */
"..- -", /* 126 - ~ (really bar) */
". . .", /* 127 - <del> (error) */
};
static int playtone(struct ast_channel *chan, int tone, int len)
{
int res;
char dtmf[20];
snprintf(dtmf, sizeof(dtmf), "%d/%d", tone, len);
ast_playtones_start(chan, 0, dtmf, 0);
ast_safe_sleep(chan, len);
res = ast_safe_sleep(chan, len);
ast_playtones_stop(chan);
return res;
}
static int morsecode_exec(struct ast_channel *chan, const char *data)
{
int res=0, ditlen, tone;
int res = 0, ditlen, tone, toneoff, digit2;
const char *digit;
const char *ditlenc, *tonec;
const char *ditlenc, *tonec, *toneb, *codetype;
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Syntax: Morsecode(<string>) - no argument found\n");
return 0;
}
/* Use variable MORESEDITLEN, if set (else 80) */
ast_channel_lock(chan);
/* Use variable MORESEDITLEN, if set (else 80) */
ditlenc = pbx_builtin_getvar_helper(chan, "MORSEDITLEN");
if (ast_strlen_zero(ditlenc) || (sscanf(ditlenc, "%30d", &ditlen) != 1)) {
ditlen = 80;
}
ast_channel_unlock(chan);
/* Use variable MORSETONE, if set (else 800) */
ast_channel_lock(chan);
tonec = pbx_builtin_getvar_helper(chan, "MORSETONE");
if (ast_strlen_zero(tonec) || (sscanf(tonec, "%30d", &tone) != 1)) {
tone = 800;
}
/* Use variable MORSESPACETONE, if set (else 0) */
toneb = pbx_builtin_getvar_helper(chan, "MORSESPACETONE");
if (ast_strlen_zero(toneb) || (sscanf(toneb, "%30d", &toneoff) != 1)) {
toneoff = 0;
}
/* Use variable MORSETYPE, if set (else INTERNATIONAL) */
codetype = pbx_builtin_getvar_helper(chan, "MORSETYPE");
if (!codetype || strcmp(codetype, "AMERICAN")) {
codetype = "INTERNATIONAL";
}
ast_channel_unlock(chan);
for (digit = data; *digit; digit++) {
int digit2 = *digit;
const char *dahdit;
if (digit2 < 0) {
continue;
}
for (dahdit = morsecode[digit2]; *dahdit; dahdit++) {
if (*dahdit == '-') {
playtone(chan, tone, 3 * ditlen);
} else if (*dahdit == '.') {
playtone(chan, tone, 1 * ditlen);
} else {
/* Account for ditlen of silence immediately following */
playtone(chan, 0, 2 * ditlen);
if (!strcmp(codetype, "AMERICAN")) {
for (digit = data; *digit; digit++) {
const char *dahdit;
digit2 = *digit;
if (digit2 < 0 || digit2 > 127) {
continue;
}
for (dahdit = americanmorsecode[digit2]; *dahdit; dahdit++) {
if (*dahdit == '-') {
res = playtone(chan, tone, 3 * ditlen);
} else if (*dahdit == '.') {
res = playtone(chan, tone, 1 * ditlen);
} else if (*dahdit == 'L' || *dahdit == 'l') {
res = playtone(chan, tone, 6 * ditlen); /* long dash */
} else if (*dahdit == '0') {
res = playtone(chan, tone, 9 * ditlen); /* extra long dash */
} else if (*dahdit == ' ') { /* space char (x20) = 6 dot lengths */
/* Intra-char pauses, specific to American Morse */
res = playtone(chan, toneoff, 3 * ditlen);
} else {
/* Account for ditlen of silence immediately following */
res = playtone(chan, toneoff, 2 * ditlen);
}
/* Pause slightly between each dit and dah */
playtone(chan, 0, 1 * ditlen);
/* Pause slightly between each dit and dah */
res = playtone(chan, toneoff, 1 * ditlen);
if (res)
break;
}
/* Pause between characters */
res = playtone(chan, toneoff, 3 * ditlen);
if (res)
break;
}
} else { /* International */
for (digit = data; *digit; digit++) {
const char *dahdit;
digit2 = *digit;
if (digit2 < 0 || digit2 > 127) {
continue;
}
for (dahdit = internationalcode[digit2]; *dahdit; dahdit++) {
if (*dahdit == '-') {
res = playtone(chan, tone, 3 * ditlen);
} else if (*dahdit == '.') {
res = playtone(chan, tone, 1 * ditlen);
} else {
/* Account for ditlen of silence immediately following */
res = playtone(chan, toneoff, 2 * ditlen);
}
/* Pause slightly between each dit and dah */
res = playtone(chan, toneoff, 1 * ditlen);
if (res)
break;
}
/* Pause between characters */
res = playtone(chan, toneoff, 2 * ditlen);
if (res)
break;
}
/* Pause between characters */
playtone(chan, 0, 2 * ditlen);
}
return res;

View File

@ -29,6 +29,7 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
@ -65,9 +66,11 @@
<description>
<para>Executes mpg123 to play the given location, which typically would be a mp3 filename
or m3u playlist filename or a URL. Please read http://en.wikipedia.org/wiki/M3U
to see how M3U playlist file format is like, Example usage would be
to see what the M3U playlist file format is like.</para>
<para>User can exit by pressing any key on the dialpad, or by hanging up.</para>
<example title="Play an MP3 playlist">
exten => 1234,1,MP3Player(/var/lib/asterisk/playlist.m3u)
User can exit by pressing any key on the dialpad, or by hanging up.</para>
</example>
<para>This application does not automatically answer and should be preceeded by an
application such as Answer() or Progress().</para>
</description>
@ -100,37 +103,37 @@ static int mp3play(const char *filename, unsigned int sampling_rate, int fd)
char buffer_size_str[8];
snprintf(buffer_size_str, 8, "%u", (int) 0.5*2*sampling_rate/1000); // 0.5 seconds for a live stream
/* Most commonly installed in /usr/local/bin */
execl(LOCAL_MPG_123, "mpg123", "-q", "-s", "-b", buffer_size_str, "-f", "8192", "--mono", "-r", sampling_rate_str, "-@", filename, (char *)NULL);
execl(LOCAL_MPG_123, "mpg123", "-e", "s16", "-q", "-s", "-b", buffer_size_str, "-f", "8192", "--mono", "-r", sampling_rate_str, "-@", filename, (char *)NULL);
/* But many places has it in /usr/bin */
execl(MPG_123, "mpg123", "-q", "-s", "-b", buffer_size_str, "-f", "8192", "--mono", "-r", sampling_rate_str, "-@", filename, (char *)NULL);
execl(MPG_123, "mpg123", "-e", "s16", "-q", "-s", "-b", buffer_size_str, "-f", "8192", "--mono", "-r", sampling_rate_str, "-@", filename, (char *)NULL);
/* As a last-ditch effort, try to use PATH */
execlp("mpg123", "mpg123", "-q", "-s", "-b", buffer_size_str, "-f", "8192", "--mono", "-r", sampling_rate_str, "-@", filename, (char *)NULL);
execlp("mpg123", "mpg123", "-e", "s16", "-q", "-s", "-b", buffer_size_str, "-f", "8192", "--mono", "-r", sampling_rate_str, "-@", filename, (char *)NULL);
}
else if (!strncasecmp(filename, "http://", 7)) {
char buffer_size_str[8];
snprintf(buffer_size_str, 8, "%u", 6*2*sampling_rate/1000); // 6 seconds for a remote MP3 file
/* Most commonly installed in /usr/local/bin */
execl(LOCAL_MPG_123, "mpg123", "-q", "-s", "-b", buffer_size_str, "-f", "8192", "--mono", "-r", sampling_rate_str, filename, (char *)NULL);
execl(LOCAL_MPG_123, "mpg123", "-e", "s16", "-q", "-s", "-b", buffer_size_str, "-f", "8192", "--mono", "-r", sampling_rate_str, filename, (char *)NULL);
/* But many places has it in /usr/bin */
execl(MPG_123, "mpg123", "-q", "-s", "-b", buffer_size_str, "-f", "8192", "--mono", "-r", sampling_rate_str, filename, (char *)NULL);
execl(MPG_123, "mpg123", "-e", "s16", "-q", "-s", "-b", buffer_size_str, "-f", "8192", "--mono", "-r", sampling_rate_str, filename, (char *)NULL);
/* As a last-ditch effort, try to use PATH */
execlp("mpg123", "mpg123", "-q", "-s", "-b", buffer_size_str, "-f", "8192", "--mono", "-r", sampling_rate_str, filename, (char *)NULL);
execlp("mpg123", "mpg123", "-e", "s16", "-q", "-s", "-b", buffer_size_str, "-f", "8192", "--mono", "-r", sampling_rate_str, filename, (char *)NULL);
}
else if (strstr(filename, ".m3u")) {
/* Most commonly installed in /usr/local/bin */
execl(LOCAL_MPG_123, "mpg123", "-q", "-z", "-s", "-f", "8192", "--mono", "-r", sampling_rate_str, "-@", filename, (char *)NULL);
execl(LOCAL_MPG_123, "mpg123", "-e", "s16", "-q", "-z", "-s", "-f", "8192", "--mono", "-r", sampling_rate_str, "-@", filename, (char *)NULL);
/* But many places has it in /usr/bin */
execl(MPG_123, "mpg123", "-q", "-z", "-s", "-f", "8192", "--mono", "-r", sampling_rate_str, "-@", filename, (char *)NULL);
execl(MPG_123, "mpg123", "-e", "s16", "-q", "-z", "-s", "-f", "8192", "--mono", "-r", sampling_rate_str, "-@", filename, (char *)NULL);
/* As a last-ditch effort, try to use PATH */
execlp("mpg123", "mpg123", "-q", "-z", "-s", "-f", "8192", "--mono", "-r", sampling_rate_str, "-@", filename, (char *)NULL);
execlp("mpg123", "mpg123", "-e", "s16", "-q", "-z", "-s", "-f", "8192", "--mono", "-r", sampling_rate_str, "-@", filename, (char *)NULL);
}
else {
/* Most commonly installed in /usr/local/bin */
execl(MPG_123, "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", sampling_rate_str, filename, (char *)NULL);
execl(MPG_123, "mpg123", "-e", "s16", "-q", "-s", "-f", "8192", "--mono", "-r", sampling_rate_str, filename, (char *)NULL);
/* But many places has it in /usr/bin */
execl(LOCAL_MPG_123, "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", sampling_rate_str, filename, (char *)NULL);
execl(LOCAL_MPG_123, "mpg123", "-e", "s16", "-q", "-s", "-f", "8192", "--mono", "-r", sampling_rate_str, filename, (char *)NULL);
/* As a last-ditch effort, try to use PATH */
execlp("mpg123", "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", sampling_rate_str, filename, (char *)NULL);
execlp("mpg123", "mpg123", "-e", "s16", "-q", "-s", "-f", "8192", "--mono", "-r", sampling_rate_str, filename, (char *)NULL);
}
/* Can't use ast_log since FD's are closed */
fprintf(stderr, "Execute of mpg123 failed\n");

View File

@ -26,7 +26,10 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>deprecated</support_level>
<deprecated_in>16</deprecated_in>
<removed_in>19</removed_in>
***/
#include "asterisk.h"

View File

@ -27,9 +27,6 @@
*
* \ingroup applications
*
* \todo Make a way to be able to set variables (and functions) on the outbound
* channel, similar to the Variable headers for the AMI Originate, and the
* Set options for call files.
*/
/*** MODULEINFO
@ -98,12 +95,30 @@ static const char app_originate[] = "Originate";
<argument name="argN" />
</argument>
</option>
<option name="C">
<para>Comma-separated list of codecs to use for this call.
Default is <literal>slin</literal>.</para>
</option>
<option name="c">
<para>The caller ID number to use for the called channel. Default is
the current channel's Caller ID number.</para>
</option>
<option name="n">
<para>The caller ID name to use for the called channel. Default is
the current channel's Caller ID name.</para>
</option>
<option name="v" argsep="^">
<para>A series of channel variables to set on the destination channel.</para>
<argument name="var1" multiple="true" argsep="=">
<argument name="name" required="true" />
<argument name="value" required="true" />
</argument>
</option>
</optionlist>
</parameter>
</syntax>
<description>
<para>This application originates an outbound call and connects it to a specified extension or application. This application will block until the outgoing call fails or gets answered. At that point, this application will exit with the status variable set and dialplan processing will continue.</para>
<para>This application originates an outbound call and connects it to a specified extension or application. This application will block until the outgoing call fails or gets answered, unless the async option is used. At that point, this application will exit with the status variable set and dialplan processing will continue.</para>
<para>This application sets the following channel variable before exiting:</para>
<variablelist>
<variable name="ORIGINATE_STATUS">
@ -128,11 +143,19 @@ enum {
OPT_PREDIAL_CALLEE = (1 << 0),
OPT_PREDIAL_CALLER = (1 << 1),
OPT_ASYNC = (1 << 2),
OPT_CALLER_NUM = (1 << 3),
OPT_CALLER_NAME = (1 << 4),
OPT_CODECS = (1 << 5),
OPT_VARIABLES = (1 << 6),
};
enum {
OPT_ARG_PREDIAL_CALLEE,
OPT_ARG_PREDIAL_CALLER,
OPT_ARG_CALLER_NUM,
OPT_ARG_CALLER_NAME,
OPT_ARG_CODECS,
OPT_ARG_VARIABLES,
/* note: this entry _MUST_ be the last one in the enum */
OPT_ARG_ARRAY_SIZE,
};
@ -141,9 +164,12 @@ AST_APP_OPTIONS(originate_exec_options, BEGIN_OPTIONS
AST_APP_OPTION('a', OPT_ASYNC),
AST_APP_OPTION_ARG('b', OPT_PREDIAL_CALLEE, OPT_ARG_PREDIAL_CALLEE),
AST_APP_OPTION_ARG('B', OPT_PREDIAL_CALLER, OPT_ARG_PREDIAL_CALLER),
AST_APP_OPTION_ARG('C', OPT_CODECS, OPT_ARG_CODECS),
AST_APP_OPTION_ARG('c', OPT_CALLER_NUM, OPT_ARG_CALLER_NUM),
AST_APP_OPTION_ARG('n', OPT_CALLER_NAME, OPT_ARG_CALLER_NAME),
AST_APP_OPTION_ARG('v', OPT_VARIABLES, OPT_ARG_VARIABLES),
END_OPTIONS );
static int originate_exec(struct ast_channel *chan, const char *data)
{
AST_DECLARE_APP_ARGS(args,
@ -158,29 +184,24 @@ static int originate_exec(struct ast_channel *chan, const char *data)
struct ast_flags64 opts = { 0, };
char *opt_args[OPT_ARG_ARRAY_SIZE];
char *predial_callee = NULL;
char *parse;
char *parse, *cnum = NULL, *cname = NULL;
struct ast_variable *vars = NULL;
char *chantech, *chandata;
int res = -1;
int continue_in_dialplan = 0;
int outgoing_status = 0;
unsigned int timeout = 30;
static const char default_exten[] = "s";
struct ast_format_cap *cap_slin = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
struct ast_format_cap *capabilities;
capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
ast_autoservice_start(chan);
if (!cap_slin) {
if (!capabilities) {
goto return_cleanup;
}
ast_format_cap_append(cap_slin, ast_format_slin, 0);
ast_format_cap_append(cap_slin, ast_format_slin12, 0);
ast_format_cap_append(cap_slin, ast_format_slin16, 0);
ast_format_cap_append(cap_slin, ast_format_slin24, 0);
ast_format_cap_append(cap_slin, ast_format_slin32, 0);
ast_format_cap_append(cap_slin, ast_format_slin44, 0);
ast_format_cap_append(cap_slin, ast_format_slin48, 0);
ast_format_cap_append(cap_slin, ast_format_slin96, 0);
ast_format_cap_append(cap_slin, ast_format_slin192, 0);
ast_format_cap_append(capabilities, ast_format_slin, 0);
if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "Originate() requires arguments\n");
@ -236,7 +257,57 @@ static int originate_exec(struct ast_channel *chan, const char *data)
goto return_cleanup;
}
if (ast_test_flag64(&opts, OPT_CODECS)) {
if (!ast_strlen_zero(opt_args[OPT_ARG_CODECS])) {
ast_format_cap_remove_by_type(capabilities, AST_MEDIA_TYPE_UNKNOWN);
ast_format_cap_update_by_allow_disallow(capabilities, opt_args[OPT_ARG_CODECS], 1);
}
}
if (ast_test_flag64(&opts, OPT_CALLER_NUM)) {
if (!ast_strlen_zero(opt_args[OPT_ARG_CALLER_NUM])) {
cnum = opt_args[OPT_ARG_CALLER_NUM];
} else if (ast_channel_caller(chan)->id.number.str) {
cnum = ast_channel_caller(chan)->id.number.str;
}
}
if (ast_test_flag64(&opts, OPT_CALLER_NAME)) {
if (!ast_strlen_zero(opt_args[OPT_ARG_CALLER_NAME])) {
cname = opt_args[OPT_ARG_CALLER_NAME];
} else if (ast_channel_caller(chan)->id.name.str) {
cname = ast_channel_caller(chan)->id.name.str;
}
}
/* Assign variables */
if (ast_test_flag64(&opts, OPT_VARIABLES)
&& !ast_strlen_zero(opt_args[OPT_ARG_VARIABLES])) {
char *vartext;
char *text = opt_args[OPT_ARG_VARIABLES];
while ((vartext = ast_strsep(&text, '^', 0))) {
struct ast_variable *var;
char *varname, *varvalue;
if (!(varname = ast_strsep(&vartext, '=', 0))) {
ast_log(LOG_ERROR, "Variable syntax error: %s\n", vartext);
goto return_cleanup;
}
if (!(varvalue = ast_strsep(&vartext, '=', 0))) {
varvalue = ""; /* empty values are allowed */
}
var = ast_variable_new(varname, varvalue, "");
if (!var) {
ast_log(LOG_ERROR, "Failed to allocate variable: %s\n", varname);
goto return_cleanup;
}
ast_debug(1, "Appending variable '%s' with value '%s'", varname, varvalue);
ast_variable_list_append(&vars, var);
}
}
if (!strcasecmp(args.type, "exten")) {
const char *cid_num = cnum;
const char *cid_name = cname;
int priority = 1; /* Initialized in case priority not specified */
const char *exten = args.arg2;
@ -254,19 +325,21 @@ static int originate_exec(struct ast_channel *chan, const char *data)
ast_debug(1, "Originating call to '%s/%s' and connecting them to extension %s,%s,%d\n",
chantech, chandata, args.arg1, exten, priority);
res = ast_pbx_outgoing_exten_predial(chantech, cap_slin, chandata,
res = ast_pbx_outgoing_exten_predial(chantech, capabilities, chandata,
timeout * 1000, args.arg1, exten, priority, &outgoing_status,
ast_test_flag64(&opts, OPT_ASYNC) ? AST_OUTGOING_NO_WAIT : AST_OUTGOING_WAIT,
NULL, NULL, NULL, NULL, NULL, 0, NULL,
cid_num, cid_name, vars, NULL, NULL, 0, NULL,
predial_callee);
} else {
const char *cid_num = cnum;
const char *cid_name = cname;
ast_debug(1, "Originating call to '%s/%s' and connecting them to %s(%s)\n",
chantech, chandata, args.arg1, S_OR(args.arg2, ""));
res = ast_pbx_outgoing_app_predial(chantech, cap_slin, chandata,
res = ast_pbx_outgoing_app_predial(chantech, capabilities, chandata,
timeout * 1000, args.arg1, args.arg2, &outgoing_status,
ast_test_flag64(&opts, OPT_ASYNC) ? AST_OUTGOING_NO_WAIT : AST_OUTGOING_WAIT,
NULL, NULL, NULL, NULL, NULL, NULL,
cid_num, cid_name, vars, NULL, NULL, NULL,
predial_callee);
}
@ -311,7 +384,10 @@ return_cleanup:
break;
}
}
ao2_cleanup(cap_slin);
if (vars) {
ast_variables_destroy(vars);
}
ao2_cleanup(capabilities);
ast_autoservice_stop(chan);
return continue_in_dialplan ? 0 : -1;

View File

@ -31,7 +31,10 @@
/*** MODULEINFO
<depend>osptk</depend>
<depend>openssl</depend>
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
<deprecated_in>19</deprecated_in>
<removed_in>21</removed_in>
***/
#include "asterisk.h"

View File

@ -160,6 +160,8 @@ AST_APP_OPTIONS(page_opts, {
AST_APP_OPTION('n', PAGE_NOCALLERANNOUNCE),
});
#define PAGE_BEEP "beep"
/* We use this structure as a way to pass this to all dialed channels */
struct page_options {
char *opts[OPT_ARG_ARRAY_SIZE];
@ -172,8 +174,6 @@ struct page_options {
*
* \param chan Setup bridge profile on this channel.
* \param options Options to setup bridge profile.
*
* \return Nothing
*/
static void setup_profile_bridge(struct ast_channel *chan, struct page_options *options)
{
@ -190,8 +190,6 @@ static void setup_profile_bridge(struct ast_channel *chan, struct page_options *
*
* \param chan Setup user profile on this channel.
* \param options Options to setup paged user profile.
*
* \return Nothing
*/
static void setup_profile_paged(struct ast_channel *chan, struct page_options *options)
{
@ -214,8 +212,6 @@ static void setup_profile_paged(struct ast_channel *chan, struct page_options *o
*
* \param chan Setup user profile on this channel.
* \param options Options to setup caller user profile.
*
* \return Nothing
*/
static void setup_profile_caller(struct ast_channel *chan, struct page_options *options)
{
@ -402,9 +398,14 @@ static int page_exec(struct ast_channel *chan, const char *data)
ast_free(predial_callee);
if (!ast_test_flag(&options.flags, PAGE_QUIET)) {
res = ast_streamfile(chan, "beep", ast_channel_language(chan));
if (!res)
res = ast_waitstream(chan, "");
if (!ast_fileexists(PAGE_BEEP, NULL, NULL)) {
ast_log(LOG_WARNING, "Missing required sound file: '" PAGE_BEEP "'\n");
} else {
res = ast_streamfile(chan, PAGE_BEEP, ast_channel_language(chan));
if (!res) {
res = ast_waitstream(chan, "");
}
}
}
if (!res) {

View File

@ -35,7 +35,7 @@
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
/* This file provides config-file based 'say' functions, and implenents
/* This file provides config-file based 'say' functions, and implements
* some CLI commands.
*/
#include "asterisk/say.h" /*!< provides config-file based 'say' functions */
@ -62,6 +62,12 @@
be answered before the sound is played.</para>
<note><para>Not all channel types support playing messages while still on hook.</para></note>
</option>
<option name="say">
<para>Play using the say.conf file.</para>
</option>
<option name="mix">
<para>Play using a mix of filename and the say.conf file.</para>
</option>
</optionlist>
</parameter>
</syntax>
@ -446,6 +452,7 @@ static int playback_exec(struct ast_channel *chan, const char *data)
char *tmp;
int option_skip=0;
int option_say=0;
int option_mix=0;
int option_noanswer = 0;
AST_DECLARE_APP_ARGS(args,
@ -466,6 +473,8 @@ static int playback_exec(struct ast_channel *chan, const char *data)
option_skip = 1;
if (strcasestr(args.options, "say"))
option_say = 1;
if (strcasestr(args.options, "mix"))
option_mix = 1;
if (strcasestr(args.options, "noanswer"))
option_noanswer = 1;
}
@ -486,6 +495,13 @@ static int playback_exec(struct ast_channel *chan, const char *data)
while (!res && (front = strsep(&back, "&"))) {
if (option_say)
res = say_full(chan, front, "", ast_channel_language(chan), NULL, -1, -1);
else if (option_mix){
/* Check if it is in say format but not remote audio file */
if (strcasestr(front, ":") && !strcasestr(front, "://"))
res = say_full(chan, front, "", ast_channel_language(chan), NULL, -1, -1);
else
res = ast_streamfile(chan, front, ast_channel_language(chan));
}
else
res = ast_streamfile(chan, front, ast_channel_language(chan));
if (!res) {

File diff suppressed because it is too large Load Diff

View File

@ -75,6 +75,23 @@
<option name="n">
<para>to read digits even if the line is not up.</para>
</option>
<option name="t">
<para>Terminator digit(s) to use for ending input.
Default is <literal>#</literal>. If you need to read
the digit <literal>#</literal> literally, you should
remove or change the terminator character. Multiple
terminator characters may be specified. If no terminator
digit is present, input cannot be ended using digits
and you will need to rely on duration and max digits
for ending input.</para>
</option>
<option name="e">
<para>to read the terminator as the digit string if the
only digit read is the terminator. This is for cases
where the terminator is a valid digit, but only by itself.
ie; <literal>1234</literal> and <literal>#</literal> are
valid, but <literal>1234#</literal> is not.</para>
</option>
</optionlist>
</parameter>
<parameter name="attempts">
@ -114,12 +131,22 @@ enum read_option_flags {
OPT_SKIP = (1 << 0),
OPT_INDICATION = (1 << 1),
OPT_NOANSWER = (1 << 2),
OPT_TERMINATOR = (1 << 3),
OPT_KEEP_TERMINATOR = (1 << 4),
};
enum {
OPT_ARG_TERMINATOR,
/* note: this entry _MUST_ be the last one in the enum */
OPT_ARG_ARRAY_SIZE,
};
AST_APP_OPTIONS(read_app_options, {
AST_APP_OPTION('s', OPT_SKIP),
AST_APP_OPTION('i', OPT_INDICATION),
AST_APP_OPTION('n', OPT_NOANSWER),
AST_APP_OPTION_ARG('t', OPT_TERMINATOR, OPT_ARG_TERMINATOR),
AST_APP_OPTION('e', OPT_KEEP_TERMINATOR),
});
static char *app = "Read";
@ -132,9 +159,11 @@ static int read_exec(struct ast_channel *chan, const char *data)
int tries = 1, to = 0, x = 0;
double tosec;
char *argcopy = NULL;
char *opt_args[OPT_ARG_ARRAY_SIZE];
struct ast_tone_zone_sound *ts = NULL;
struct ast_flags flags = {0};
const char *status = "ERROR";
char *terminator = "#"; /* use default terminator # by default */
AST_DECLARE_APP_ARGS(arglist,
AST_APP_ARG(variable);
@ -156,7 +185,7 @@ static int read_exec(struct ast_channel *chan, const char *data)
AST_STANDARD_APP_ARGS(arglist, argcopy);
if (!ast_strlen_zero(arglist.options)) {
ast_app_parse_options(read_app_options, &flags, NULL, arglist.options);
ast_app_parse_options(read_app_options, &flags, opt_args, arglist.options);
}
if (!ast_strlen_zero(arglist.attempts)) {
@ -192,9 +221,19 @@ static int read_exec(struct ast_channel *chan, const char *data)
ts = ast_get_indication_tone(ast_channel_zone(chan), arglist.filename);
}
}
if (ast_test_flag(&flags, OPT_TERMINATOR)) {
if (!ast_strlen_zero(opt_args[OPT_ARG_TERMINATOR])) {
terminator = opt_args[OPT_ARG_TERMINATOR];
} else {
terminator = ""; /* no digit inherently will terminate input */
}
}
if (ast_channel_state(chan) != AST_STATE_UP) {
if (ast_test_flag(&flags, OPT_SKIP)) {
/* At the user's option, skip if the line is not up */
if (ts) {
ts = ast_tone_zone_sound_unref(ts);
}
pbx_builtin_setvar_helper(chan, arglist.variable, "");
pbx_builtin_setvar_helper(chan, "READSTATUS", "SKIPPED");
return 0;
@ -220,7 +259,7 @@ static int read_exec(struct ast_channel *chan, const char *data)
break;
}
tmp[x++] = res;
if (tmp[x-1] == '#') {
if (terminator && strchr(terminator, tmp[x-1])) {
tmp[x-1] = '\0';
status = "OK";
break;
@ -230,13 +269,21 @@ static int read_exec(struct ast_channel *chan, const char *data)
}
}
} else {
res = ast_app_getdata(chan, arglist.filename, tmp, maxdigits, to);
if (res == AST_GETDATA_COMPLETE || res == AST_GETDATA_EMPTY_END_TERMINATED)
res = ast_app_getdata_terminator(chan, arglist.filename, tmp, maxdigits, to, terminator);
if (res == AST_GETDATA_COMPLETE) {
status = "OK";
else if (res == AST_GETDATA_TIMEOUT)
} else if (res == AST_GETDATA_EMPTY_END_TERMINATED) {
if (ast_test_flag(&flags, OPT_KEEP_TERMINATOR)) {
/* if the option is set to do so, read the
returned string as the terminator string */
ast_copy_string(tmp, terminator, sizeof(tmp));
}
status = "OK";
} else if (res == AST_GETDATA_TIMEOUT) {
status = "TIMEOUT";
else if (res == AST_GETDATA_INTERRUPTED)
} else if (res == AST_GETDATA_INTERRUPTED) {
status = "INTERRUPTED";
}
}
if (res > -1) {
pbx_builtin_setvar_helper(chan, arglist.variable, tmp);

111
apps/app_reload.c Normal file
View File

@ -0,0 +1,111 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2021, Naveen Albert
*
* Naveen Albert <asterisk@phreaknet.org>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*! \file
*
* \brief Reload Asterisk modules
*
* \author Naveen Albert <asterisk@phreaknet.org>
*
* \ingroup applications
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/
#include "asterisk.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
/*** DOCUMENTATION
<application name="Reload" language="en_US">
<synopsis>
Reloads an Asterisk module, blocking the channel until the reload has completed.
</synopsis>
<syntax>
<parameter name="module" required="false">
<para>The full name(s) of the target module(s) or resource(s) to reload.
If omitted, everything will be reloaded.</para>
<para>The full names MUST be specified (e.g. <literal>chan_iax2</literal>
to reload IAX2 or <literal>pbx_config</literal> to reload the dialplan.</para>
</parameter>
</syntax>
<description>
<para>Reloads the specified (or all) Asterisk modules and reports success or failure.
Success is determined by each individual module, and if all reloads are successful,
that is considered an aggregate success. If multiple modules are specified and any
module fails, then FAILURE will be returned. It is still possible that other modules
did successfully reload, however.</para>
<para>Sets <variable>RELOADSTATUS</variable> to one of the following values:</para>
<variablelist>
<variable name="RELOADSTATUS">
<value name="SUCCESS">
Specified module(s) reloaded successfully.
</value>
<value name="FAILURE">
Some or all of the specified modules failed to reload.
</value>
</variable>
</variablelist>
</description>
</application>
***/
static char *app = "Reload";
static int reload_exec(struct ast_channel *chan, const char *data)
{
char *targets, *target = NULL;
enum ast_module_reload_result res = AST_MODULE_RELOAD_SUCCESS;
targets = ast_strdupa(data);
ast_autoservice_start(chan);
if (ast_strlen_zero(targets)) { /* Reload everything */
res = ast_module_reload(targets);
} else {
while((target = ast_strsep(&targets, ',', AST_STRSEP_ALL))) {
res |= ast_module_reload(target);
}
}
ast_autoservice_stop(chan);
if (res == AST_MODULE_RELOAD_SUCCESS) {
pbx_builtin_setvar_helper(chan, "RELOADSTATUS", "SUCCESS");
} else {
pbx_builtin_setvar_helper(chan, "RELOADSTATUS", "FAILURE");
}
return 0;
}
static int unload_module(void)
{
return ast_unregister_application(app);
}
static int load_module(void)
{
return ast_register_application_xml(app, reload_exec);
}
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Reload module(s)");

View File

@ -57,6 +57,15 @@
<parameter name="channel" required="false">
<para>Channel where digits will be played</para>
</parameter>
<parameter name="options">
<optionlist>
<option name="a">
<para>Answer the channel specified by the <literal>channel</literal>
parameter if it is not already up. If no <literal>channel</literal>
parameter is provided, the current channel will be answered.</para>
</option>
</optionlist>
</parameter>
</syntax>
<description>
<para>It will send all digits or terminate if it encounters an error.</para>
@ -90,6 +99,19 @@
</manager>
***/
enum read_option_flags {
OPT_ANSWER = (1 << 0),
};
AST_APP_OPTIONS(senddtmf_app_options, {
AST_APP_OPTION('a', OPT_ANSWER),
});
enum {
/* note: this entry _MUST_ be the last one in the enum */
OPT_ARG_ARRAY_SIZE,
};
static const char senddtmf_name[] = "SendDTMF";
static int senddtmf_exec(struct ast_channel *chan, const char *vdata)
@ -100,11 +122,14 @@ static int senddtmf_exec(struct ast_channel *chan, const char *vdata)
struct ast_channel *chan_found = NULL;
struct ast_channel *chan_dest = chan;
struct ast_channel *chan_autoservice = NULL;
char *opt_args[OPT_ARG_ARRAY_SIZE];
struct ast_flags flags = {0};
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(digits);
AST_APP_ARG(dinterval);
AST_APP_ARG(duration);
AST_APP_ARG(channel);
AST_APP_ARG(options);
);
if (ast_strlen_zero(vdata)) {
@ -136,6 +161,12 @@ static int senddtmf_exec(struct ast_channel *chan, const char *vdata)
chan_autoservice = chan;
}
}
if (!ast_strlen_zero(args.options)) {
ast_app_parse_options(senddtmf_app_options, &flags, opt_args, args.options);
}
if (ast_test_flag(&flags, OPT_ANSWER)) {
ast_auto_answer(chan_dest);
}
res = ast_dtmf_stream(chan_dest, chan_autoservice, args.digits,
dinterval <= 0 ? 250 : dinterval, duration);
if (chan_found) {

View File

@ -35,6 +35,7 @@
*/
/*** MODULEINFO
<defaultenabled>no</defaultenabled>
<support_level>extended</support_level>
***/

View File

@ -26,8 +26,8 @@
*/
/*** MODULEINFO
<support_level>core</support_level>
<depend>res_speech</depend>
<support_level>core</support_level>
***/
#include "asterisk.h"

View File

@ -590,8 +590,8 @@ static int gosub_exec(struct ast_channel *chan, const char *data)
ast_channel_unlock(chan);
if (!ast_exists_extension(chan, dest_context, dest_exten, dest_priority, caller_id)) {
ast_log(LOG_ERROR, "Attempt to reach a non-existent destination for %s: (Context:%s, Extension:%s, Priority:%d)\n",
app_gosub, dest_context, dest_exten, dest_priority);
ast_log(LOG_ERROR, "%s attempted to reach non-existent destination '%s,%s,%d' from '%s,%s,%d'",
app_gosub, dest_context, dest_exten, dest_priority, orig_context, orig_exten, orig_priority);
goto error_exit;
}
@ -924,8 +924,6 @@ static struct ast_custom_function stackpeek_function = {
* \param chan Channel to balance stack on.
*
* \note The channel is already locked when called.
*
* \return Nothing
*/
static void balance_stack(struct ast_channel *chan)
{

Some files were not shown because too many files have changed in this diff Show More