asterisk/asterisk.git
4 days agobridge_channel_write_frame: Check for NULL channel master
George Joseph [Fri, 2 Apr 2021 12:21:33 +0000 (06:21 -0600)]
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

7 days agoloader.c: Speed up deprecation metadata lookup
Sean Bright [Thu, 1 Apr 2021 15:38:04 +0000 (11:38 -0400)]
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

7 days agores_prometheus: Clone containers before iterating
George Joseph [Thu, 1 Apr 2021 13:39:03 +0000 (07:39 -0600)]
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

8 days agoloader: Output warnings for deprecated modules.
Joshua C. Colp [Wed, 10 Mar 2021 15:03:11 +0000 (11:03 -0400)]
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

8 days agores_rtp_asterisk: Fix standard deviation calculation
Kevin Harwell [Mon, 22 Mar 2021 20:22:42 +0000 (15:22 -0500)]
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

9 days agores_rtp_asterisk: Don't count 0 as a minimum lost packets
Kevin Harwell [Mon, 29 Mar 2021 22:40:49 +0000 (17:40 -0500)]
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

9 days agores_rtp_asterisk: Statically declare rtp_drop_packets_data object
Kevin Harwell [Wed, 31 Mar 2021 17:17:58 +0000 (12:17 -0500)]
res_rtp_asterisk: Statically declare rtp_drop_packets_data object

This patch makes the drop_packets_data object static.

Change-Id: If4f9b21fa0c47d41a35b6b05941d978efb4da87b

9 days agores_rtp_asterisk: Only raise flash control frame on end.
Joshua C. Colp [Mon, 29 Mar 2021 22:52:08 +0000 (19:52 -0300)]
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

9 days agores_rtp_asterisk: Add a DEVMODE RTP drop packets CLI command
Kevin Harwell [Fri, 5 Mar 2021 18:53:47 +0000 (12:53 -0600)]
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

9 days agores_pjsip: Give error when TLS transport configured but not supported.
Joshua C. Colp [Tue, 30 Mar 2021 11:59:14 +0000 (08:59 -0300)]
res_pjsip: Give error when TLS transport configured but not supported.

Change-Id: I058af496021ff870ccec2d8cbade637b348ab80b

9 days agotime: Add timeval create and unit conversion functions
Kevin Harwell [Fri, 5 Mar 2021 18:47:38 +0000 (12:47 -0600)]
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

10 days agoapp_queue: Add alembic migration to add ringinuse to queue_members.
Sean Bright [Wed, 24 Mar 2021 13:38:20 +0000 (09:38 -0400)]
app_queue: Add alembic migration to add ringinuse to queue_members.

ASTERISK-28356 #close

Change-Id: I53a1bfdd3113d620bea88349019173a2f3f0ae39

12 days agomodules.conf: Fix more differing usages of assignment operators.
Sean Bright [Sun, 28 Mar 2021 15:47:35 +0000 (11:47 -0400)]
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

2 weeks agologger.conf.sample: Add more debug documentation.
Ben Ford [Wed, 24 Mar 2021 15:52:30 +0000 (10:52 -0500)]
logger.conf.sample: Add more debug documentation.

Change-Id: Iff0e713f2120d8dce8e1e26924b99ed17f9d9dff

2 weeks agologging: Add .log to samples and update asterisk.logrotate.
Ben Ford [Wed, 24 Mar 2021 15:59:12 +0000 (10:59 -0500)]
logging: Add .log to samples and update asterisk.logrotate.

Added .log extension to the sample logs in logger.conf.sample so that
they will be able to be opened in the browser when attached to JIRA
tickets. Because of this, asterisk.logrotate has also been updated to
look for .log extensions instead of no extension for log files such as
full and messages.

Change-Id: I5de743c03f08047d6c6cc80cac5019ae0c4c200f

2 weeks agoapp_queue.c: Remove dead 'updatecdr' code.
Sean Bright [Tue, 23 Mar 2021 20:15:45 +0000 (16:15 -0400)]
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

2 weeks agoqueues.conf.sample: Correct 'context' documentation.
Sean Bright [Tue, 23 Mar 2021 22:24:35 +0000 (18:24 -0400)]
queues.conf.sample: Correct 'context' documentation.

ASTERISK-24631 #close

Change-Id: I8bf8776906a72ee02f24de6a85345940b9ff6b6f

2 weeks agologger: Console sessions will now respect logger.conf dateformat= option
Mark Murawski [Fri, 19 Mar 2021 14:11:26 +0000 (10:11 -0400)]
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

2 weeks agoapp_queue.c: Don't crash when realtime queue name is empty.
Sean Bright [Fri, 19 Mar 2021 20:57:44 +0000 (16:57 -0400)]
app_queue.c: Don't crash when realtime queue name is empty.

ASTERISK-27542 #close

Change-Id: If0b9719380a25533d2aed1053cff845dc3a4854a

2 weeks agores_pjsip_session: Make reschedule_reinvite check for NULL topologies
George Joseph [Thu, 18 Mar 2021 16:14:34 +0000 (10:14 -0600)]
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

2 weeks agoapp_queue: Only send QueueMemberStatus if status changes.
Joshua C. Colp [Fri, 19 Mar 2021 09:56:18 +0000 (06:56 -0300)]
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

2 weeks agocore_unreal: Fix deadlock with T.38 control frames.
Joshua C. Colp [Fri, 19 Mar 2021 13:52:08 +0000 (10:52 -0300)]
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

2 weeks agores_pjsip: Add support for partial transport reload.
Joshua C. Colp [Mon, 1 Mar 2021 23:32:24 +0000 (19:32 -0400)]
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

3 weeks agomenuselect: exit non-zero in case of failure on --enable|disable options.
Jaco Kroon [Sat, 13 Mar 2021 11:01:50 +0000 (13:01 +0200)]
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>

3 weeks agores_rtp_asterisk: Force resync on SSRC change.
Joshua C. Colp [Wed, 17 Mar 2021 15:28:45 +0000 (12:28 -0300)]
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

3 weeks agomenuselect: Add ability to set deprecated and removed versions.
Joshua C. Colp [Wed, 10 Mar 2021 14:05:58 +0000 (10:05 -0400)]
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

3 weeks agoxml: Allow deprecated_in and removed_in for MODULEINFO.
Joshua C. Colp [Wed, 10 Mar 2021 14:18:48 +0000 (10:18 -0400)]
xml: Allow deprecated_in and removed_in for MODULEINFO.

ASTERISK-29337

Change-Id: I2211b7da8d29369f8649aeabce07679da0787f2b

3 weeks agoxml: Embed module information into core XML documentation.
Joshua C. Colp [Tue, 9 Mar 2021 14:54:27 +0000 (10:54 -0400)]
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

3 weeks agodocumentation: Fix non-matching module support levels.
Joshua C. Colp [Wed, 10 Mar 2021 10:47:26 +0000 (06:47 -0400)]
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

4 weeks agochannel: Fix crash in suppress API.
Joshua C. Colp [Wed, 10 Mar 2021 00:35:08 +0000 (20:35 -0400)]
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

4 weeks agofunc_callerid+res_agi: Fix compile errors related to -Werror=zero-length-bounds
Jaco Kroon [Wed, 24 Feb 2021 18:00:35 +0000 (20:00 +0200)]
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>

4 weeks agoapp.h: Fix -Werror=zero-length-bounds compile errors in dev mode.
Jaco Kroon [Wed, 24 Feb 2021 18:34:36 +0000 (20:34 +0200)]
app.h: Fix -Werror=zero-length-bounds compile errors in dev mode.

Change-Id: I5c104dc1f8417ccd3d01faf86e84ccbf89bc3b31
Signed-off-by: Jaco Kroon <jaco@uls.co.za>

4 weeks agoapp_dial.c: Only send DTMF on first progress event.
Sean Bright [Sat, 6 Mar 2021 22:57:02 +0000 (17:57 -0500)]
app_dial.c: Only send DTMF on first progress event.

ASTERISK-29329 #close

Change-Id: Ic58e7a17f1ff3f785a5b21dced88682581149601

4 weeks agores_format_attr_*: Parameter Names are Case-Insensitive.
Alexander Traud [Fri, 5 Mar 2021 17:16:56 +0000 (18:16 +0100)]
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

4 weeks agochan_iax2: System Header strings is included via asterisk.h/compat.h.
Alexander Traud [Fri, 5 Mar 2021 17:45:32 +0000 (18:45 +0100)]
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

4 weeks agomodules.conf: Fix differing usage of assignment operators.
Sean Bright [Mon, 8 Mar 2021 21:43:16 +0000 (16:43 -0500)]
modules.conf: Fix differing usage of assignment operators.

ASTERISK-24434 #close

Change-Id: I0144e8d65d878128da59dcf3df12ca8cee47d6db

4 weeks agostrings.h: ast_str_to_upper() and _to_lower() are not pure.
Sean Bright [Mon, 8 Mar 2021 20:06:00 +0000 (15:06 -0500)]
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

4 weeks agores_musiconhold.c: Plug ref leak caused by ao2_replace() misuse.
Sean Bright [Mon, 8 Mar 2021 23:16:14 +0000 (18:16 -0500)]
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

4 weeks agores/res_rtp_asterisk: generate new SSRC on native bridge end
Torrey Searle [Fri, 19 Feb 2021 11:50:21 +0000 (12:50 +0100)]
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

5 weeks agosorcery: Add support for more intelligent reloading.
Joshua C. Colp [Mon, 1 Mar 2021 21:35:20 +0000 (17:35 -0400)]
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

5 weeks agores_pjsip_refer: Move the progress dlg release to a serializer
George Joseph [Tue, 2 Mar 2021 18:55:38 +0000 (11:55 -0700)]
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

5 weeks agores_pjsip_registrar: Include source IP and port in log messages.
Joshua C. Colp [Wed, 3 Mar 2021 18:31:07 +0000 (14:31 -0400)]
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

5 weeks agoasterisk: Update copyright.
Joshua C. Colp [Wed, 3 Mar 2021 18:44:22 +0000 (14:44 -0400)]
asterisk: Update copyright.

ASTERISK-29326

Change-Id: Ia95dbfb66e2d11ac4d1228444283bb2e4d77396a

5 weeks agoAST-2021-006 - res_pjsip_t38.c: Check for session_media on reinvite.
Ben Ford [Thu, 25 Feb 2021 19:50:47 +0000 (13:50 -0600)]
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

5 weeks agores_format_attr_h263: Generate valid SDP fmtp for H.263+.
Alexander Traud [Thu, 28 Jan 2021 14:39:01 +0000 (15:39 +0100)]
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

5 weeks agores_pjsip_nat: Don't rewrite Contact on REGISTER responses.
Joshua C. Colp [Wed, 24 Feb 2021 13:04:09 +0000 (09:04 -0400)]
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

5 weeks agochannel: Fix memory leak in suppress API.
Joshua C. Colp [Wed, 3 Mar 2021 13:32:22 +0000 (09:32 -0400)]
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

5 weeks agores_rtp_asterisk: Check remote ICE reset and reset local ice attrb
Salah Ahmed [Wed, 27 Jan 2021 20:01:01 +0000 (14:01 -0600)]
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

5 weeks agopjsip: Generate progress (once) when receiving a 180 with a SDP
Holger Hans Peter Freyther [Thu, 7 Jan 2021 14:25:05 +0000 (22:25 +0800)]
pjsip: Generate progress (once) when receiving a 180 with a SDP

ASTERISK-29105

Change-Id: If1615fe7115fe544ef974b044d3cea5c48b94a38

5 weeks agomain: With Dutch language year after 2020 is not spoken in say.c
Nico Kooijman [Sun, 28 Feb 2021 09:24:29 +0000 (10:24 +0100)]
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

5 weeks agores_pjsip: dont return early from registration if init auth fails
Nick French [Thu, 25 Feb 2021 02:51:55 +0000 (20:51 -0600)]
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

5 weeks agores_fax: validate the remote/local Station ID for UTF-8 format
Alexei Gradinari [Tue, 23 Feb 2021 16:14:10 +0000 (11:14 -0500)]
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

6 weeks agoapp_page.c: Don't fail to Page if beep sound file is missing
Sean Bright [Thu, 25 Feb 2021 19:55:22 +0000 (14:55 -0500)]
app_page.c: Don't fail to Page if beep sound file is missing

ASTERISK-16799 #close

Change-Id: I40367b0d6dbf66a39721bde060c8b2d734a61cf4

6 weeks agores_pjsip_refer: Refactor progress locking and serialization
George Joseph [Fri, 19 Feb 2021 19:25:13 +0000 (12:25 -0700)]
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

6 weeks agores_rtp_asterisk: Add packet subtype during RTCP debug when relevant
Kevin Harwell [Wed, 24 Feb 2021 22:05:32 +0000 (16:05 -0600)]
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

6 weeks agores_pjsip_session: Always produce offer on re-INVITE without SDP.
Joshua C. Colp [Tue, 16 Feb 2021 18:33:07 +0000 (14:33 -0400)]
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

6 weeks agores_odbc_transaction: correctly initialise forcecommit value from DSN.
Jaco Kroon [Tue, 23 Feb 2021 11:28:08 +0000 (13:28 +0200)]
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>

6 weeks agores_pjsip_session.c: Check topology on re-invite.
Ben Ford [Mon, 15 Feb 2021 18:24:42 +0000 (12:24 -0600)]
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

6 weeks agores_config_pgsql: Limit realtime_pgsql() to return one (no more) record.
Boris P. Korzun [Mon, 15 Feb 2021 19:02:00 +0000 (22:02 +0300)]
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

6 weeks agoapp_queue: Fix conversion of complex extension states into device states
Ivan Poddubnyi [Fri, 13 Sep 2019 13:02:11 +0000 (15:02 +0200)]
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

6 weeks agoapp.h: Restore C++ compatibility for macro AST_DECLARE_APP_ARGS
Jaco Kroon [Wed, 10 Feb 2021 17:59:01 +0000 (19:59 +0200)]
app.h: Restore C++ compatibility for macro AST_DECLARE_APP_ARGS

This partially reverts commit 3d1bf3c537bba0416f691f48165fdd0a32554e8a,
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>

6 weeks agochan_sip: Filter pass-through audio/video formats away, again.
Alexander Traud [Fri, 5 Feb 2021 12:29:51 +0000 (13:29 +0100)]
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

6 weeks agofunc_odbc: Introduce minargs config and expose ARGC in addition to ARGn.
Jaco Kroon [Wed, 17 Feb 2021 20:51:17 +0000 (22:51 +0200)]
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>

6 weeks agoapp_mixmonitor: Add AMI events MixMonitorStart, -Stop and -Mute.
Sebastien Duthil [Wed, 13 Jan 2021 20:05:53 +0000 (15:05 -0500)]
app_mixmonitor: Add AMI events MixMonitorStart, -Stop and -Mute.

ASTERISK-29244

Change-Id: I1862d58264c2c8b5d8983272cb29734b184d67c5

7 weeks agoAST-2021-002: Remote crash possible when negotiating T.38
Kevin Harwell [Mon, 1 Feb 2021 21:24:25 +0000 (15:24 -0600)]
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

7 weeks agortp: Enable srtp replay protection
Alexander Traud [Tue, 26 Jan 2021 17:09:53 +0000 (10:09 -0700)]
rtp:  Enable srtp replay protection

Add option "srtpreplayprotection" rtp.conf to enable srtp
replay protection.

ASTERISK-29260
Reported by: Alexander Traud

Change-Id: I5cd346e3c6b6812039d1901aa4b7be688173b458

7 weeks agores_pjsip_diversion: Fix adding more than one histinfo to Supported
Ivan Poddubnyi [Mon, 28 Dec 2020 12:43:23 +0000 (13:43 +0100)]
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

7 weeks agores_rtp_asterisk.c: Fix signed mismatch that leads to overflow
Sean Bright [Fri, 11 Dec 2020 20:49:48 +0000 (15:49 -0500)]
res_rtp_asterisk.c: Fix signed mismatch that leads to overflow

ASTERISK-29205 #close

Change-Id: Ib7aa65644e8df76e2378d7613ee7cf751b9d0bea

7 weeks agopjsip: Make modify_local_offer2 tolerate previous failed SDP.
Joshua C. Colp [Fri, 5 Feb 2021 11:26:02 +0000 (07:26 -0400)]
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

7 weeks agores_pjsip_refer: Always serialize calls to refer_progress_notify
George Joseph [Tue, 9 Feb 2021 17:25:27 +0000 (10:25 -0700)]
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

7 weeks agocore_unreal: Fix T.38 faxing when using local channels.
Ben Ford [Mon, 11 Jan 2021 20:20:34 +0000 (14:20 -0600)]
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

8 weeks agoformat_wav: Support of MIME-type for wav16
Boris P. Korzun [Tue, 2 Feb 2021 08:33:22 +0000 (11:33 +0300)]
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

8 weeks agochan_sip: Allow [peer] without audio (text+video).
Alexander Traud [Fri, 5 Feb 2021 08:33:41 +0000 (09:33 +0100)]
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

8 weeks agochan_iax2.c: Require secret and auth method if encryption is enabled
George Joseph [Thu, 28 Jan 2021 18:02:34 +0000 (11:02 -0700)]
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

2 months agoapp_read: Release tone zone reference on early return.
Sean Bright [Wed, 3 Feb 2021 18:53:03 +0000 (13:53 -0500)]
app_read: Release tone zone reference on early return.

Change-Id: I350939f2220f9e5d44ddf4c8d9a4c99fde4d169a

2 months agochan_sip: Set up calls without audio (text+video), again.
Alexander Traud [Wed, 27 Jan 2021 17:42:06 +0000 (18:42 +0100)]
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

2 months agochan_pjsip, app_transfer: Add TRANSFERSTATUSPROTOCOL variable
Dan Cropp [Fri, 22 Jan 2021 15:12:12 +0000 (09:12 -0600)]
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

2 months agochannel: Set up calls without audio (text+video), again.
Alexander Traud [Fri, 22 Jan 2021 08:54:49 +0000 (09:54 +0100)]
channel: Set up calls without audio (text+video), again.

ASTERISK-29259

Change-Id: Ib6a6550e0e08355745d66da8e60ef49e81f9c6c5

2 months agores/res_pjsip.c: allow user=phone when number contain *#
roadkill [Fri, 22 Jan 2021 13:12:46 +0000 (14:12 +0100)]
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

2 months agochan_sip: SDP: Reject audio streams correctly.
Alexander Traud [Thu, 21 Jan 2021 19:28:06 +0000 (20:28 +0100)]
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

2 months agomain/frame: Add missing control frame names to ast_frame_subclass2str
Ivan Poddubnyi [Fri, 22 Jan 2021 17:17:18 +0000 (18:17 +0100)]
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

2 months agores_musiconhold: Add support of various URL-schemes by MoH.
Boris P. Korzun [Sat, 23 Jan 2021 13:15:44 +0000 (16:15 +0300)]
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

2 months agoAC_HEADER_STDC causes a compile failure with autoconf 2.70
Jaco Kroon [Fri, 8 Jan 2021 16:02:47 +0000 (18:02 +0200)]
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>

2 months agopjsip_scheduler: Fix pjsip show scheduled_tasks like for compiler Clang.
Alexander Traud [Fri, 15 Jan 2021 09:33:47 +0000 (10:33 +0100)]
pjsip_scheduler: Fix pjsip show scheduled_tasks like for compiler Clang.

Otherwise, Clang 10 warned because of logical-not-parentheses.

Change-Id: Ia8fb493f727b08070eb2dcf520c08df34ed11d79

2 months agores_pjsip_session: Avoid sometimes-uninitialized warning with Clang.
Alexander Traud [Fri, 15 Jan 2021 11:09:00 +0000 (12:09 +0100)]
res_pjsip_session: Avoid sometimes-uninitialized warning with Clang.

ASTERISK-29248

Change-Id: I2b17bd5ffb246bc64c463402c9831413da78a556

2 months agores_pjsip_pubsub: Fix truncation of persisted SUBSCRIBE packet
Sean Bright [Thu, 14 Jan 2021 14:47:21 +0000 (09:47 -0500)]
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

2 months agochan_pjsip.c: Add parameters to frame in indicate.
Ben Ford [Mon, 11 Jan 2021 20:25:09 +0000 (14:25 -0600)]
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

2 months agores/res_pjsip_session.c: Check that media type matches in
Robert Cripps [Tue, 22 Dec 2020 10:42:35 +0000 (11:42 +0100)]
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

2 months agoStasis/messaging: tech subscriptions conflict with endpoint subscriptions.
Jean Aunis [Wed, 30 Dec 2020 13:56:47 +0000 (14:56 +0100)]
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

2 months agochan_sip: SDP: Sidestep stream parsing when its media is disabled.
Alexander Traud [Wed, 23 Dec 2020 14:44:45 +0000 (15:44 +0100)]
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

2 months agochan_pjsip: Assign SIPDOMAIN after creating a channel
Ivan Poddubnyi [Tue, 29 Dec 2020 18:16:00 +0000 (19:16 +0100)]
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

2 months agochan_pjsip: Stop queueing control frames twice on outgoing channels
Ivan Poddubnyi [Thu, 31 Dec 2020 11:53:34 +0000 (12:53 +0100)]
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

2 months agocontrib/systemd: Added note on common issues with systemd and asterisk
Jaco Kroon [Fri, 18 Dec 2020 19:06:20 +0000 (21:06 +0200)]
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

2 months agoRevert "res_pjsip_outbound_registration.c: Use our own scheduler and other stuff"
George Joseph [Thu, 7 Jan 2021 14:40:36 +0000 (08:40 -0600)]
Revert "res_pjsip_outbound_registration.c:  Use our own scheduler and other stuff"

This reverts commit 2fe76dd816706f045ecbc44bf8ad6498977415b3.

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

ASTERISK-29230
ASTERISK-29231
Reported by: Michael Maier

Change-Id: I6453af680e17d8ffe7af2c5de7e1b2a58c8793cb

3 months agofunc_lock: fix multiple-channel-grant problems.
Jaco Kroon [Fri, 18 Dec 2020 19:06:20 +0000 (21:06 +0200)]
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>

3 months agopbx_lua: Add LUA_VERSIONS environment variable to ./configure.
Jaco Kroon [Wed, 23 Dec 2020 17:41:10 +0000 (19:41 +0200)]
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>

3 months agoapp_mixmonitor: cleanup datastore when monitor thread fails to launch
Kevin Harwell [Wed, 23 Dec 2020 19:06:19 +0000 (13:06 -0600)]
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

3 months agoapp_voicemail: Prevent deadlocks when out of ODBC database connections
Sean Bright [Thu, 24 Dec 2020 15:03:44 +0000 (10:03 -0500)]
app_voicemail: Prevent deadlocks when out of ODBC database connections

ASTERISK-28992 #close

Change-Id: Ia7d608924036139ee2520b840d077762d02668d0

3 months agochan_pjsip: Incorporate channel reference count into transfer_refer().
Dan Cropp [Mon, 7 Dec 2020 22:59:51 +0000 (16:59 -0600)]
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

3 months agopbx_realtime: wrong type stored on publish of ast_channel_snapshot_type
Kevin Harwell [Tue, 22 Dec 2020 23:40:38 +0000 (17:40 -0600)]
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