asterisk/asterisk.git
16 months agoapp_bridgeaddchan.c: Make BridgeAdd be more like Bridge
Richard Mudgett [Mon, 30 Dec 2019 21:05:44 +0000 (15:05 -0600)]
app_bridgeaddchan.c: Make BridgeAdd be more like Bridge

* Made BridgeAdd not hangup the call if there is a problem.
* Reduced message level from warning to verbose for normal exception
cases.
* Added a loop safety check to BridgeAdd.
* Made BridgeAdd set BRIDGERESULT with the status when dialplan is
resumed.

Change-Id: I374d39b8a3edcc794eeb5c6b9f31a01424cdc426

16 months agoMerge "func_odbc: acf_odbc_read() and cli_odbc_read() unicode support"
Joshua Colp [Thu, 2 Jan 2020 15:35:31 +0000 (09:35 -0600)]
Merge "func_odbc:  acf_odbc_read() and cli_odbc_read() unicode support"

16 months agoMerge "res_fax: wrap v21 detected Asterisk initiated negotiation with config option"
George Joseph [Thu, 2 Jan 2020 14:43:21 +0000 (08:43 -0600)]
Merge "res_fax: wrap v21 detected Asterisk initiated negotiation with config option"

16 months agoMerge "chan_sip: voice frames are no longer transmitted after emitting a COLP"
Friendly Automation [Mon, 30 Dec 2019 21:17:50 +0000 (15:17 -0600)]
Merge "chan_sip: voice frames are no longer transmitted after emitting a COLP"

16 months agodb: Initialize condition primitive before use
Sean Bright [Fri, 27 Dec 2019 23:29:45 +0000 (18:29 -0500)]
db: Initialize condition primitive before use

The db_init() function ultimately calls db_sync() which signals the
condition before it is initialized.

Change-Id: Id4a4e025b637bc4ac7d90557fcb71d56598892ab

16 months agoMerge "config.c: Skip UTF-8 BOMs if present when reading config files"
George Joseph [Fri, 27 Dec 2019 19:12:03 +0000 (13:12 -0600)]
Merge "config.c: Skip UTF-8 BOMs if present when reading config files"

16 months agoMerge "main/file.c: Limit media cache usage to remote files."
Joshua C. Colp [Fri, 20 Dec 2019 00:41:11 +0000 (18:41 -0600)]
Merge "main/file.c: Limit media cache usage to remote files."

16 months agoMerge "app_chanisavail/cdr: ChanIsAvail sometimes fails to deactivate CDR."
Joshua C. Colp [Fri, 20 Dec 2019 00:40:11 +0000 (18:40 -0600)]
Merge "app_chanisavail/cdr: ChanIsAvail sometimes fails to deactivate CDR."

16 months agoMerge "chan_sip: in case of tcp/tls, be less annoying about tx errors."
Friendly Automation [Thu, 19 Dec 2019 16:44:45 +0000 (10:44 -0600)]
Merge "chan_sip:  in case of tcp/tls, be less annoying about tx errors."

16 months agoMerge "confbridge: Add support for specifying maximum sample rate."
Friendly Automation [Thu, 19 Dec 2019 16:00:43 +0000 (10:00 -0600)]
Merge "confbridge: Add support for specifying maximum sample rate."

16 months agoconfig.c: Skip UTF-8 BOMs if present when reading config files
Sean Bright [Wed, 18 Dec 2019 15:13:21 +0000 (10:13 -0500)]
config.c: Skip UTF-8 BOMs if present when reading config files

ASTERISK-28667 #close

Change-Id: I4767ed365c98f3e1587b7653321048a31d8a53b2

16 months agomain/file.c: Limit media cache usage to remote files.
Kevin Reeves [Thu, 21 Nov 2019 18:48:42 +0000 (12:48 -0600)]
main/file.c: Limit media cache usage to remote files.

When testing for the existance of a file, the media cache is searched even if
the file has no chance of being in it.  This can cause performance issues
as the media cache size increases.

As a result, calls to applications like Read and Playback using local files
must scan through the media cache before playing.  Under load and with a
large cache, this can delay the playback of those files.

This patch updates the function that checks for the existance of a file to
only consult the media cache database if the requested file is a remote path.
It introduces a new is_remote_path() function in main/file.c.

ASTERISK-28625  #close
Reported-by: kevin@phoneburner.com

Change-Id: If91137493732d9034dafa381c081c69274a7dcc9

16 months agoMerge "res_rtp_asterisk: Add frame list cleanups to ast_rtp_read"
George Joseph [Wed, 18 Dec 2019 14:54:16 +0000 (08:54 -0600)]
Merge "res_rtp_asterisk:  Add frame list cleanups to ast_rtp_read"

16 months agoMerge "sip_to_pjsip.py: Fix trustrpid typo"
Friendly Automation [Wed, 18 Dec 2019 13:26:45 +0000 (07:26 -0600)]
Merge "sip_to_pjsip.py: Fix trustrpid typo"

16 months agoMerge "configure: Add check for MySQL client bool and my_bool type usage."
Joshua C. Colp [Wed, 18 Dec 2019 12:37:06 +0000 (06:37 -0600)]
Merge "configure: Add check for MySQL client bool and my_bool type usage."

16 months agoMerge "res_pjsip_session: Set stream state on created streams for incoming SDP."
Joshua C. Colp [Wed, 18 Dec 2019 11:38:29 +0000 (05:38 -0600)]
Merge "res_pjsip_session: Set stream state on created streams for incoming SDP."

16 months agosip_to_pjsip.py: Fix trustrpid typo
Pascal Cadotte Michaud [Tue, 17 Dec 2019 13:38:45 +0000 (08:38 -0500)]
sip_to_pjsip.py: Fix trustrpid typo

ASTERISK-28664 #close

Change-Id: I6c28b1002fd7075ae0ed36f026f8c1855c9418a6

16 months agoapp_chanisavail/cdr: ChanIsAvail sometimes fails to deactivate CDR.
Frederic LE FOLL [Wed, 27 Nov 2019 17:34:24 +0000 (18:34 +0100)]
app_chanisavail/cdr: ChanIsAvail sometimes fails to deactivate CDR.

Temporary channel lifespan is very short and CDR deactivation request
through ast_cdr_set_property() may happen when CDR is not available
yet. Use CDR_PROP() dialplan function instead, it will first wait
for pending CDR insertion requests to be processed.

ASTERISK-28636

Change-Id: I1cbe09e8d2169c0962c1195133ff260d291f2074

16 months agoMerge "res_pjsip_nat: Restore original contact for REGISTER responses"
George Joseph [Mon, 16 Dec 2019 17:03:47 +0000 (11:03 -0600)]
Merge "res_pjsip_nat: Restore original contact for REGISTER responses"

16 months agoconfigure: Add check for MySQL client bool and my_bool type usage.
Joshua C. Colp [Mon, 16 Dec 2019 12:35:31 +0000 (08:35 -0400)]
configure: Add check for MySQL client bool and my_bool type usage.

Instead of trying to use the defined MySQL client version from the
header use a configure check to determine whether the bool or my_bool
type should be used for defining a boolean.

ASTERISK-28604

Change-Id: Id2225b3785115de074c50c123ff1a68005b4a9c7

17 months agoconfbridge: Add support for specifying maximum sample rate.
Joshua C. Colp [Thu, 12 Dec 2019 00:03:46 +0000 (00:03 +0000)]
confbridge: Add support for specifying maximum sample rate.

ConfBridge has the ability to move between different sample
rates for mixing the conference bridge. Up until now there has
only been the ability to set the conference bridge to mix at
a specific sample rate, or to let it move between sample rates
as necessary. This change adds the ability to configure a
conference bridge with a maximum sample rate so it can move
between sample rates but only up to the configured maximum.

ASTERISK-28658

Change-Id: Idff80896ccfb8a58a816e4ce9ac4ebde785963ee

17 months agoMerge "PJSIP_CONTACT: add missing argument documentation"
Friendly Automation [Mon, 16 Dec 2019 12:56:16 +0000 (06:56 -0600)]
Merge "PJSIP_CONTACT: add missing argument documentation"

17 months agores_pjsip_session: Set stream state on created streams for incoming SDP.
Joshua C. Colp [Mon, 16 Dec 2019 11:23:07 +0000 (07:23 -0400)]
res_pjsip_session: Set stream state on created streams for incoming SDP.

A previous review, 13174, made a change whereby on an incoming offer SDP
the pending topology was initialized to the configured. This caused a problem
for bundle with WebRTC where bundle could reference a stream that did not
actually exist if the configuration had both audio and video but the
offer SDP only contained audio.

This change undoes that review and instead fixes the original problem it
sought to solve by setting the state of created streams based on the
contents of the offer SDP. This way the stream state is not inactive
until negotiation later completes.

ASTERISK-28659

Change-Id: Ic5ae5a86437d3e686ac5afd91d133cc916198355

17 months agores_fax: wrap v21 detected Asterisk initiated negotiation with config option
Kevin Harwell [Fri, 13 Dec 2019 19:46:17 +0000 (13:46 -0600)]
res_fax: wrap v21 detected Asterisk initiated negotiation with config option

A previous patch:

Gerrit Change-Id: I73bb24799bfe1a48adae9c034a2edbae54cc2a39

made it so a T.38 Gateway tries to negotiate with both sides by sending T.38
negotiation request to both endpoints supported T.38 versus the previous
behavior of forwarding negotiation to the "other" channel once a preamble
was detected.

This had the unfortunate side effect of breaking some setups. Specifically
ones that set the max datagram option on an endpoint configuration (configured
max datagram was not propagated since Asterisk now initiates negotiations).

This patch adds a configuration option, "negotiate_both", that when enabled
makes it so Asterisk initiates the negotiation requests to both endpoints vs.
the previous behavior of waiting, and forwarding the request.

The default is disabled keeping with the old behavior.

ASTERISK-28660

Change-Id: I5deb875f3485e20bc75119ec743090655d864a1a

17 months agoACL: ast_apply_acl_nolog - identical to ast_apply_acl but without logging.
Jaco Kroon [Wed, 4 Dec 2019 08:35:52 +0000 (10:35 +0200)]
ACL: ast_apply_acl_nolog - identical to ast_apply_acl but without logging.

Due to use in res_rtp_asterisk there is a need to be able to apply an
ACL without logging any invalid/denies.  It's probably sensible to at
least validate the ACL once directly after load and report invalid ACLs.

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

17 months agoPJSIP_CONTACT: add missing argument documentation
Pascal Cadotte Michaud [Wed, 11 Dec 2019 16:52:31 +0000 (11:52 -0500)]
PJSIP_CONTACT: add missing argument documentation

add missing argument "rtt" and "status" to the documentation

The change to the dtd file allow an enumlist to contain one or many
configOptionToEnum or enum.

This is different from the previous patch I submitted when you could have a
configOptionToEnum or (a configOptionToEnum followed by one or manu enums) or
(one or many enums)

ASTERISK-28626

Change-Id: Ia71743ee7ec813f40297b0ddefeee7909db63b6d

17 months agoMerge "Revert "PJSIP_CONTACT: add missing argument documentation""
George Joseph [Wed, 11 Dec 2019 16:36:58 +0000 (10:36 -0600)]
Merge "Revert "PJSIP_CONTACT: add missing argument documentation""

17 months agoRevert "PJSIP_CONTACT: add missing argument documentation"
Joshua Colp [Wed, 11 Dec 2019 13:01:32 +0000 (07:01 -0600)]
Revert "PJSIP_CONTACT: add missing argument documentation"

This reverts commit 7e3015d77913accad9b1dcd200ceec30e52bf445.

Reason for revert: Regression in XML validation.

validity error : Content model of enumlist is not determinist:
(configOptionToEnum | (configOptionToEnum , enum+) | enum+)

As we are preparing to do releases and this is not critical
I am reverting this for now until resolved.

Change-Id: I30c2295f9d7f0a0475674ee77071a7ebabf5b83f

17 months agores_rtp_asterisk: Add frame list cleanups to ast_rtp_read
George Joseph [Wed, 4 Dec 2019 21:01:22 +0000 (14:01 -0700)]
res_rtp_asterisk:  Add frame list cleanups to ast_rtp_read

In Asterisk 16+, there are a few places in ast_rtp_read where we've
allocated a frame list but return a null frame instead of the list.
In these cases, any frames left in the list won't be freed.  In the
vast majority of the cases, the list is empty when we return so
there's nothing to free but there have been leaks reported in the
wild that can be traced back to frames left in the list before
returning.

The escape paths now all have logic to free frames left in the
list.

ASTERISK-28609
Reported by: Ted G

Change-Id: Ia1d7075857ebd26b47183c44b1aebb0d8f985f7a

17 months agoMerge "res_pjsip_registrar.c: Prevent potential double free if AOR is not found"
George Joseph [Mon, 9 Dec 2019 17:47:43 +0000 (11:47 -0600)]
Merge "res_pjsip_registrar.c: Prevent potential double free if AOR is not found"

17 months agochan_sip: in case of tcp/tls, be less annoying about tx errors.
Jaco Kroon [Wed, 4 Dec 2019 14:35:35 +0000 (16:35 +0200)]
chan_sip:  in case of tcp/tls, be less annoying about tx errors.

chan_sip.c:3782 __sip_xmit: sip_xmit of 0x7f1478069230 (len 600) to
213.150.203.60:1492 returned -2: Interrupted system call

returned -2 implies this wasn't actually an OS error, so errno makes no
sense either.  Internal error was already logged higher up, and -2
generally means that either there isn't a valid connection available, or
the pipe notification failed, and that is already correctly logged.

ASTERISK-28651 #close

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

17 months agoMerge "app_queue: Fix old confusing comment about when the members are called"
Friendly Automation [Fri, 6 Dec 2019 19:33:26 +0000 (13:33 -0600)]
Merge "app_queue: Fix old confusing comment about when the members are called"

17 months agores_pjsip_nat: Restore original contact for REGISTER responses
George Joseph [Mon, 26 Aug 2019 02:20:13 +0000 (20:20 -0600)]
res_pjsip_nat: Restore original contact for REGISTER responses

RFC3261 Section 10 "Registrations", specifically paragraph
"10.2.4: Refreshing Bindings", states that a user agent compares
each contact address (in a 200 REGISTER response) to see if it
created the contact.  If the Asterisk endpoint has the
rewrite_contact option set however, the contact host and port sent
back in the 200 response will be the rewritten one and not the
one sent by the user agent.  This prevents the user agent from
matching its own contact.  Some user agents get very upset when
this happens and will not consider the registration successful.
While this is rare, it is acceptable behavior especially if more
than 1 user agent is allowed to register to a single endpoint/aor.

This commit updates res_pjsip_nat (where rewrite_contact is
implemented) to store the original incoming Contact header in
a new "x-ast-orig-host" URI parameter before rewriting it, and to
restore the original host and port to the Contact headers in the
outgoing response.

This is only done if the request is a REGISTER and rewrite_contact
is enabled.

pjsip_message_filter was also updated to ensure that if a request
comes in with any existing x-ast-* URI parameters, we remove them
so they don't conflict.  Asterisk will never send a request
with those headers in it but someone might just decide to add them
to a request they craft and send to Asterisk.

NOTE: If a device changes its contact address and registers again,
it's a NEW registration.  If the device didn't unregister the
original registration then all existing behavior based
on aor/remove_existing and aor/max_contacts apply.

ASTERISK-28502
Reported-by: Ross Beer

Change-Id: Idc263ad2d2d7bd8faa047e5804d96a5fe1cd282e

17 months agoMerge "res_pjsip_outbound_registration: add support for SRV failover"
Friendly Automation [Fri, 6 Dec 2019 15:30:20 +0000 (09:30 -0600)]
Merge "res_pjsip_outbound_registration: add support for SRV failover"

17 months agoMerge "res_pjsip_registrar.c: Prevent possible buffer overflow with domain aliases"
Friendly Automation [Fri, 6 Dec 2019 15:17:49 +0000 (09:17 -0600)]
Merge "res_pjsip_registrar.c: Prevent possible buffer overflow with domain aliases"

17 months agoMerge "channel.c: Resolve issue with receiving SIP INFO packets for DTMF"
Friendly Automation [Fri, 6 Dec 2019 14:46:26 +0000 (08:46 -0600)]
Merge "channel.c: Resolve issue with receiving SIP INFO packets for DTMF"

17 months agoMerge "chan_sip+native_bridge_rtp: no directmedia for ptime other than default ptime."
Joshua Colp [Thu, 5 Dec 2019 13:53:56 +0000 (07:53 -0600)]
Merge "chan_sip+native_bridge_rtp: no directmedia for ptime other than default ptime."

17 months agoMerge "PJSIP_CONTACT: add missing argument documentation"
Friendly Automation [Thu, 5 Dec 2019 00:25:19 +0000 (18:25 -0600)]
Merge "PJSIP_CONTACT: add missing argument documentation"

17 months agoMerge "res_pjsip_session.c: Prevent use-after-free with TEST_FRAMEWORK enabled"
Kevin Harwell [Thu, 5 Dec 2019 00:03:18 +0000 (18:03 -0600)]
Merge "res_pjsip_session.c: Prevent use-after-free with TEST_FRAMEWORK enabled"

17 months agoMerge "parking: Fall back to parker channel name even if it matches parkee."
Friendly Automation [Wed, 4 Dec 2019 23:19:24 +0000 (17:19 -0600)]
Merge "parking: Fall back to parker channel name even if it matches parkee."

17 months agores_pjsip_registrar.c: Prevent potential double free if AOR is not found
Sean Bright [Wed, 4 Dec 2019 21:26:46 +0000 (16:26 -0500)]
res_pjsip_registrar.c: Prevent potential double free if AOR is not found

The simple fix here is simply to NULL out username and password after we call
ast_free on them. Unfortunately, I noticed that we weren't checking for
allocation failures for username and password, and adding those checks made
things noisy and cumbersome.

So instead we partially rollback the recent LGTM patch, and move the alloca
calls into find_aor_name().

ASTERISK-28641 #close
Reported by: Ross Beer

Change-Id: Ic9d01624e717a020be0b0aee31f0814e7f1ffbe2

17 months agores_pjsip_registrar.c: Prevent possible buffer overflow with domain aliases
Sean Bright [Wed, 4 Dec 2019 21:12:39 +0000 (16:12 -0500)]
res_pjsip_registrar.c: Prevent possible buffer overflow with domain aliases

We're appropriately sizing the id_domain_alias buffer, but then copying the data
into the id_domain one. We were then using the uninitialized id_domain_alias
buffer we just allocated.

This is ASTERISK~28641 adjacent, but significant enough to warrant its own
patch.

Change-Id: I81c38724d18deab8c6573153e2b99dbb6e2f33d9

17 months agochan_sip: voice frames are no longer transmitted after emitting a COLP
Jean Aunis [Tue, 3 Dec 2019 11:58:26 +0000 (12:58 +0100)]
chan_sip: voice frames are no longer transmitted after emitting a COLP

The SIP transaction state was reset when emitting an UPDATE or a re-INVITE
related to a COLP, preventing RTP packets to be emitted.

ASTERISK-28647

Change-Id: Ie7a30fa7a97f711e7ba6cc17f221a0993d48bd8b

17 months agochan_sip+native_bridge_rtp: no directmedia for ptime other than default ptime.
Frederic LE FOLL [Wed, 27 Nov 2019 18:11:33 +0000 (19:11 +0100)]
chan_sip+native_bridge_rtp: no directmedia for ptime other than default ptime.

During capabilities selection (joint capabilities of us and peer,
configured capability for this peer, or general configured
capabilities), if sip_new() does not keep framing information,
then directmedia activation will fail for any framing different
from default framing.

ASTERISK-28637

Change-Id: I99257502788653c2816fc991cac7946453082466

17 months agoapp_queue: Fix old confusing comment about when the members are called
Walter Doekes [Wed, 4 Dec 2019 09:33:44 +0000 (10:33 +0100)]
app_queue: Fix old confusing comment about when the members are called

ASTERISK-28644

Change-Id: I2771a931d00a8fc2b9f9a4d1a33ea8f1ad24e06b

17 months agores_pjsip_session.c: Prevent use-after-free with TEST_FRAMEWORK enabled
Sean Bright [Tue, 3 Dec 2019 21:42:00 +0000 (16:42 -0500)]
res_pjsip_session.c: Prevent use-after-free with TEST_FRAMEWORK enabled

We need to copy the endpoint name before we call ao2_cleanup() on it,
otherwise we might try to access memory that has been reclaimed.

ASTERISK-28445 #close
Reported by: Bernhard Schmidt

Change-Id: I404b952608aa606e0babd3c4108346721fb726b3

17 months agoMerge "media_cache.c: Various CLI improvements"
George Joseph [Mon, 2 Dec 2019 22:01:57 +0000 (16:01 -0600)]
Merge "media_cache.c: Various CLI improvements"

17 months agochannel.c: Resolve issue with receiving SIP INFO packets for DTMF
George Joseph [Fri, 22 Nov 2019 16:39:36 +0000 (09:39 -0700)]
channel.c: Resolve issue with receiving SIP INFO packets for DTMF

The problem is essentially the same as in ASTERISK~28245. Besides
the direct media scenario we have an additional scenario where a
special client is involved. This device mutes audio by default in
transmit direction (no rtp frames) and activates audio only by a
foot switch. In this situation dtmf input (pin for conferences,
transfer features codes , etc) using SIP INFO mode is not
understood properly especially when SIP INFO messages are sent
quickly.

This patch ensures that SIP INFO frames are properly queued and
processed in the above scenario. The patch also corrects situations
where successive dtmf events are received quicker than the
signalled event duration (plus minimum gap/pause) allows, i.e. DTMF
events have to be buffered in the ast channel read queue and
emulation has to be processed asynchronously at slower speed.

Reported by: Thomas Arimont
patches:
  trigger_dtmf_emulation.patch submitted by Thomas Arimont (license 5525)

Change-Id: I309bf61dd065c9978c8e48f5b9a936ab47de64c2

17 months agoCI: Turn off shallow cloning altogether
George Joseph [Mon, 2 Dec 2019 12:48:01 +0000 (05:48 -0700)]
CI: Turn off shallow cloning altogether

Change-Id: I73ed4aef33a92f20080128aafc34e19fd4457196

17 months agoMerge "core: Improve MALLOC_DEBUG for frames."
Joshua Colp [Mon, 2 Dec 2019 12:45:24 +0000 (06:45 -0600)]
Merge "core: Improve MALLOC_DEBUG for frames."

17 months agoparking: Fall back to parker channel name even if it matches parkee.
Joshua Colp [Mon, 25 Nov 2019 12:55:27 +0000 (12:55 +0000)]
parking: Fall back to parker channel name even if it matches parkee.

ASTERISK-28631

Change-Id: Ia74d084799fbb9bee3403e30d2391aacd46243cc

17 months agomedia_cache.c: Various CLI improvements
Sean Bright [Fri, 22 Nov 2019 21:31:29 +0000 (16:31 -0500)]
media_cache.c: Various CLI improvements

* Use ast_cli_completion_add() to improve performance when large number of
  cached items are present.

* Only complete one URI for commands that only accept a single URI.

* Change command documentation to wrap at 80 characters to improve
  readability.

Change-Id: Iedb0a2c3541e49561bc231dca2dcc0ebd8612902

17 months agores_pjsip_t38: T.38 error correction mode selection at 200 ok received
Salah Ahmed [Fri, 15 Nov 2019 17:34:26 +0000 (11:34 -0600)]
res_pjsip_t38: T.38 error correction mode selection at 200 ok received

if asterisk offer T38 SDP with none error correction scheme and
the endpoint respond with redundancy EC scheme, asterisk switch
to that mode. Since we configure the endpoint as none EC mode
we should not switch to any other mode except none.
following logic implemented in code.

1. If asterisk offer none, and anything except none in answer
   will be ignored.
2. If asterisk offer fec, answer with fec, redundancy and none will
   be accepted.
3. If asterisk offer redundancy, answer with redundancy and none
   will be accepted.

ASTERISK-28621

Change-Id: I343c62253ea4c8b7ee17abbfb377a4d484a14b19

17 months agoMerge "chan_sip.c: Prevent address change on unauthenticated SIP request."
Benjamin Keith Ford [Thu, 21 Nov 2019 19:55:03 +0000 (13:55 -0600)]
Merge "chan_sip.c: Prevent address change on unauthenticated SIP request."

17 months agochan_sip.c: Prevent address change on unauthenticated SIP request.
Ben Ford [Mon, 21 Oct 2019 19:55:06 +0000 (14:55 -0500)]
chan_sip.c: Prevent address change on unauthenticated SIP request.

If the name of a peer is known and a SIP request is sent using that
peer's name, the address of the peer will change even if the request
fails the authentication challenge. This means that an endpoint can
be altered and even rendered unusuable, even if it was in a working
state previously. This can only occur when the nat option is set to the
default, or auto_force_rport.

This change checks the result of authentication first to ensure it is
successful before setting the address and the nat option.

ASTERISK-28589 #close

Change-Id: I581c5ed1da60ca89f590bd70872de2b660de02df

17 months agomanager.c: Prevent the Originate action from running the Originate app
George Joseph [Thu, 24 Oct 2019 17:41:23 +0000 (11:41 -0600)]
manager.c:  Prevent the Originate action from running the Originate app

If an AMI user without the "system" authorization calls the
Originate AMI command with the Originate application,
the second Originate could run the "System" command.

Action: Originate
Channel: Local/1111
Application: Originate
Data: Local/2222,app,System,touch /tmp/owned

If the "system" authorization isn't set, we now block the
Originate app as well as the System, Exec, etc. apps.

ASTERISK-28580
Reported by: Eliel Sardañons

Change-Id: Ic4c9dedc34c426f03c8c14fce334a71386d8a5fa

17 months agoMerge "chan_dahdi: PRI span status may stay "Down, Active" after a short alarm"
Friendly Automation [Thu, 21 Nov 2019 15:23:15 +0000 (09:23 -0600)]
Merge "chan_dahdi: PRI span status may stay "Down, Active" after a short alarm"

17 months agoMerge "app_senddtmf: Add receive mode to AMI Action PlayDTMF"
George Joseph [Thu, 21 Nov 2019 15:18:54 +0000 (09:18 -0600)]
Merge "app_senddtmf: Add receive mode to AMI Action PlayDTMF"

17 months agoPJSIP_CONTACT: add missing argument documentation
Pascal Cadotte Michaud [Thu, 21 Nov 2019 13:24:58 +0000 (08:24 -0500)]
PJSIP_CONTACT: add missing argument documentation

add missing argument "rtt" and "status" to the documentation

ASTERISK-28626
Change-Id: I8419e4c8203e411b87d93dc395acdbcf7526dedf

17 months agoMerge "app_amd: Fixed timeout issue"
Kevin Harwell [Wed, 20 Nov 2019 22:15:31 +0000 (16:15 -0600)]
Merge "app_amd: Fixed timeout issue"

17 months agores_pjsip_outbound_registration: add support for SRV failover
Kevin Harwell [Wed, 20 Nov 2019 18:56:08 +0000 (12:56 -0600)]
res_pjsip_outbound_registration: add support for SRV failover

ASTERISK-28624

Change-Id: I8da7c300dd985ab7b10dbd5194aff2f737808561

17 months agoMerge "func_curl.c: Support custom http headers"
Friendly Automation [Wed, 20 Nov 2019 15:57:12 +0000 (09:57 -0600)]
Merge "func_curl.c: Support custom http headers"

17 months agoMerge "res_pjsip_registrar: Fix uninitlized variable warning"
Friendly Automation [Wed, 20 Nov 2019 14:00:46 +0000 (08:00 -0600)]
Merge "res_pjsip_registrar: Fix uninitlized variable warning"

17 months agoCI: Fix missing script block in jenkinsfiles
George Joseph [Tue, 19 Nov 2019 18:11:06 +0000 (11:11 -0700)]
CI: Fix missing script block in jenkinsfiles

Change-Id: I9f44a3d5085ea7880fad1a3883a4820907e29ea3
(cherry picked from commit 95213b01d2d5e72e38b40c30fa5d0c8cf4b37b16)

17 months agoCI: Fix missing script block in jenkinsfiles
George Joseph [Tue, 19 Nov 2019 17:40:09 +0000 (10:40 -0700)]
CI: Fix missing script block in jenkinsfiles

Change-Id: Ib4b6e4887695f230ea7a5b0c879b29fc5a13be4f
(cherry picked from commit d60f23ecbdb748b188da424c92335152941c7673)
(cherry picked from commit ce8a23fdf966dc6824678f3cb722753db06baa7a)
(cherry picked from commit f0d1ce50afd25a1269e680b90c8bb612bd543565)

17 months agoCI: Increase clone depth and do better cleanup
George Joseph [Tue, 19 Nov 2019 14:51:56 +0000 (07:51 -0700)]
CI: Increase clone depth and do better cleanup

The original clone depth of 10 was causing the need to rebase
changes whose parent was older than the 10 commits.  The clone
depth has been increased to 100.

Workspace cleanup was only happening for successful builds which
wasn't enough to keep the 8G workspace in-memory drives on the
docker slaves from filling up.  Now the workspaces are cleaned up
after every build regardless of success/failure.  If you need to
preserve builds temporarily, you can log into Jenkins/Manage
Jenkins/Configure System and change the CLEANUP_WS_* environment
variable for the job type you're troubleshooting to "FALSE".

Change-Id: I0d7366e87cea714e5dbc9488caf718802fce75ca

17 months agoMerge "serializer: set high/low alert levels on whole pool"
Friendly Automation [Tue, 19 Nov 2019 16:18:32 +0000 (10:18 -0600)]
Merge "serializer: set high/low alert levels on whole pool"

17 months agores_pjsip_registrar: Fix uninitlized variable warning
Sean Bright [Tue, 19 Nov 2019 15:31:59 +0000 (10:31 -0500)]
res_pjsip_registrar: Fix uninitlized variable warning

Fixes: error: ‘domain_name’ may be used uninitialized in this function

Found with gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008

Change-Id: I44413b49ea1205aa25538142161deb73883c79e8

17 months agoMerge "parking: Fix case where we can't get the parker."
George Joseph [Tue, 19 Nov 2019 15:22:45 +0000 (09:22 -0600)]
Merge "parking: Fix case where we can't get the parker."

17 months agoapp_amd: Fixed timeout issue
Michael Cargile [Tue, 5 Nov 2019 18:16:48 +0000 (13:16 -0500)]
app_amd: Fixed timeout issue

ASTERISK_28143 attempted to fix an issue where calls with no audio would never
timeout. It did so by adding AST_FRAME_NULL as a frame type to process in its
calculations. Unfortunately these frames seem to show up at irregular time
intervals. This resulted in app_amd returning prematurely most of the time.

* Removed AST_FRAME_NULL from the calculations
* Added a check to see how much time has actually passed since app_amd began

ASTERISK-28608

Change-Id: I642a21b02d389b17e40ccd5357754b034c3daa42

17 months agochan_dahdi: PRI span status may stay "Down, Active" after a short alarm
Frederic LE FOLL [Thu, 7 Nov 2019 17:54:22 +0000 (18:54 +0100)]
chan_dahdi: PRI span status may stay "Down, Active" after a short alarm

Upon a short PRI disconnection, libpri may maintain Q.921 layer 'up' and
may thus not send PRI_EVENT_DCHAN_DOWN / PRI_EVENT_DCHAN_UP events.
If pri_event_alarm() clears DCHAN_UP status bit upon alarm detection
and no Q.921 reconnection sequence occurs, chan_dahdi will keep
seeing span status "Down" at the end of alarm.

This patch modifies pri_event_alarm() in order to keep DCHAN_UP bit
unchanged. libpri will send a PRI_EVENT_DCHAN_DOWN event if it detects
a disconnection of Q.921 layer and this will clear DCHAN_UP if required.

ASTERISK-28615

Change-Id: Ibe27df4971fd4c82cc6850020bce4a8b2692c996

17 months agoapp_senddtmf: Add receive mode to AMI Action PlayDTMF
lvl [Thu, 7 Nov 2019 17:05:39 +0000 (17:05 +0000)]
app_senddtmf: Add receive mode to AMI Action PlayDTMF

ASTERISK-28614

Change-Id: I183501297ae1dc294ae56b34acac9b0343eb2664

17 months agoMerge "res_rtp_asterisk: Always return provided DTLS packet length."
George Joseph [Mon, 18 Nov 2019 19:04:05 +0000 (13:04 -0600)]
Merge "res_rtp_asterisk: Always return provided DTLS packet length."

17 months agoMerge "func_env: Prevent FILE() from reading garbage at end-of-file"
Friendly Automation [Mon, 18 Nov 2019 18:38:40 +0000 (12:38 -0600)]
Merge "func_env: Prevent FILE() from reading garbage at end-of-file"

17 months agoMerge "various files - fix some alerts raised by lgtm code analysis"
George Joseph [Mon, 18 Nov 2019 17:42:37 +0000 (11:42 -0600)]
Merge "various files - fix some alerts raised by lgtm code analysis"

17 months agoserializer: set high/low alert levels on whole pool
Alexei Gradinari [Thu, 7 Nov 2019 16:56:57 +0000 (11:56 -0500)]
serializer: set high/low alert levels on whole pool

The current code sets alert levels starting from index 1.
Need to set on whole pool starting from index 0.

Change-Id: I5decbb43160954fb9a512f04302637fc666b6f5d

17 months agores_rtp_asterisk: Always return provided DTLS packet length.
Joshua Colp [Thu, 14 Nov 2019 10:19:04 +0000 (06:19 -0400)]
res_rtp_asterisk: Always return provided DTLS packet length.

OpenSSL can not tolerate if the packet sent out does not
match the length that it provided to the sender. This change
lies and says that each time the full packet was sent. If
a problem does occur then a retransmission will occur as
appropriate.

ASTERISK-28576

Change-Id: Id42455b15c9dc4eb987c8c023ece6fbf3c22a449

17 months agofunc_env: Prevent FILE() from reading garbage at end-of-file
Sean Bright [Wed, 13 Nov 2019 20:25:22 +0000 (15:25 -0500)]
func_env: Prevent FILE() from reading garbage at end-of-file

If the last line of a file does not have a terminating EOL sequence, we
potentially add garbage to the value returned from the FILE() function.

There is no overflow potential here as we are reading from a buffer of a
known size, we are just reading too much of it.

ASTERISK-26481 #close

Change-Id: I50dd4fcf416fb3c83150040a1a79a59d9eb1ae01

17 months agobridge_softmix: clear hold when joining a softmix bridge
Kevin Harwell [Wed, 13 Nov 2019 23:24:48 +0000 (17:24 -0600)]
bridge_softmix: clear hold when joining a softmix bridge

MOH continues to play to a channel if that channel was on hold prior to
entering a softmix bridge. MOH will not stop even if the original "holder"
attempts an unhold.

For the most part a softmix bridge ignores holds, so a participating channel
shouldn't join while on hold. This patch checks to see if the channel joining
the softmix bridge is currently on hold. If so then it indicates an unhold.

ASTERISK-28618

Change-Id: I66ccd4efc80f5b4c3dd68186b379eb442916392b

17 months agovarious files - fix some alerts raised by lgtm code analysis
Kevin Harwell [Wed, 23 Oct 2019 17:36:17 +0000 (12:36 -0500)]
various files - fix some alerts raised by lgtm code analysis

This patch fixes several issues reported by the lgtm code analysis tool:

https://lgtm.com/projects/g/asterisk/asterisk

Not all reported issues were addressed in this patch. This patch mostly fixes
confirmed reported errors, potential problematic code points, and a few other
"low hanging" warnings or recommendations found in core supported modules.
These include, but are not limited to the following:

* innapropriate stack allocation in loops
* buffer overflows
* variable declaration "hiding" another variable declaration
* comparisons results that are always the same
* ambiguously signed bit-field members
* missing header guards

Change-Id: Id4a881686605d26c94ab5409bc70fcc21efacc25

18 months agofunc_curl.c: Support custom http headers
Martin Tomec [Thu, 7 Nov 2019 17:54:06 +0000 (17:54 +0000)]
func_curl.c: Support custom http headers

When user wants to send json data, the default Content-Type header
is incorect (application/x-www-form-urlencoded). This patch allows
to set any custom headers so the Content-Type header can be
overriden. User can set multiple headers by multiple calls of
curlopt(). This approach is not consistent with other parameters,
but is more readable in dialplan than one call with multiple
headers.

ASTERISK-28613

Change-Id: I4dd68c3f4e25362ef941d73a3861f58348dcfbf9

18 months agoparking: Fix case where we can't get the parker.
Joshua Colp [Fri, 15 Nov 2019 10:46:37 +0000 (06:46 -0400)]
parking: Fix case where we can't get the parker.

ASTERISK-28616

Change-Id: Iabe31ae38d01604284fcc5c2438d44e29a32ea4d

18 months agostasis: Don't hold app_registry and session locks unnecessarily
George Joseph [Wed, 6 Nov 2019 11:47:17 +0000 (04:47 -0700)]
stasis: Don't hold app_registry and session locks unnecessarily

resource_events:stasis_app_message_handler() was locking the session,
then attempting to determine if the app had debug enabled which
locked the app_registry container.  res_stasis:__stasis_app_register
was locking the app_registry container then calling app_update
which caused app_handler (which locks the session) to run.
The result was a deadlock.

* Updated resource_events:stasis_app_message_handler() to determine
  if debug was set (which locks the app_registry) before obtaining the
  session lock.

* Updated res_stasis:__stasis_app_register to release the app_registry
  container lock before calling app_update (which locks the sesison).

ASTERISK-28423
Reported by Ross Beer

Change-Id: I58c69d08cb372852a63933608e4d6c3e456247b4

18 months agoMerge "parking: Use channel snapshot instead of channel."
Friendly Automation [Thu, 14 Nov 2019 21:02:47 +0000 (15:02 -0600)]
Merge "parking: Use channel snapshot instead of channel."

18 months agoparking: Use channel snapshot instead of channel.
Joshua Colp [Tue, 12 Nov 2019 11:00:44 +0000 (07:00 -0400)]
parking: Use channel snapshot instead of channel.

There exists a scenario where a thread can hold a lock on the
channels container while trying to lock a bridge. At the same
time another thread can hold the lock for said bridge while
attempting to retrieve a channel. This causes a deadlock.

This change fixes this scenario by retrieving a channel snapshot
instead of a channel, as information present in the snapshot
is all that is needed.

ASTERISK-28616

Change-Id: I68ceb1d62c7378addcd286e21be08a660a7cecf2

18 months agores_pjsip_session: initialize pending's topology to endpoint's
Kevin Harwell [Tue, 12 Nov 2019 18:36:37 +0000 (12:36 -0600)]
res_pjsip_session: initialize pending's topology to endpoint's

Found during some testing, there is a race condition between selecting an
appropriate bridge type for a call versus the applying of media on the callee's
session. In some instances a native bridge type would have been chosen, but
due to the callee's media not yet being established at bridge compatibility
check time the simple bridge type is picked instead.

When using chan_pjsip this initiates a topology change event. The topologies
are then compared for the two sessions. However, when the topology was created
for the caller its streams are initialized to "inactive". This topology is then
used as a base when creating the callee's topology, and streams. Soon after
the caller's topology's stream(s) get updated based on the sdp (get set to
sendrecv in the failing scenario).

Now when the topology change event is raised, and the two topologies are
compared, the comparison fails due to a stream state mismatch (sendrecv vs
inactive). And since they differ a reinvite is sent out (to the caller in
this case).

This patch makes it such that when the caller's topology is initially created
it gets created based on its configured endpoint's media topology. When the
endpoint's topology is created its stream's state(s) are initialized to
sendrecv instead of inactive. Subsequently, now when the callee's topology is
created its topology streams are now initialized to sendrecv. Thus when the
topology change event occurs due to the mentioned scenario the stream states
match for the given sessions, and the reinvite is not sent unless due to some
other valid mismatch.

Note, this patch only changes one pending media state's creation point. It's
possible other places *could* be changed, however for now it was deemed best
to only alter what's here.

Change-Id: I6ba3a6a75f64824a1b963044c37acbe951c389c7

18 months agocore: Improve MALLOC_DEBUG for frames.
Corey Farrell [Fri, 8 Nov 2019 15:20:13 +0000 (10:20 -0500)]
core: Improve MALLOC_DEBUG for frames.

* Pass caller information to frame allocation functions.
* Disable caching as it interfers with MALLOC_DEBUG reporting.
* Stop using ast_calloc_cache.

Change-Id: Id343cd80a3db941d2daefde2a060750fea8cd260

18 months agoBuild: Fix compile issues with seldom used modules
George Joseph [Tue, 29 Oct 2019 13:23:54 +0000 (07:23 -0600)]
Build:  Fix compile issues with seldom used modules

The following modules needed tweaks for API changes.

addons/cdr_mysql.c
addons/chan_ooh323.c
apps/app_meetme.c

ASTERISK-28604

Change-Id: Ib40e513ae55b5114be035cdc929abb6a8ce2d06d

18 months agores_pjsip_outbound_registration: Extend documentation for "max_retries".
Joshua Colp [Fri, 25 Oct 2019 11:46:41 +0000 (11:46 +0000)]
res_pjsip_outbound_registration: Extend documentation for "max_retries".

If the "max_retries" option is set to 0 then upon failure no
further attemps are made, so explicitly document the behavior.

ASTERISK-28602

Change-Id: I1e30daae9dd6c49ce18744164214d3def505acbf

18 months agoMerge "res_ari_events: Add module reference when a WebSocket is open."
Joshua Colp [Tue, 29 Oct 2019 15:25:06 +0000 (10:25 -0500)]
Merge "res_ari_events: Add module reference when a WebSocket is open."

18 months agores_calendar: Resolve memory leak on calendar destruction
Sean Bright [Thu, 24 Oct 2019 14:15:14 +0000 (10:15 -0400)]
res_calendar: Resolve memory leak on calendar destruction

Calling ne_uri_parse allocates memory that needs to be freed with a
corresponding call to ne_uri_free.

ASTERISK-28572 #close

Change-Id: I8a6834da27000a6807d89cb7a157b2a88fcb5e61

18 months agores_ari_events: Add module reference when a WebSocket is open.
Joshua Colp [Thu, 24 Oct 2019 10:21:31 +0000 (07:21 -0300)]
res_ari_events: Add module reference when a WebSocket is open.

This change ensures that the module isn't unloaded when a
WebSocket is open. Previously it was possible to unload the
module manually or during shutdown which could cause a crash
when any active WebSockets were terminated.

ASTERISK-28585

Change-Id: I85c71ab112f99875b586419a34c08c8b34c14c5c

18 months agoMerge "ExternalMedia: Change return object from ExternalMedia to Channel"
George Joseph [Mon, 21 Oct 2019 18:53:38 +0000 (13:53 -0500)]
Merge "ExternalMedia:  Change return object from ExternalMedia to Channel"

18 months agoMerge "utils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN"
Kevin Harwell [Mon, 21 Oct 2019 18:51:49 +0000 (13:51 -0500)]
Merge "utils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN"

18 months agoMerge "app_voicemail.c: Support multiple file formats for forwarded messages."
Joshua Colp [Mon, 21 Oct 2019 15:32:17 +0000 (10:32 -0500)]
Merge "app_voicemail.c: Support multiple file formats for forwarded messages."

18 months agoMerge "Crash during "pjsip show channelstats" execution"
Friendly Automation [Mon, 21 Oct 2019 13:01:48 +0000 (08:01 -0500)]
Merge "Crash during "pjsip show channelstats" execution"

18 months agoutils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN
Sean Bright [Fri, 18 Oct 2019 18:47:20 +0000 (14:47 -0400)]
utils.h: Set lower bound for thread stack size to PTHREAD_STACK_MIN

ASTERISK-28590 #close

Change-Id: I51abce00c04d0a06550bda5205580705185b9c1c

18 months agoMerge "README-SERIOUSLY.bestpractices.md: Speling correetions."
Joshua Colp [Fri, 18 Oct 2019 17:54:37 +0000 (12:54 -0500)]
Merge "README-SERIOUSLY.bestpractices.md: Speling correetions."

18 months agoExternalMedia: Change return object from ExternalMedia to Channel
George Joseph [Fri, 18 Oct 2019 11:36:12 +0000 (05:36 -0600)]
ExternalMedia:  Change return object from ExternalMedia to Channel

When we created the External Media addition to ARI we created an
ExternalMedia object to be returned from the channels/externalMedia
REST endpoint.  This object contained the channel object that was
created plus local_address and local_port attributes (which are
also in the Channel variables).  At the time, we thought that
creating an ExternalMedia object would give us more flexibility
in the future but as we created the sample speech to text
application, we discovered that it doesn't work so well with ARI
client libraries that a) don't have the ExternalMedia object
defined and/or b) can't promote the embedded channel structure
to a first-class Channel object.

This change causes the channels/externalMedia REST endpoint to
return a Channel object (like channels/create and channels/originate)
instead of the ExternalMedia object.

Change-Id: If280094debd35102cf21e0a31a5e0846fec14af9

18 months agoCrash during "pjsip show channelstats" execution
Salah Ahmed [Fri, 18 Oct 2019 09:22:22 +0000 (11:22 +0200)]
Crash during "pjsip show channelstats" execution

During execution "pjsip show channelstats" cli command by an
external module asterisk crashed. It seems this is a separate
thread running to fetch and print rtp stats. The crash happened on
the ao2_lock method, just before it going to read the rtp stats on
a rtp instance. According to gdb backtrace log, it seems the
session media was already cleaned up at that moment.

ASTERISK-28578

Change-Id: I3e05980dd4694577be6d39be2c21a5736bae3c6f