]> git.ipfire.org Git - thirdparty/asterisk.git/log
thirdparty/asterisk.git
4 years agores_musiconhold: Don't crash when real-time doesn't return any entries
Nathan Bruning [Thu, 10 Dec 2020 23:06:56 +0000 (00:06 +0100)] 
res_musiconhold: Don't crash when real-time doesn't return any entries

ASTERISK-29211 #close

Change-Id: Ifbf0a4f786ab2a52342f9d1a1db4c9907f069877

4 years agopjsip: Match lifetime of INVITE session to our session.
Joshua C. Colp [Thu, 29 Oct 2020 17:21:13 +0000 (14:21 -0300)] 
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

4 years agoIntroduce astcachedir, to be used for temporary bucket files
lvl [Thu, 29 Oct 2020 11:25:27 +0000 (12:25 +0100)] 
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

4 years agores_http_media_cache.c: Set reasonable number of redirects
Sean Bright [Sat, 21 Nov 2020 17:51:48 +0000 (12:51 -0500)] 
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

4 years agomedia_cache: Fix reference leak with bucket file metadata
Sean Bright [Mon, 23 Nov 2020 20:56:25 +0000 (15:56 -0500)] 
media_cache: Fix reference leak with bucket file metadata

Change-Id: Ia0e4124110df613ce5fdfa9ef8780016ebaa52c6

4 years agores_pjsip_stir_shaken: Fix module description
Stanislav [Tue, 24 Nov 2020 06:55:08 +0000 (08:55 +0200)] 
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

4 years agovoicemail: add option 'e' to play greetings as early media
Joshua C. Colp [Mon, 12 Oct 2020 10:30:52 +0000 (07:30 -0300)] 
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

4 years agoloader: Sync load- and build-time deps.
Alexander Traud [Mon, 2 Nov 2020 07:24:42 +0000 (08:24 +0100)] 
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

4 years agoCHANGES: Remove already applied CHANGES update
Sean Bright [Wed, 18 Nov 2020 19:11:46 +0000 (14:11 -0500)] 
CHANGES: Remove already applied CHANGES update

Change-Id: Iee7163bc732d58c5cbaa2cfab1f5aab4a412060a

4 years agores_pjsip: set Accept-Encoding to identity in OPTIONS response
Alexander Greiner-Baer [Tue, 17 Nov 2020 20:19:35 +0000 (21:19 +0100)] 
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

4 years agochan_sip: Remove unused sip_socket->port.
Alexander Traud [Wed, 4 Nov 2020 13:39:10 +0000 (14:39 +0100)] 
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

4 years agobridge_basic: Fixed setup of recall channels
Boris P. Korzun [Fri, 13 Nov 2020 12:19:30 +0000 (15:19 +0300)] 
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

4 years agomodules.conf: Align the comments for more conclusiveness.
Alexander Traud [Tue, 3 Nov 2020 08:27:17 +0000 (09:27 +0100)] 
modules.conf: Align the comments for more conclusiveness.

Change-Id: I79cc693cd5a6e5dd7d403b7e91d970ff1ddf8306

4 years agoapp_queue: Fix deadlock between update and show queues
George Joseph [Wed, 11 Nov 2020 14:55:22 +0000 (07:55 -0700)] 
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

4 years agoUpdate CHANGES and UPGRADE.txt for 18.1.0
Asterisk Development Team [Thu, 12 Nov 2020 11:50:09 +0000 (06:50 -0500)] 
Update CHANGES and UPGRADE.txt for 18.1.0

4 years agores_pjsip_outbound_registration.c: Use our own scheduler and other stuff
George Joseph [Mon, 2 Nov 2020 19:53:02 +0000 (12:53 -0700)] 
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

4 years agopjsip_scheduler.c: Add type ONESHOT and enhance cli show command
George Joseph [Mon, 2 Nov 2020 19:53:58 +0000 (12:53 -0700)] 
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

4 years agosched: AST_SCHED_REPLACE_UNREF can lead to use after free of data
Alexei Gradinari [Fri, 2 Oct 2020 19:32:29 +0000 (15:32 -0400)] 
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

4 years agores_pjsip/config_transport: Load and run without OpenSSL.
Alexander Traud [Fri, 30 Oct 2020 16:43:59 +0000 (17:43 +0100)] 
res_pjsip/config_transport: Load and run without OpenSSL.

ASTERISK-28933
Reported-by: Walter Doekes
Change-Id: I65eac49e5b0a79261ea80e2b9b38a836886ed59f

4 years agores_stir_shaken: Include OpenSSL headers where used actually.
Alexander Traud [Fri, 30 Oct 2020 10:53:32 +0000 (11:53 +0100)] 
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

4 years agofunc_curl.c: Allow user to set what return codes constitute a failure.
Dovid Bender [Sun, 18 Oct 2020 18:40:10 +0000 (18:40 +0000)] 
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

4 years agoAST-2020-001 - res_pjsip: Return dialog locked and referenced
Kevin Harwell [Wed, 4 Nov 2020 21:08:10 +0000 (15:08 -0600)] 
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

4 years agoAST-2020-002 - res_pjsip: Stop sending INVITEs after challenge limit.
Ben Ford [Tue, 3 Nov 2020 16:38:34 +0000 (10:38 -0600)] 
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

4 years agosip_to_pjsip.py: Handle #include globs and other fixes
Sean Bright [Thu, 29 Oct 2020 15:21:45 +0000 (11:21 -0400)] 
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

4 years agoCompiler fixes for GCC with -Og
Alexander Traud [Thu, 29 Oct 2020 08:55:53 +0000 (09:55 +0100)] 
Compiler fixes for GCC with -Og

ASTERISK-29144

Change-Id: I2a72c072083b4492a223c6f9d73d21f4f424db62

4 years agoCompiler fixes for GCC with -Os
Alexander Traud [Thu, 29 Oct 2020 13:59:48 +0000 (14:59 +0100)] 
Compiler fixes for GCC with -Os

ASTERISK-29145

Change-Id: I9af705f2b9725c53141aef5d0ff512a1800f073c

4 years agoCompiler fixes for GCC when printf %s is NULL
Alexander Traud [Fri, 30 Oct 2020 08:46:10 +0000 (09:46 +0100)] 
Compiler fixes for GCC when printf %s is NULL

ASTERISK-29146

Change-Id: Ib04bdad87d729f805f5fc620ef9952f58ea96d41

4 years agochan_sip: On authentication, pick MD5 for sure.
Alexander Traud [Fri, 23 Oct 2020 15:26:15 +0000 (17:26 +0200)] 
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

4 years agomain/say: Work around gcc 9 format-truncation false positive
Walter Doekes [Thu, 4 Jun 2020 14:23:37 +0000 (16:23 +0200)] 
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

4 years agores_pjsip, res_pjsip_session: initialize local variables
Kevin Harwell [Mon, 19 Oct 2020 20:31:14 +0000 (15:31 -0500)] 
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

4 years agoinstall_prereq: Add GMime 3.0.
Alexander Traud [Fri, 23 Oct 2020 14:55:18 +0000 (16:55 +0200)] 
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

4 years agores_pjsip_session: Restore calls to ast_sip_message_apply_transport()
Nick French [Tue, 13 Oct 2020 17:15:28 +0000 (12:15 -0500)] 
res_pjsip_session: Restore calls to ast_sip_message_apply_transport()

Commit 44bb0858cb3ea6a8db8b8d1c7fedcfec341ddf66 ("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

4 years agoBuildSystem: Enable Lua 5.4.
Alexander Traud [Fri, 23 Oct 2020 14:49:02 +0000 (16:49 +0200)] 
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

4 years agofeatures.conf.sample: Sample sound files incorrectly quoted
Sean Bright [Thu, 22 Oct 2020 16:21:20 +0000 (12:21 -0400)] 
features.conf.sample: Sample sound files incorrectly quoted

ASTERISK-29136 #close

Change-Id: I3186536d65a50014c8da4780c9224919caa81440

4 years agologger.conf.sample: add missing comment mark
Andrew Siplas [Mon, 12 Oct 2020 05:45:44 +0000 (01:45 -0400)] 
logger.conf.sample: add missing comment mark

Add missing comment mark from stock configuration.

ASTERISK-29123 #close

Change-Id: I4f94eb4544166bca8af4c17fd11edee3c6980620

4 years agores_pjsip: Adjust outgoing offer call pref.
Joshua C. Colp [Tue, 6 Oct 2020 15:32:04 +0000 (12:32 -0300)] 
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

4 years agoLogging: Add debug logging categories
Kevin Harwell [Fri, 28 Aug 2020 21:32:37 +0000 (16:32 -0500)] 
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 56028426de0692e8e36167251053c91b96e97c41)

4 years agotcptls.c: Don't close TCP client file descriptors more than once
Sean Bright [Wed, 30 Sep 2020 20:00:36 +0000 (16:00 -0400)] 
tcptls.c: Don't close TCP client file descriptors more than once

ASTERISK-28430 #close

Change-Id: Ib556b0a0c95cca939e956886214ec8d828d89606

4 years agoresource_endpoints.c: memory leak when providing a 404 response
Jean Aunis [Mon, 5 Oct 2020 15:44:04 +0000 (17:44 +0200)] 
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

4 years agoapp_voicemail.c: Document VMSayName interruption behavior
Sean Bright [Wed, 30 Sep 2020 00:57:20 +0000 (20:57 -0400)] 
app_voicemail.c: Document VMSayName interruption behavior

ASTERISK-26424 #close

Change-Id: I797ad0ed302d0b3d2c90543eff5b7207ed08ecf0

4 years agopbx.c: On error, ast_add_extension2_lockopt should always free 'data'
Sean Bright [Tue, 29 Sep 2020 18:04:48 +0000 (14:04 -0400)] 
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

4 years agoapp_confbridge/bridge_softmix: Add ability to force estimated bitrate
George Joseph [Thu, 24 Sep 2020 18:46:15 +0000 (12:46 -0600)] 
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

4 years agochannels: Don't dereference NULL pointer
Jasper van der Neut [Wed, 23 Sep 2020 09:05:39 +0000 (11:05 +0200)] 
channels: Don't dereference NULL pointer

Check result of ast_translator_build_path against NULL before dereferencing.

ASTERISK-29091

Change-Id: Ia3538ea190bd371f70c9dd49984b021765691b29

4 years agores_pjsip_sdp_rtp: Fix accidentally native bridging calls
Holger Hans Peter Freyther [Wed, 23 Sep 2020 03:39:12 +0000 (11:39 +0800)] 
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

4 years agores_musiconhold: Load all realtime entries, not just the first
lvl [Mon, 28 Sep 2020 12:42:47 +0000 (14:42 +0200)] 
res_musiconhold: Load all realtime entries, not just the first

ASTERISK-29099

Change-Id: I45636679c0fb5a5f59114c8741626631a604e8a6

4 years agores_pjsip_diversion: fix double 181
Torrey Searle [Thu, 24 Sep 2020 14:54:08 +0000 (16:54 +0200)] 
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

4 years agores_musiconhold: Clarify that playlist mode only supports HTTP(S) URLs
Sean Bright [Thu, 24 Sep 2020 16:47:41 +0000 (12:47 -0400)] 
res_musiconhold: Clarify that playlist mode only supports HTTP(S) URLs

Change-Id: I41e77a04e4a523f4ed61a7a20b738ffd42be441e

4 years agodsp.c: Update calls to ast_format_cmp to check result properly
Sean Bright [Wed, 23 Sep 2020 20:20:48 +0000 (16:20 -0400)] 
dsp.c: Update calls to ast_format_cmp to check result properly

ASTERISK-28311 #close

Change-Id: Ib1ce8fc1a8752751f5bf3615c59245532dfd9aa2

4 years agores_musiconhold: Start playlist after initial announcement
Sean Bright [Fri, 18 Sep 2020 20:02:27 +0000 (16:02 -0400)] 
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

4 years agores_pjsip_session: Fix stream name memory leak.
Joshua C. Colp [Tue, 22 Sep 2020 10:05:34 +0000 (07:05 -0300)] 
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

4 years agofunc_curl.c: Prevent crash when using CURLOPT(httpheader)
Sean Bright [Fri, 18 Sep 2020 13:09:59 +0000 (09:09 -0400)] 
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

4 years agores_pjsip_session: Fix session reference leak.
Joshua C. Colp [Tue, 22 Sep 2020 10:13:32 +0000 (07:13 -0300)] 
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

4 years agores_stasis.c: Add compare function for bridges moh container
Michal Hajek [Wed, 16 Sep 2020 13:01:07 +0000 (15:01 +0200)] 
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

4 years agologger.h: Fix ast_trace to respect scope_level
George Joseph [Thu, 17 Sep 2020 16:40:39 +0000 (10:40 -0600)] 
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

4 years agoaudiosocket: Fix module menuselect descriptions
Sean Bright [Tue, 15 Sep 2020 20:44:35 +0000 (16:44 -0400)] 
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

4 years agobridge_softmix/sfu_topologies_on_join: Ignore topology change failures
George Joseph [Thu, 17 Sep 2020 18:01:27 +0000 (12:01 -0600)] 
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

4 years agores_pjsip_session.c: Fix build when TEST_FRAMEWORK is not defined
Sean Bright [Tue, 15 Sep 2020 21:16:34 +0000 (17:16 -0400)] 
res_pjsip_session.c: Fix build when TEST_FRAMEWORK is not defined

Change-Id: Id4852c26e9c412af8e37b5dd3c15da9453ad3276

4 years agores_pjsip_diversion: implement support for History-Info
Torrey Searle [Thu, 13 Aug 2020 08:34:55 +0000 (10:34 +0200)] 
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

4 years agoformat_cap: Perform codec lookups by pointer instead of name
Sean Bright [Mon, 14 Sep 2020 18:23:27 +0000 (14:23 -0400)] 
format_cap: Perform codec lookups by pointer instead of name

ASTERISK-28416 #close

Change-Id: I069420875ebdbcaada52d92599a5f7de3cb2cdf4

4 years agores_pjsip_session: Fix issue with COLP and 491
George Joseph [Fri, 11 Sep 2020 16:09:55 +0000 (10:09 -0600)] 
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

4 years agodebugging: Add enough to choke a mule
George Joseph [Thu, 20 Aug 2020 20:09:25 +0000 (14:09 -0600)] 
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

4 years agores_pjsip_session: Handle multi-stream re-invites better
George Joseph [Thu, 20 Aug 2020 16:21:18 +0000 (10:21 -0600)] 
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

4 years agorealtime: Increased reg_server character size
Sungtae Kim [Mon, 31 Aug 2020 12:21:09 +0000 (14:21 +0200)] 
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

4 years agores_stasis.c: Added video_single option for bridge creation
Sungtae Kim [Sun, 30 Aug 2020 20:42:06 +0000 (22:42 +0200)] 
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

4 years agoBridging: Use a ref to bridge_channel's channel to prevent crash.
Ben Ford [Mon, 31 Aug 2020 16:14:20 +0000 (11:14 -0500)] 
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

4 years agoUpdate CHANGES and UPGRADE.txt for 18.0.0
Asterisk Development Team [Wed, 9 Sep 2020 14:08:27 +0000 (09:08 -0500)] 
Update CHANGES and UPGRADE.txt for 18.0.0

4 years agores_pjsip_session: Deferred re-INVITE without SDP send a=sendrecv instead of a=sendonly
Patrick Verzele [Tue, 1 Sep 2020 13:43:46 +0000 (14:43 +0100)] 
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

4 years agoconversions: Add string to signed integer conversion functions
Kevin Harwell [Fri, 28 Aug 2020 21:31:40 +0000 (16:31 -0500)] 
conversions: Add string to signed integer conversion functions

Change-Id: Id603b0b03b78eb84c7fca030a08b343c0d5973f9

4 years agoapp_queue: Fix leave-empty not recording a call as abandoned
Kfir Itzhak [Wed, 26 Aug 2020 09:58:21 +0000 (12:58 +0300)] 
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

4 years agoast_coredumper: Fix issues with naming
George Joseph [Fri, 28 Aug 2020 14:34:09 +0000 (08:34 -0600)] 
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

4 years agoparking: Copy parker UUID as well.
Joshua C. Colp [Fri, 28 Aug 2020 09:29:23 +0000 (06:29 -0300)] 
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

4 years agosip_nat_settings: Update script for latest Linux.
Alexander Traud [Wed, 26 Aug 2020 15:43:13 +0000 (17:43 +0200)] 
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

4 years agosamples: Fix keep_alive_interval default in pjsip.conf.
Alexander Traud [Wed, 26 Aug 2020 15:19:55 +0000 (17:19 +0200)] 
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

4 years agochan_pjsip: disallow PJSIP_SEND_SESSION_REFRESH pre-answer execution
Kevin Harwell [Mon, 24 Aug 2020 21:26:23 +0000 (16:26 -0500)] 
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

4 years agopbx: Fix hints deadlock between reload and ExtensionState.
Joshua C. Colp [Thu, 27 Aug 2020 10:31:40 +0000 (07:31 -0300)] 
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

4 years agologger.c: Added a new log formatter called "plain"
George Joseph [Fri, 14 Aug 2020 16:13:33 +0000 (10:13 -0600)] 
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

4 years agores_speech: Bump reference on format object
Nickolay Shmyrev [Fri, 21 Aug 2020 21:53:04 +0000 (23:53 +0200)] 
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

4 years agores_pjsip_diversion: handle 181
Torrey Searle [Wed, 22 Jul 2020 08:45:57 +0000 (10:45 +0200)] 
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

4 years agoapp_queue: Member lastpause time reseting
Evandro César Arruda [Fri, 21 Aug 2020 05:09:11 +0000 (02:09 -0300)] 
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

4 years agoapp_voicemail: Process urgent messages with mailcmd
Sean Bright [Fri, 21 Aug 2020 14:17:59 +0000 (10:17 -0400)] 
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

4 years agores_pjsip_session: Don't aggressively terminate on failed re-INVITE.
Joshua C. Colp [Tue, 18 Aug 2020 09:36:05 +0000 (06:36 -0300)] 
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

4 years agobridge_channel: Ensure text messages are zero terminated
Sean Bright [Wed, 19 Aug 2020 17:29:51 +0000 (13:29 -0400)] 
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

4 years agores_musiconhold.c: Use ast_file_read_dir to scan MoH directory
Sean Bright [Fri, 7 Aug 2020 14:31:01 +0000 (10:31 -0400)] 
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

4 years agoscope_trace: Added debug messages and added additional macros
George Joseph [Wed, 19 Aug 2020 12:37:23 +0000 (06:37 -0600)] 
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

4 years agostream.c: Added 2 more debugging utils and added pos to stream string
George Joseph [Thu, 20 Aug 2020 13:32:03 +0000 (07:32 -0600)] 
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

4 years agochan_sip: Clear ToHost property on peer when changing to dynamic host
Dennis Buteyn [Tue, 18 Feb 2020 12:30:31 +0000 (14:30 +0200)] 
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

4 years agoACN: Changes specific to the core
George Joseph [Mon, 20 Jul 2020 19:39:14 +0000 (13:39 -0600)] 
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

4 years agoMakefile: Fix certified version numbers
cmaj [Thu, 6 Aug 2020 17:51:10 +0000 (11:51 -0600)] 
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

4 years agores_musiconhold.c: Prevent crash with realtime MoH
Sean Bright [Thu, 6 Aug 2020 16:41:33 +0000 (12:41 -0400)] 
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

4 years agores_pjsip: Fix codec preference defaults.
Joshua C. Colp [Thu, 6 Aug 2020 18:10:20 +0000 (15:10 -0300)] 
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

4 years agovector.h: Fix implementation of AST_VECTOR_COMPACT() for empty vectors
Sean Bright [Tue, 4 Aug 2020 15:51:16 +0000 (11:51 -0400)] 
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

4 years agopjproject: clone sdp to protect against (nat) modifications
Michael Neuhauser [Tue, 30 Jun 2020 15:40:41 +0000 (17:40 +0200)] 
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

4 years agoutils.c: NULL terminate ast_base64decode_string.
Ben Ford [Tue, 4 Aug 2020 19:36:22 +0000 (14:36 -0500)] 
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

4 years agoACN: Configuration renaming for pjsip endpoint
George Joseph [Tue, 21 Jul 2020 14:17:54 +0000 (08:17 -0600)] 
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

5 years agores_stir_shaken: Fix memory allocation error in curl.c
Ben Ford [Mon, 20 Jul 2020 18:05:43 +0000 (13:05 -0500)] 
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 deaa3742dc998e38369d34bfc308d84e9036dcba)

5 years agores_pjsip_session: Ensure reused streams have correct bundle group
George Joseph [Thu, 23 Jul 2020 19:47:25 +0000 (13:47 -0600)] 
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

5 years agores_pjsip_registrar: Don't specify an expiration for static contacts.
Joshua C. Colp [Wed, 22 Jul 2020 09:41:59 +0000 (06:41 -0300)] 
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

5 years agoutf8.c: Add UTF-8 validation and utility functions
Sean Bright [Mon, 13 Jul 2020 20:06:14 +0000 (16:06 -0400)] 
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

5 years agostasis_bridge.c: Fixed wrong video_mode shown
sungtae kim [Fri, 10 Jul 2020 23:14:53 +0000 (01:14 +0200)] 
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

5 years agovector.h: Add AST_VECTOR_SORT()
Sean Bright [Mon, 20 Jul 2020 18:17:45 +0000 (14:17 -0400)] 
vector.h: Add AST_VECTOR_SORT()

Allows a vector to be sorted in-place, rather than only during
insertion.

Change-Id: I22cba9ddf556a7e44dacc53c4431bd81dd2fa780