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

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

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:41:43 +0000 (14:41 +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 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 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 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 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 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 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_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 agoUpdate CHANGES and UPGRADE.txt for 16.16.0
Asterisk Development Team [Thu, 14 Jan 2021 15:51:50 +0000 (10:51 -0500)] 
Update CHANGES and UPGRADE.txt for 16.16.0

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 [Wed, 23 Dec 2020 17:41:10 +0000 (19:41 +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:39:44 +0000 (08:39 -0600)] 
Revert "res_pjsip_outbound_registration.c:  Use our own scheduler and other stuff"

This reverts commit e1fd51cd2c183a3eb61803f52277d1a7d7a18c9c.

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

ASTERISK-29230
ASTERISK-29231
Reported by: Michael Maier

Change-Id: Ie2356c1cd74436603600599885286b98055b8a17

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

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

As described in the issue, /tmp is not a suitable location for a
large amount of cached media files, since most distributions make
/tmp a RAM-based tmpfs mount with limited capacity.

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

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

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

ASTERISK-29143

Change-Id: Ic54e95199405abacd9e509cef5f08fa14c510b5d

4 years 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 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 08:02:23 +0000 (09:02 +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 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 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 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 [Mon, 16 Nov 2020 10:38:04 +0000 (11:38 +0100)] 
modules.conf: Align the comments for more conclusiveness.

Change-Id: I79cc693cd5a6e5dd7d403b7e91d970ff1ddf8306

4 years agoapp_queue: Fix deadlock between update and show queues
George Joseph [Wed, 11 Nov 2020 14:55:22 +0000 (07:55 -0700)] 
app_queue: Fix deadlock between update and show queues

Operations that update queues when shared_lastcall is set lock the
queue in question, then have to lock the queues container to find the
other queues with the same member. On the other hand, __queues_show
(which is called by both the CLI and AMI) does the reverse. It locks
the queues container, then iterates over the queues locking each in
turn to display them.  This creates a deadlock.

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

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

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

ASTERISK-29155

Change-Id: I78d4dc36728c2d7bc187b97d82673fc77f2bcf41

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

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

* Instead of using the pjproject timer heap, we now use our own
  pjsip_scheduler.  This allows us to more easily debug and allows us to
  see times in "pjsip show/list registrations" as well as being able to
  see the registrations in "pjsip show scheduled_tasks".

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

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

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

Change-Id: I4534a0fc78c7cb69f23b7b449dda9748c90daca2

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

* Added a ONESHOT type that never reschedules.

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

  CLI> pjsip show scheduled_tasks like outreg
  PJSIP Scheduled Tasks:

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

* Fixed incorrect display of "Next Start".

* Compacted the displays of times in the CLI.

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

Change-Id: Ie718ca9fd30490b8a167bedf6b0b06d619dc52f3

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

The data can be freed if the old object '_data' is the same object as
new 'data'. Because at first the object is unreferenced which can lead
to destroying it.

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

Change-Id: I0164f57c387243510bdbd2f8dcf33377b6c202da

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

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

4 years agores_stir_shaken: Include OpenSSL headers where used actually.
Alexander Traud [Fri, 30 Oct 2020 10:53:32 +0000 (11:53 +0100)] 
res_stir_shaken: Include OpenSSL headers where used actually.

This avoids the inclusion of the OpenSSL headers in the public header,
which avoids one external library dependency in res_pjsip_stir_shaken.

Change-Id: I6a07e2d81d2b5442e24e99b8cc733a99f881dcf4

4 years agofunc_curl.c: Allow user to set what return codes constitute a failure.
Dovid Bender [Sun, 18 Oct 2020 18:40:10 +0000 (18:40 +0000)] 
func_curl.c: Allow user to set what return codes constitute a failure.

Currently any response from res_curl where we get an answer from the
web server, regardless of what the response is (404, 403 etc.) Asterisk
currently treats it as a success. This patch allows you to set which
codes should be considered as a failure by Asterisk. If say we set
failurecodes=404,403 then when using curl in realtime if a server gives
a 404 error Asterisk will try to failover to the next option set in
extconfig.conf

ASTERISK-28825

Reported by: Dovid Bender
Code by: Gobinda Paul

Change-Id: I94443e508343e0a3e535e51ea6e0562767639987

4 years agoAST-2020-001 - res_pjsip: Return dialog locked and referenced
Kevin Harwell [Mon, 19 Oct 2020 22:21:57 +0000 (17:21 -0500)] 
AST-2020-001 - res_pjsip: Return dialog locked and referenced

pjproject returns the dialog locked and with a reference. However,
in Asterisk the method that handles this decrements the reference
and removes the lock prior to returning. This makes it possible,
under some circumstances, for another thread to free said dialog
before the thread that created it attempts to use it again. Of
course when the thread that created it tries to use a freed dialog
a crash can occur.

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

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

ASTERISK-29057 #close

Change-Id: I5ef645a47829596f402cf383dc02c629c618969e

4 years agoAST-2020-002 - res_pjsip: Stop sending INVITEs after challenge limit.
Ben Ford [Mon, 2 Nov 2020 16:29:31 +0000 (10:29 -0600)] 
AST-2020-002 - res_pjsip: Stop sending INVITEs after challenge limit.

If Asterisk sends out an INVITE and receives a challenge with a
different nonce value each time, it will continuously send out INVITEs,
even if the call is hung up. The endpoint must be configured for
outbound authentication 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 13:35:26 +0000 (14:35 +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 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 agoUpdate CHANGES and UPGRADE.txt for 16.14.0
Asterisk Development Team [Mon, 19 Oct 2020 18:06:13 +0000 (13:06 -0500)] 
Update CHANGES and UPGRADE.txt for 16.14.0

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

Added debug logging categories that allow a user to output debug
information based on a specified category. This lets the user limit,
and filter debug output to data relevant to a particular context,
or topic. For instance the following categories are now available for
debug logging purposes:

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

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

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

ASTERISK-29054 #close

Change-Id: I6e6cb247bb1f01dbf34750b2cd98e5b5b41a1849
(cherry picked from commit 56028426de0692e8e36167251053c91b96e97c41)

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

With the addition of STIR/SHAKEN, the function ast_base64decode_string
was added for convenience since there is a lot of converting done during
the STIR/SHAKEN process. This function returned the decoded string for
you, but did not NULL terminate it, causing some issues (specifically
with MALLOC_DEBUG). Now, the returned string is NULL terminated, and the
documentation has been updated to reflect this.

Change-Id: Icdd7d05b323b0c47ff6ed43492937a03641bdcf5

4 years agores_stir_shaken: Fix memory allocation error in curl.c
Ben Ford [Mon, 20 Jul 2020 18:05:43 +0000 (13:05 -0500)] 
res_stir_shaken: Fix memory allocation error in curl.c

Fixed a memory allocation that was not passing in the correct size for
the struct in curl.c.

Change-Id: I5fb92fbbe84b075fa6aefa2423786df80e114c3a

4 years agores_stir_shaken: Add stir_shaken option and general improvements.
Ben Ford [Wed, 24 Jun 2020 16:49:11 +0000 (11:49 -0500)] 
res_stir_shaken: Add stir_shaken option and general improvements.

Added a new configuration option for PJSIP endpoints - stir_shaken. If
set to yes, then STIR/SHAKEN support will be added to inbound and
outbound INVITEs. The default is no. Alembic has been updated to include
this option.

Previously the dialplan function was not trimming the whitespace from
the parameters it recieved. Now it does.

Also added a conditional that, when TEST_FRAMEWORK is enabled, the
timestamp in the identity header will be overlooked. This is just for
testing, since the testsuite will rely on a SIPp scenario with a preset
identity header to trigger the MISMATCH result.

Change-Id: I43d67f1489b8c1c5729ed3ca8d71e35ddf438df1

4 years agores_stir_shaken: Add outbound INVITE support.
Ben Ford [Tue, 2 Jun 2020 14:04:23 +0000 (09:04 -0500)] 
res_stir_shaken: Add outbound INVITE support.

Integrated STIR/SHAKEN support with outgoing INVITEs. When an INVITE is
sent, the caller ID will be checked to see if there is a certificate
that corresponds to it. If so, that information will be retrieved and an
Identity header will be added to the SIP message. The format is:

header.payload.signature;info=<public_key_url>alg=ES256;ppt=shaken

Header, payload, and signature are all BASE64 encoded. The public key
URL is retrieved from the certificate. Currently the algorithm and ppt
are ES256 and shaken, respectively. This message is signed and can be
used for verification on the receiving end.

Two new configuration options have been added to the certificate object:
attestation and origid. The attestation is required and must be A, B, or
C. origid is the origination identifier.

A new utility function has been added as well that takes a string,
allocates space, BASE64 encodes it, then returns it, eliminating the
need to calculate the size yourself.

Change-Id: I1f84d6a5839cb2ed152ef4255b380cfc2de662b4

4 years agores_stir_shaken: Add inbound INVITE support.
Ben Ford [Tue, 19 May 2020 19:46:45 +0000 (14:46 -0500)] 
res_stir_shaken: Add inbound INVITE support.

Integrated STIR/SHAKEN support with incoming INVITES. Upon receiving an
INVITE, the Identity header is retrieved, parsing the message to verify
the signature. If any of the parsing fails,
AST_STIR_SHAKEN_VERIFY_NOT_PRESENT will be added to the channel for this
caller ID. If verification itself fails,
AST_STIR_SHAKEN_VERIFY_SIGNATURE_FAILED will be added. If anything in
the payload does not line up with the SIP signaling,
AST_STIR_SHAKEN_VERIFY_MISMATCH will be added. If all of the above steps
pass, then AST_STIR_SHAKEN_VERIFY_PASSED will be added, completing the
verification process.

A new config option has been added to the general section for
stir_shaken.conf. "signature_timeout" is the amount of time a signature
will be considered valid. If an INVITE is received and the amount of
time between when it was received and when it was signed is greater than
signature_timeout, verification will fail.

Some changes were also made to signing and verification. There was an
error where the whole JSON string was being signed rather than the
header combined with the payload. This has been changed to sign the
correct thing. Verification has been changed to do this as well, and the
unit tests have been updated to reflect these changes.

A couple of utility functions have also been added. One decodes a BASE64
string and returns the decoded string, doing all the length calculations
for you. The other retrieves a string value from a header in a rdata
object.

Change-Id: I855f857be3d1c63b64812ac35d9ce0534085b913

4 years ago res_stir_shaken: Add unit tests for signing and verification.
Ben Ford [Wed, 13 May 2020 21:37:25 +0000 (16:37 -0500)] 
 res_stir_shaken: Add unit tests for signing and verification.

Added two unit tests, one for signing and another for verifying.
stir_shaken_sign checks to make sure that all the required parameters
are passed in and then signs the actual payload. If a signature is
produced and a payload returned as a result, the test passes.
stir_shaken_verify takes the signature from a signed payload to verify.
This unit test also verifies that all the required information is passed
in, and then attempts to verify the signature. If verification is
successful and a payload is returned, the test passes.

Change-Id: I9fa43380f861ccf710cd0f6b6c102a517c86ea13

4 years agores_stir_shaken: Added dialplan function and API call.
Ben Ford [Mon, 4 May 2020 21:11:00 +0000 (16:11 -0500)] 
res_stir_shaken: Added dialplan function and API call.

Adds the "STIR_SHAKEN" dialplan function and an API call to add a
STIR_SHAKEN verification result to a channel. This information will be
held in a datastore on the channel that can later be queried through the
"STIR_SHAKEN" dialplan funtion to get information on STIR_SHAKEN results
including identity, attestation, and verify_result. Here are some
examples:

STIR_SHAKEN(count)
STIR_SHAKEN(0, identity)
STIR_SHAKEN(1, attestation)
STIR_SHAKEN(2, verify_result)

Getting the count can be used to iterate through the results and pull
information by specifying the index and the field you want to retrieve.

Change-Id: Ice6d52a3a7d6e4607c9c35b28a1f7c25f5284a82

4 years agores_stir_shaken: Use ast_asprintf for creating file path.
Joshua C. Colp [Fri, 1 May 2020 12:29:07 +0000 (09:29 -0300)] 
res_stir_shaken: Use ast_asprintf for creating file path.

Change-Id: Ice5d92ecea2f1101c80487484f48ef98be2f1824

4 years agores_stir_shaken: Implemented signature verification.
Ben Ford [Wed, 15 Apr 2020 18:15:21 +0000 (13:15 -0500)] 
res_stir_shaken: Implemented signature verification.

There are a lot of moving parts in this patch, but the focus of it is on
the verification of the signature using a public key located at the
public key URL provided in the JSON payload. First, we check the
database to see if we have already downloaded the key. If so, check to
see if it has expired. If it has, redownload from the URL. If we don't
have an entry in the database, just go ahead and download the public
key. The expiration is tested each time we download the file. After
that, read the public key from the file and use it to verify the
signature. All sanity checking is done when the payload is first
received, so the verification is complete once this point is reached.

The XML has also been added since a new config option was added to
general (curl_timeout). The maximum amount of time to wait for a
download can be configured through this option, with a low value by
default.

Change-Id: I3ba4c63880493bf8c7d17a9cfca1af0e934d1a1c

4 years agores_stir_shaken: Do not build without OpenSSL.
Alexander Traud [Mon, 13 Apr 2020 16:47:22 +0000 (18:47 +0200)] 
res_stir_shaken: Do not build without OpenSSL.

Change-Id: Idba5151a3079f9dcc0076d635422c5df5845114f

4 years agores_stir_shaken: Implemented signing of JSON payload.
Ben Ford [Thu, 26 Mar 2020 18:34:47 +0000 (13:34 -0500)] 
res_stir_shaken: Implemented signing of JSON payload.

This change provides functions that take in a JSON payload, verify that
the contents contain all the mandatory fields and required values (if
any), and signs the payload with the private key. Four fields are added
to the payload: x5u, attest, iat, and origid. As of now, these are just
placeholder values that will be set to actual values once the logic is
implemented for what to do when an actual payload is received, but the
functions to add these values have all been implemented and are ready to
use. Upon successful signing and the addition of those four values, a
ast_stir_shaken_payload is returned, containing other useful information
such as the algorithm and signature.

Change-Id: I74fa41c0640ab2a64a1a80110155bd7062f13393

4 years agores_stir_shaken: Initial commit and reading private key.
Ben Ford [Mon, 23 Mar 2020 20:00:09 +0000 (15:00 -0500)] 
res_stir_shaken: Initial commit and reading private key.

This commit sets up some of the initial framework for the module and
adds a way to read the private key from the specified file, which will
then be appended to the certificate object. This works fine for now, but
eventually some other structure will likely need to be used to store all
this information. Similarly, the caller_id_number is specified on the
certificate config object, but in the end we will want that information
to be tied to the certificate itself and read it from there.

A method has been added that will retrieve the private key associated
with the caller_id_number passed in. Tab completion for certificates and
stores has also been added.

Change-Id: Ic4bc1416fab5d6afe15a8e2d32f7ddd4e023295f

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_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 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 agores_musiconhold: Load all realtime entries, not just the first
lvl [Mon, 28 Sep 2020 12:42:47 +0000 (14:42 +0200)] 
res_musiconhold: Load all realtime entries, not just the first

ASTERISK-29099

Change-Id: I45636679c0fb5a5f59114c8741626631a604e8a6

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