]> git.ipfire.org Git - thirdparty/asterisk.git/log
thirdparty/asterisk.git
4 years 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

4 years agoasterisk: Export additional manager functions
Sean Bright [Fri, 18 Dec 2020 15:16:38 +0000 (10:16 -0500)] 
asterisk: Export additional manager functions

Rename check_manager_enabled() and check_webmanager_enabled() to begin
with ast_ so that the symbols are automatically exported by the
linker.

ASTERISK~29184

Change-Id: I85762b9a5d14500c15f6bad6507138c8858644c9

4 years agores_pjsip: Prevent segfault in UDP registration with flow transports
Nick French [Sat, 19 Dec 2020 17:54:50 +0000 (11:54 -0600)] 
res_pjsip: Prevent segfault in UDP registration with flow transports

Segfault occurs during outbound UDP registration when all
transport states are being iterated over. The transport object
in the transport is accessed, but flow transports have a NULL
transport object.

Modify to not iterate over any flow transport

ASTERISK-29210 #close

Change-Id: If28dc3a18bdcbd0a49598b09b7fe4404d45c996a

4 years agocodecs: Remove test-law.
Alexander Traud [Tue, 1 Dec 2020 14:11:58 +0000 (15:11 +0100)] 
codecs: Remove test-law.

This was dead code, test code introduced with Asterisk 13. This was
found while analyzing ASTERISK_28416 and ASTERISK_29185. This change
partly fixes, not closes those two issues.

Change-Id: I42d0daa37f6f334c7d86672f06f085858a3f3940

4 years agores/res_pjsip_diversion: prevent crash on tel: uri in History-Info
Torrey Searle [Tue, 22 Dec 2020 08:58:39 +0000 (09:58 +0100)] 
res/res_pjsip_diversion: prevent crash on tel: uri in History-Info

Add a check to see if the URI is a Tel URI and prevent crashing on
trying to retrieve the reason parameter.

ASTERISK-29191
ASTERISK-29219

Change-Id: I0320aa205f22cda511d60a2edf2b037e8fd6cc37
(cherry picked from commit a7aea71e60d513af82c6e3825e2308e063139b63)

4 years agochan_vpb.cc: Fix compile errors.
Richard Mudgett [Sat, 26 Dec 2020 18:14:05 +0000 (12:14 -0600)] 
chan_vpb.cc: Fix compile errors.

Fix the usual compile problem when someone adds a new callback to struct
ast_channel_tech.

Change-Id: I9bdeb8a8cc65f03b2d6e4f2eb5809af47c906c32

4 years agores_pjsip_session.c: Fix compiler warnings.
Richard Mudgett [Sat, 26 Dec 2020 17:42:51 +0000 (11:42 -0600)] 
res_pjsip_session.c: Fix compiler warnings.

AST_VECTOR_SIZE() returns a size_t.  This is not always equivalent to an
unsigned long on all machines.

Change-Id: I0a4189a104e6e3a2e2273de06620eaef19df9338

4 years agores_pjsip_session: Fixed NULL active media topology handle
Sungtae Kim [Sun, 13 Dec 2020 12:03:32 +0000 (13:03 +0100)] 
res_pjsip_session: Fixed NULL active media topology handle

Added NULL pointer check to prevent Asterisk crash.

ASTERISK-29215

Change-Id: If07e50ea8d78cb610af9195fc13b5dca4bfcef95

4 years agoapp_chanspy: Spyee information missing in ChanSpyStop AMI Event
Sean Bright [Fri, 11 Dec 2020 19:27:56 +0000 (14:27 -0500)] 
app_chanspy: Spyee information missing in ChanSpyStop AMI Event

The documentation in the wiki says there should be spyee-channel
information elements in the ChanSpyStop AMI event.

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

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

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

ASTERISK-28883 #close

Change-Id: I81ce397a3fd614c094d043ffe5b1b1d76188835f

4 years agores_ari: Fix wrong media uri handle for channel play
Sungtae Kim [Tue, 1 Dec 2020 01:27:43 +0000 (02:27 +0100)] 
res_ari: Fix wrong media uri handle for channel play

Fixed wrong null object handle in
/channels/<channel_id>/play request handler.

ASTERISK-29188

Change-Id: I6691c640247a51ad15f23e4a203ca8430809bafe

4 years agologger.c: Automatically add a newline to formats that don't have one
George Joseph [Thu, 10 Dec 2020 15:09:52 +0000 (08:09 -0700)] 
logger.c: Automatically add a newline to formats that don't have one

Scope tracing allows you to not specify a format string or variable,
in which case it just prints the indent, file, function, and line
number.  The trace output automatically adds a newline to the end
in this case.  If you also have debugging turned on for the module,
a debug message is also printed but the standard log functionality
which prints it doesn't add the newline so you have messages
that don't break correctly.

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

ASTERISK-29209
Reported by: Alexander Traud

Change-Id: I994a7df27f88df343b7d19f3e81a4b562d9d41da

4 years agores_pjsip_nat.c: Create deep copies of strings when appropriate
Pirmin Walthert [Tue, 8 Dec 2020 17:37:13 +0000 (18:37 +0100)] 
res_pjsip_nat.c: Create deep copies of strings when appropriate

In rewrite_uri asterisk was not making deep copies of strings when
changing the uri. This was in some cases causing garbage in the route
header and in other cases even crashing asterisk when receiving a
message with a record-route header set. Thanks to Ralf Kubis for
pointing out why this happens. A similar problem was found in
res_pjsip_transport_websocket.c. Pjproject needs as well to be patched
to avoid garbage in CANCEL messages.

ASTERISK-29024 #close

Change-Id: Ic5acd7fa2fbda3080f5f36ef12e46804939b198b

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 agores_pjsip_pidf_digium_body_supplement: Support Sangoma user agent.
Joshua C. Colp [Wed, 16 Dec 2020 12:17:23 +0000 (08:17 -0400)] 
res_pjsip_pidf_digium_body_supplement: Support Sangoma user agent.

This adds support for both Digium and Sangoma user agent strings
for the Sangoma specific body supplement.

Change-Id: Ib99362b24b91d3cbe888d8b2fce3fad5515d9482

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 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 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, and changes
the default location from /tmp to /var/cache/asterisk.

ASTERISK-29143

Change-Id: Ic54e95199405abacd9e509cef5f08fa14c510b5d

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

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

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 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 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 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_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_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_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 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 agochan_sip.c: Don't build by default
Sean Bright [Tue, 15 Sep 2020 15:48:21 +0000 (11:48 -0400)] 
chan_sip.c: Don't build by default

ASTERISK-29083 #close

Change-Id: I9ea25fba3ba8f63a47886894bd966e0f08d5e003

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