]> git.ipfire.org Git - thirdparty/asterisk.git/log
thirdparty/asterisk.git
4 years agores_pjsip_session.c: Fix build when TEST_FRAMEWORK is not defined
Sean Bright [Tue, 15 Sep 2020 21:16:34 +0000 (17:16 -0400)] 
res_pjsip_session.c: Fix build when TEST_FRAMEWORK is not defined

Change-Id: Id4852c26e9c412af8e37b5dd3c15da9453ad3276

4 years agores_pjsip_diversion: implement support for History-Info
Torrey Searle [Thu, 13 Aug 2020 08:34:55 +0000 (10:34 +0200)] 
res_pjsip_diversion: implement support for History-Info

Implemention of History-Info capable of interworking with Diversion
Header following RFC7544

ASTERISK-29027 #close

Change-Id: I2296369582d4b295c5ea1e60bec391dd1d318fa6

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

ASTERISK-28416 #close

Change-Id: I069420875ebdbcaada52d92599a5f7de3cb2cdf4

4 years agores_pjsip_session: Fix issue with COLP and 491
George Joseph [Fri, 11 Sep 2020 16:09:55 +0000 (10:09 -0600)] 
res_pjsip_session: Fix issue with COLP and 491

The recent 491 changes introduced a check to determine if the active
and pending topologies were equal and to suppress the re-invite if they
were. When a re-invite is sent for a COLP-only change, the pending
topology is NULL so that check doesn't happen and the re-invite is
correctly sent. Of course, sending the re-invite sets the pending
topology.  If a 491 is received, when we resend the re-invite, the
pending topology is set and since we didn't request a change to the
topology in the first place, pending and active topologies are equal so
the topologies-equal check causes the re-invite to be erroneously
suppressed.

This change checks if the topologies are equal before we run the media
state resolver (which recreates the pending topology) so that when we
do the final topologies-equal check we know if this was a topology
change request.  If it wasn't a change request, we don't suppress
the re-invite even though the topologies are equal.

ASTERISK-29014

Change-Id: Iffd7dd0500301156a566119ebde528d1a9573314

4 years agodebugging: Add enough to choke a mule
George Joseph [Thu, 20 Aug 2020 20:09:25 +0000 (14:09 -0600)] 
debugging:  Add enough to choke a mule

Added to:
 * bridges/bridge_softmix.c
 * channels/chan_pjsip.c
 * include/asterisk/res_pjsip_session.h
 * main/channel.c
 * res/res_pjsip_session.c

There NO functional changes in this commit.

Change-Id: I06af034d1ff3ea1feb56596fd7bd6d7939dfdcc3

4 years agores_pjsip_session: Handle multi-stream re-invites better
George Joseph [Thu, 20 Aug 2020 16:21:18 +0000 (10:21 -0600)] 
res_pjsip_session:  Handle multi-stream re-invites better

When both Asterisk and a UA send re-invites at the same time, both
send 491 "Transaction in progress" responses to each other and back
off a specified amount of time before retrying. When Asterisk
prepares to send its re-invite, it sets up the session's pending
media state with the new topology it wants, then sends the
re-invite.  Unfortunately, when it received the re-invite from the
UA, it partially processed the media in the re-invite and reset
the pending media state before sending the 491 losing the state it
set in its own re-invite.

Asterisk also was not tracking re-invites received while an existing
re-invite was queued resulting in sending stale SDP with missing
or duplicated streams, or no re-invite at all because we erroneously
determined that a re-invite wasn't needed.

There was also an issue in bridge_softmix where we were using a stream
from the wrong topology to determine if a stream was added.  This also
caused us to erroneously determine that a re-invite wasn't needed.

Regardless of how the delayed re-invite was triggered, we need to
reconcile the topology that was active at the time the delayed
request was queued, the pending topology of the queued request,
and the topology currently active on the session.  To do this we
need a topology resolver AND we need to make stream named unique
so we can accurately tell what a stream has been added or removed
and if we can re-use a slot in the topology.

Summary of changes:

 * bridge_softmix:
   * We no longer reset the stream name to "removed" in
     remove_all_original_streams().  That was causing  multiple streams
     to have the same name and wrecked the checks for duplicate streams.

   * softmix_bridge_stream_sources_update() was checking the old_stream
     to see if it had the softmix prefix and not considering the stream
     as "new" if it did.  If the stream in that slot has something in it
     because another re-invite happened, then that slot in old might
     have a softmix stream but the same stream in new might actually
     be a new one.  Now we check the new_stream's name instead of
     the old_stream's.

 * stream:
   * Instead of using plain media type name ("audio", "video", etc) as
     the default stream name, we now append the stream position to it
     to make it unique.  We need to do this so we can distinguish multiple
     streams of the same type from each other.

   * When we set a stream's state to REMOVED, we no longer reset its
     name to "removed" or destroy its metadata.  Again, we need to
     do this so we can distinguish multiple streams of the same
     type from each other.

 * res_pjsip_session:
   * Added resolve_refresh_media_states() that takes in 3 media states
     and creates an up-to-date pending media state that includes the changes
     that might have happened while a delayed session refresh was in the
     delayed queue.

   * Added is_media_state_valid() that checks the consistency of
     a media state and returns a true/false value. A valid state has:
     * The same number of stream entries as media session entries.
         Some media session entries can be NULL however.
     * No duplicate streams.
     * A valid stream for each non-NULL media session.
     * A stream that matches each media session's stream_num
       and media type.

   * Updated handle_incoming_sdp() to set the stream name to include the
     stream position number in the name to make it unique.

   * Updated the ast_sip_session_delayed_request structure to include both
     the pending and active media states and updated the associated delay
     functions to process them.

   * Updated sip_session_refresh() to accept both the pending and active
     media states that were in effect when the request was originally queued
     and to pass them on should the request need to be delayed again.

   * Updated sip_session_refresh() to call resolve_refresh_media_states()
     and substitute its results for the pending state passed in.

   * Updated sip_session_refresh() with additional debugging.

   * Updated session_reinvite_on_rx_request() to simply return PJ_FALSE
     to pjproject if a transaction is in progress.  This stops us from
     creating a partial pending media state that would be invalid later on.

   * Updated reschedule_reinvite() to clone both the current pending and
     active media states and pass them to delay_request() so the resolver
     can tell what the original intention of the re-invite was.

   * Added a large unit test for the resolver.

ASTERISK-29014

Change-Id: Id3440972943c611a15f652c6c569fa0e4536bfcb

4 years agores_stasis.c: Added video_single option for bridge creation
Sungtae Kim [Sun, 30 Aug 2020 20:42:06 +0000 (22:42 +0200)] 
res_stasis.c: Added video_single option for bridge creation

Currently, it was not possible to create bridge with video_mode single.
This made hard to put the bridge in a vidoe_single mode.
So, added video_single option for Bridge creation using the ARI.
This allows create a bridge with video_mode single.

ASTERISK-29055

Change-Id: I43e720e5c83fc75fafe10fe22808ae7f055da2ae

4 years agorealtime: Increased reg_server character size
Sungtae Kim [Mon, 31 Aug 2020 12:21:09 +0000 (14:21 +0200)] 
realtime: Increased reg_server character size

Currently, the ps_contacts table's reg_server column in realtime database type is varchar(20).
This is fine for normal cases, but if the hostname is longer than 20, it returns error and then
failed to register the contact address of the peer.

Normally, 20 characters limitation for the hostname is fine, but with the cloud env.
So, increased the size to 255.

ASTERISK-29056

Change-Id: Iac52c8c35030303cfa551bb39f410b33bffc507d

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

There's a race condition with bridging where a bridge can be torn down
causing the bridge_channel's ast_channel to become NULL when it's still
needed. This particular case happened with attended transfers, but the
crash occurred when trying to publish a stasis message. Now, the
bridge_channel is locked, a ref to the ast_channel is obtained, and that
ref is passed down the chain.

Change-Id: Ic48715c0c041615d17d286790ae3e8c61bb28814

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

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

Building on ASTERISK-25854. When the device requests hold by sending SDP with attribute recvonly, asterisk places the session in sendonly mode. When the device later requests to resume the call by using a re-INVITE excluding SDP, asterisk needs to change the sendonly mode to sendrecv again.

Change-Id: I60341ce3d87f95869f3bc6dc358bd3e8286477a6

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

Change-Id: Id603b0b03b78eb84c7fca030a08b343c0d5973f9

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

This fixes a bug introduced mistakenly in ASTERISK-25665:
If leave-empty is enabled, a call may sometimes be removed from
a queue without recording it as abandoned.
This causes Asterisk to not generate an abandon event for that
call, and for the queue abandoned counter to be incorrect.

ASTERISK-29043 #close

Change-Id: I1a71b81df78adff59af587f1d8483cf57df430c7

4 years agoast_coredumper: Fix issues with naming
George Joseph [Fri, 28 Aug 2020 14:34:09 +0000 (08:34 -0600)] 
ast_coredumper: Fix issues with naming

If you run ast_coredumper --tarball-coredumps in the same directory
as the actual coredump, tar can fail because the link to the
actual coredump becomes recursive.  The resulting tarball will
have everything _except_ the coredump (which is usually what
you need)

There's also an issue that the directory name in the tarball
is the same as the coredump so if you extract the tarball the
directory it creates will overwrite the coredump.

So:

 * Made the link to the coredump use the absolute path to the
   file instead of a relative one.  This prevents the recursive
   link and allows tar to add the coredump.

 * The tarballed directory is now named <coredump>.output instead
   of just <coredump> so if you expand the tarball it won't
   overwrite the coredump.

Change-Id: I8b3eeb26e09a577c702ff966924bb0a2f9a759ea

4 years agoparking: Copy parker UUID as well.
Joshua C. Colp [Fri, 28 Aug 2020 09:29:23 +0000 (06:29 -0300)] 
parking: Copy parker UUID as well.

When fixing issues uncovered by GCC10 a copy of the parker UUID
was removed accidentally. This change restores it so that the
subscription has the data it needs.

ASTERISK-29042

Change-Id: I7d396a14ea648bd26d3c363dd78e78bd386b544a

4 years agosip_nat_settings: Update script for latest Linux.
Alexander Traud [Wed, 26 Aug 2020 15:43:13 +0000 (17:43 +0200)] 
sip_nat_settings: Update script for latest Linux.

With the latest Linux, 'ifconfig' is not installed on default anymore.
Furthermore, the output of the current net-tools 'ifconfig' changed.
Therefore, parsing failed. This update uses 'ip addr show' instead.
Finally, the service for the external IP changed.

Change-Id: I9b1a7c3f457e3553b50a3e9a55524e40d70245a0

4 years agosamples: Fix keep_alive_interval default in pjsip.conf.
Alexander Traud [Wed, 26 Aug 2020 15:19:55 +0000 (17:19 +0200)] 
samples: Fix keep_alive_interval default in pjsip.conf.

Since ASTERISK_27978 the default is not off but 90 seconds. That change
happened because ASTERISK_27347 disabled the keep-alives in the bundled
PJProject and Asterisk should behave the same as before.

Change-Id: Ie63dc558ade6a5a2b969c30a4bd492d63730dc46

4 years agochan_pjsip: disallow PJSIP_SEND_SESSION_REFRESH pre-answer execution
Kevin Harwell [Mon, 24 Aug 2020 21:26:23 +0000 (16:26 -0500)] 
chan_pjsip: disallow PJSIP_SEND_SESSION_REFRESH pre-answer execution

This patch makes it so if the PJSIP_SEND_SESSION_REFRESH dialplan function
is called on a channel prior to answering a warning is issued and the
function returns unsuccessful.

ASTERISK-28878 #close

Change-Id: I053f767d10cf3b2b898fa9e3e7c35ff07e23c9bb

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

When the ExtensionState AMI action is executed on a pattern matched
hint it can end up adding a new hint if one does not already exist.
This results in a locking order of contexts -> hints -> contexts.

If at the same time a reload is occurring and adding its own hint
it will have a locking order of hints -> contexts.

This results in a deadlock as one thread wants a lock on contexts
that the other has, and the other thread wants a lock on hints
that the other has.

This change enforces a hints -> contexts locking order by explicitly
locking hints in the places where a hint is added when queried for.
This matches the order seen through normal adding of hints.

ASTERISK-29046

Change-Id: I49f027f4aab5d2d50855ae937bcf5e2fd8bfc504

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

Added a new log formatter called "plain" that always prints
file, function and line number if available (even for verbose
messages) and never prints color control characters.  It also
doesn't apply any special formatting for verbose messages.
Most suitable for file output but can be used for other channels
as well.

You use it in logger.conf like so:
debug => [plain]debug
console => [plain]error,warning,debug,notice,pjsip_history
messages => [plain]warning,error,verbose

Change-Id: I4fdfe4089f66ce2f9cb29f3005522090dbb5243d

4 years agores_speech: Bump reference on format object
Nickolay Shmyrev [Fri, 21 Aug 2020 21:53:04 +0000 (23:53 +0200)] 
res_speech: Bump reference on format object

Properly bump reference on format object to avoid memory corruption on double free

ASTERISK-29040 #close

Change-Id: Ic5a7faabfe2ef965ddb024186e1de7ca4542e2a3

4 years agores_pjsip_diversion: handle 181
Torrey Searle [Wed, 22 Jul 2020 08:45:57 +0000 (10:45 +0200)] 
res_pjsip_diversion: handle 181

Adapt the response handler so it also called when 181 is received.
In the case 181 is received, also generate the 181 response.

ASTERISK-29001 #close

Change-Id: I73cfee46a8ca85371280ebdb38674f8fde7510df

4 years agoapp_queue: Member lastpause time reseting
Evandro César Arruda [Fri, 21 Aug 2020 05:05:57 +0000 (02:05 -0300)] 
app_queue: Member lastpause time reseting

This fixes the reseting members lastpause problem when realtime members is being used,
the function rt_handle_member_record was forcing the reset members lastpause because it
does not exist in realtime

ASTERISK-29034 #close

Change-Id: Ic9107e4456732a1f78412a32adb2ef87f5da40b5

4 years agoapp_voicemail: Process urgent messages with mailcmd
Sean Bright [Fri, 21 Aug 2020 14:17:59 +0000 (10:17 -0400)] 
app_voicemail: Process urgent messages with mailcmd

Rather than putting messages into INBOX and then moving them to Urgent
later, put them directly in to the Urgent folder. This prevents
mailcmd from being skipped.

ASTERISK-27273 #close

Change-Id: I49934e093290d308506ab8d45a40ef705c5ae4f5

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

Per the RFC when an outgoing re-INVITE is done we should
only terminate the dialog if a 481 or 408 is received.

ASTERISK-29033

Change-Id: I6c3ff513aa41005d02de0396ba820083e9b18503

4 years agobridge_channel: Ensure text messages are zero terminated
Sean Bright [Wed, 19 Aug 2020 17:29:51 +0000 (13:29 -0400)] 
bridge_channel: Ensure text messages are zero terminated

T.140 data in RTP is not zero terminated, so when we are queuing a text
frame on a bridge we need to ensure that we are passing a zero
terminated string.

ASTERISK-28974 #close

Change-Id: Ic10057387ce30b2094613ea67e3ae8c5c431dda3

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

Two changes of note in this patch:

* Use ast_file_read_dir instead of opendir/readdir/closedir

* If the files list should be sorted, do that at the end rather than as
  we go which improves performance for large lists

Change-Id: Ic7e9c913c0f85754c99c74c9cf6dd3514b1b941f

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

 * Added ast_stream_to_stra and ast_stream_topology_to_stra() macros
   which are shortcuts for
      ast_str_tmp(256, ast_stream_to_str(stream, &STR_TMP))

 * Added the stream position to the string representation of the
   stream.

 * Fixed some formatting in ast_stream_to_str().

Change-Id: Idaf4cb0affa46d4dce58a73a111f35435331cc4b

4 years agoscope_trace: Added debug messages and added additional macros
George Joseph [Wed, 19 Aug 2020 12:37:23 +0000 (06:37 -0600)] 
scope_trace: Added debug messages and added additional macros

The SCOPE_ENTER and SCOPE_EXIT* macros now print debug messages
at the same level as the scope level.  This allows the same
messages to be printed to the debug log when AST_DEVMODE
isn't enabled.

Also added a few variants of the SCOPE_EXIT macros that will
also call ast_log instead of ast_debug to make it easier to
use scope tracing and still print error messages.

Change-Id: I7fe55f7ec28069919a0fc0b11a82235ce904cc21

4 years agochan_sip: Clear ToHost property on peer when changing to dynamic host
Dennis Buteyn [Tue, 18 Feb 2020 12:30:31 +0000 (14:30 +0200)] 
chan_sip: Clear ToHost property on peer when changing to dynamic host

The ToHost parameter was not cleared when a peer's host value was
changed to dynamic. This causes invites to be sent to the original host.

ASTERISK-29011 #close

Change-Id: I9678d512741f71baca8f131a65b7523020b07d5c

4 years agoMakefile: Fix certified version numbers
cmaj [Thu, 6 Aug 2020 17:51:10 +0000 (11:51 -0600)] 
Makefile: Fix certified version numbers

Adds sed before awk to produce reasonable ASTERISKVERSIONNUM
on certified versions of Asterisk eg. 16.8-cert3 is 160803
instead of the previous 00800.

ASTERISK-29021 #close

Change-Id: Icf241df0ff6db09011b8c936a317a84b0b634e16

4 years agoscope_trace: Add/update utilities
George Joseph [Fri, 7 Aug 2020 11:58:38 +0000 (05:58 -0600)] 
scope_trace: Add/update utilities

* Added a AST_STREAM_STATE_END sentinel
* Add ast_stream_to_str()
* Add ast_stream_state_to_str()
* Add ast_stream_get_format_count()
* Add ast_stream_topology_to_str()
* Add ast_stream_topology_get_active_count()
* Add ast_format_cap_append_names()
* Add ast_sip_session_get_name()

Change-Id: I132eb5971ea41509c660f64e9113cda8c9013b0b

4 years agores_musiconhold.c: Prevent crash with realtime MoH
Sean Bright [Thu, 6 Aug 2020 16:41:33 +0000 (12:41 -0400)] 
res_musiconhold.c: Prevent crash with realtime MoH

The MoH class internal file vector is potentially being manipulated by
multiple threads at the same time without sufficient locking. Switch to
a reference counted list and operate on copies where necessary.

ASTERISK-28927 #close

Change-Id: I479c5dcf88db670956e8cac177b5826c986b0217

4 years agovector.h: Fix implementation of AST_VECTOR_COMPACT() for empty vectors
Sean Bright [Tue, 4 Aug 2020 15:51:16 +0000 (11:51 -0400)] 
vector.h: Fix implementation of AST_VECTOR_COMPACT() for empty vectors

The assumed behavior of realloc() - that it was effectively a free() if
its second argument was 0 - is Linux specific behavior and is not
guaranteed by either POSIX or the C specification.

Instead, if we want to resize a vector to 0, do it explicitly.

Change-Id: Ife31d4b510ebab41cb5477fdc7ea4e3138ca8b4f

5 years agopjproject: clone sdp to protect against (nat) modifications
Michael Neuhauser [Tue, 30 Jun 2020 15:40:41 +0000 (17:40 +0200)] 
pjproject: clone sdp to protect against (nat) modifications

PJSIP, UDP transport with external_media_address and session timers
enabled. Connected to SIP server that is not in local net. Asterisk
initiated the connection and is refreshing the session after 150s
(timeout 300s). The 2nd refresh-INVITE triggered by the pjsip timer has
a malformed IP address in its SDP (garbage string). This only happens
when the SDP is modified by the nat-code to replace the local IP address
with the configured external_media_address.
Analysis: the code to modify the SDP (in
res_pjsip_session.c:session_outgoing_nat_hook() and also (redundantly?)
in res_pjsip_sdp_rtp.c:change_outgoing_sdp_stream_media_address()) uses
the tdata->pool to allocate the replacement string. But the same
pjmedia_sdp_stream that was modified for the 1st refresh-INVITE is also
used for the 2nd refresh-INVITE (because it is stored in pjmedia's
pjmedia_sdp_neg structure). The problem is, that at that moment, the
tdata->pool that holds the stringified external_media_address from the
1. refresh-INVITE has long been reused for something else.
Fix by Sauw Ming of pjproject (see
https://github.com/pjsip/pjproject/pull/2476): the local, potentially
modified pjmedia_sdp_stream is cloned in
pjproject/source/pjsip/src/pjmedia/sip_neg.c:process_answer() and the
clone is stored, thereby detaching from the tdata->pool (which is only
released *after* process_answer())

ASTERISK-28973
Reported-by: Michael Neuhauser
Change-Id: I272ac22436076596e06aa51b9fa23fd1c7734a0e

5 years agores_pjsip_session: Ensure reused streams have correct bundle group
George Joseph [Thu, 23 Jul 2020 19:47:25 +0000 (13:47 -0600)] 
res_pjsip_session: Ensure reused streams have correct bundle group

When a bundled stream is removed, its bundle_group is reset to -1.
If that stream is later reused, the bundle parameters on session
media need to be reset correctly it could mistakenly be rebundled
with a stream that was removed and never reused.  Since the removed
stream has no rtp instance, a crash will result.

Change-Id: Ie2b792220f9291587ab5f9fd123145559dba96d7

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

There are various places in Asterisk - specifically in regards to
database integration - where having some kind of UTF-8 validation would
be beneficial. This patch adds:

* Functions to validate that a given string contains only valid UTF-8
  sequences.

* A function to copy a string (similar to ast_copy_string) stopping when
  an invalid UTF-8 sequence is encountered.

* A UTF-8 validator that allows for progressive validation.

All of this is based on the excellent UTF-8 decoder by Björn Höhrmann.
More information is available here:

    https://bjoern.hoehrmann.de/utf-8/decoder/dfa/

The API was written in such a way that should allow us to replace the
implementation later should we determine that we need something more
comprehensive.

Change-Id: I3555d787a79e7c780a7800cd26e0b5056368abf9

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

Statically configured contacts on an AOR don't have an expiration
time so when adding them to the resulting 200 OK if an endpoint
registers ensure they are marked as such.

ASTERISK-28995

Change-Id: I9f0e45eb2ccdedc9a0df5358634a19ccab0ad596

5 years agostasis_bridge.c: Fixed wrong video_mode shown
sungtae kim [Fri, 10 Jul 2020 23:14:53 +0000 (01:14 +0200)] 
stasis_bridge.c: Fixed wrong video_mode shown

Currently, if the bridge has created by the ARI, the video_mode
parameter was
not shown in the BridgeCreated event correctly.

Fixed it and added video_mode shown in the 'bridge show <bridge id>'
cli.

ASTERISK-28987

Change-Id: I8c205126724e34c2bdab9380f523eb62478e4295

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

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

Change-Id: I22cba9ddf556a7e44dacc53c4431bd81dd2fa780

5 years agoCI: Force publishAsteriskDocs to use python2
George Joseph [Thu, 16 Jul 2020 13:41:16 +0000 (07:41 -0600)] 
CI: Force publishAsteriskDocs to use python2

Change-Id: I7d951e75ad2d472fa096647dfb55670b11105e23

5 years agowebsocket / pjsip: Increase maximum packet size.
Joshua C. Colp [Wed, 22 Jul 2020 17:57:44 +0000 (14:57 -0300)] 
websocket / pjsip: Increase maximum packet size.

When dealing with a lot of video streams on WebRTC
the resulting SDPs can grow to be quite large. This
effectively doubles the maximum size to allow more
streams to exist.

The res_http_websocket module has also been changed
to use a buffer on the session for reading in packets
to ensure that the stack space usage is not excessive.

Change-Id: I31d4351d70c8e2c11564807a7528b984f3fbdd01

5 years agopjsip: Include timer patch to prevent cancelling timer 0.
Joshua C. Colp [Mon, 13 Jul 2020 09:41:22 +0000 (06:41 -0300)] 
pjsip: Include timer patch to prevent cancelling timer 0.

I noticed this while looking at another issue and brought
it up with Teluu. It was possible for an uninitialized timer
to be cancelled, resulting in the invalid timer id of 0
being placed into the timer heap causing issues.

This change is a backport from the pjproject repository
preventing this from happening.

Change-Id: I1ba318b1f153a6dd7458846396e2867282b428e7

5 years agoacl.c: Coerce a NULL pointer into the empty string
Sean Bright [Mon, 13 Jul 2020 20:42:40 +0000 (16:42 -0400)] 
acl.c: Coerce a NULL pointer into the empty string

If an ACL is misconfigured in the realtime database (for instance, the
"rule" is blank) and Asterisk attempts to read the ACL, Asterisk will
crash.

ASTERISK-28978 #close

Change-Id: Ic1536c4df856231bfd2da00128f7822224d77610

5 years agores_http_websocket: Avoid reading past end of string
Nickolay Shmyrev [Thu, 2 Jul 2020 22:19:50 +0000 (00:19 +0200)] 
res_http_websocket: Avoid reading past end of string

We read beyond the end of the buffer when copying the string out of the
buffer when we used ast_copy_string() because the original string was
not null terminated. Instead switch to ast_strndup() which does not
exhibit the same behavior.

ASTERISK-28975 #close

Change-Id: Ib4a75cffeb1eb8cf01136ef30306bd623e531a2a

5 years agoUpdate CHANGES and UPGRADE.txt for 17.6.0
Asterisk Development Team [Thu, 9 Jul 2020 15:30:47 +0000 (10:30 -0500)] 
Update CHANGES and UPGRADE.txt for 17.6.0

5 years agoframe.c: Make debugging easier
George Joseph [Mon, 6 Jul 2020 15:57:18 +0000 (09:57 -0600)] 
frame.c:  Make debugging easier

 * ast_frame_subclass2str() and ast_frame_type2str() now return
   a pointer to the buffer that was passed in instead of void.
   This makes it easier to use these functions inline in
   printf-style debugging statements.

 * Added many missing control frame entries in
   ast_frame_subclass2str.

Change-Id: Ifd0d6578e758cd644c96d17a5383ff2128c572fc

5 years agoScope Trace: Make it easier to trace through synchronous tasks
George Joseph [Sun, 5 Jul 2020 23:51:04 +0000 (17:51 -0600)] 
Scope Trace: Make it easier to trace through synchronous tasks

Tracing through synchronous tasks was a little troublesome because
the new thread's stack counter reset to 0.  This change allows
a synchronous task to set its trace level to be the same as the
thread that pushed the task.  For now, the task's level has to be
passed in the task's data structure but a future enhancement to the
taskprocessor subsystem could automatically set the trace level
of the servant to be that of the caller.

This doesn't really make sense for async tasks because you never
know when they're going to run anyway.

Change-Id: Ib8049c0b815063a45d8c7b0cb4e30b7b87b1d825

5 years agores_pjsip.c: Added disable_rport option for pjsip.conf
sungtae kim [Tue, 23 Jun 2020 23:27:47 +0000 (01:27 +0200)] 
res_pjsip.c: Added disable_rport option for pjsip.conf

Currently when the pjsip making an outgoing request, it keep adding the
rport parameter in a request message as a default.

This causes unexpected rport handle at the other end.

Added option for disable this behaviour in the pjsip.conf.

This is a system option, but working as a gloabl option.

ASTERISK-28959

Change-Id: I9596675e52a742774738b5aad5d1fec32f477abc

5 years agores_http_websocket.c: Continue reading after ping/pong
Nickolay Shmyrev [Mon, 22 Jun 2020 17:16:15 +0000 (19:16 +0200)] 
res_http_websocket.c: Continue reading after ping/pong

Do not return error if the client received ping frame
while looking for a string and just wait for another frame.

ASTERISK-28958 #close

Change-Id: I4d06b4827bd71e56cbaafc011ffdcef9f0332922

5 years agoPJSIP_MEDIA_OFFER: override configuration on refresh
Kevin Harwell [Tue, 30 Jun 2020 16:08:47 +0000 (11:08 -0500)] 
PJSIP_MEDIA_OFFER: override configuration on refresh

When using the PSJIP_MEDIA_OFFER dialplan function it was not
overriding an endpoint's configured codecs on refresh unless
they had a shared codec between the two.

This patch makes it so whatever is set using PJSIP_MEDIA_OFFER
is used when creating the SDP for a refresh no matter what.

ASTERISK-28878 #close

Change-Id: I0f7dc86fd0fb607c308e6f98ede303c54d1eacb6

5 years agomanager - Add Content-Type parameter to the SendText action
Kevin Harwell [Wed, 10 Jun 2020 22:01:11 +0000 (17:01 -0500)] 
manager - Add Content-Type parameter to the SendText action

This patch allows a user of AMI to now specify the type of message
content contained within by setting the 'Content-Type' parameter.

Note, the AMI version has been bumped for this change.

ASTERISK-28945 #close

Change-Id: Ibb5315702532c6b954e1498beddc8855fabdf4bb

5 years agoScope Trace: Add some new tracing macros and an ast_str helper
George Joseph [Tue, 30 Jun 2020 13:56:34 +0000 (07:56 -0600)] 
Scope Trace:  Add some new tracing macros and an ast_str helper

Created new SCOPE_ functions that don't depend on RAII_VAR.  Besides
generating less code, the use of the explicit SCOPE_EXIT macros
capture the line number where the scope exited.  The RAII_VAR
versions can't do that.

 * SCOPE_ENTER(level, ...): Like SCOPE_TRACE but doesn't use
   RAII_VAR and therefore needs needs one of...

 * SCOPE_EXIT(...): Decrements the trace stack counter and optionally
   prints a message.

 * SCOPE_EXIT_EXPR(__expr, ...): Decrements the trace stack counter,
   optionally prints a message, then executes the expression.
   SCOPE_EXIT_EXPR(break, "My while got broken\n");

 * SCOPE_EXIT_RTN(, ...): Decrements the trace stack counter,
   optionally prints a message, then returns without a value.
   SCOPE_EXIT_RTN("Bye\n");

 * SCOPE_EXIT_RTN_VALUE(__return_value, ...): Decrements the trace
   stack counter, optionally prints a message, then returns the value
   specified.
   SCOPE_EXIT_RTN_VALUE(rc, "Returning with RC: %d\n", rc);

Create an ast_str helper ast_str_tmp() that allocates a temporary
ast_str that can be passed to a function that needs it, then frees
it.  This makes using the above macros easier.  Example:

   SCOPE_ENTER(1, Format Caps 1: %s  Format Caps 2: %s\n",
       ast_str_tmp(32, ast_format_cap_get_names(cap1, &STR_TMP),
       ast_str_tmp(32, ast_format_cap_get_names(cap2, &STR_TMP));

The calls to ast_str_tmp create an ast_str of the specified initial
length which can be referenced as STR_TMP.  It then calls the
expression, which must return a char *, ast_strdupa's it, frees
STR_TMP, then returns the ast_strdupa'd string.  That string is
freed when the function returns.

Change-Id: I44059b20d55a889aa91440d2f8a590865998be51

5 years agores_pjsip: Apply AOR outbound proxy to static contacts.
Joshua C. Colp [Fri, 26 Jun 2020 10:18:55 +0000 (07:18 -0300)] 
res_pjsip: Apply AOR outbound proxy to static contacts.

The outbound proxy for an AOR was not being applied to
any statically configured Contacts. This resulted in the
OPTIONS requests being sent to the wrong target.

This change sets the outbound proxy on statically configured
contacts once the AOR configuration is done being
applied.

ASTERISK-28965

Change-Id: Ia60f3e93ea63f819c5a46bc8b54be2e588dfa9e0

5 years agomenuselect: Resolve infinite loop in dependency scenario.
Joshua C. Colp [Wed, 24 Jun 2020 10:25:47 +0000 (07:25 -0300)] 
menuselect: Resolve infinite loop in dependency scenario.

Given a scenario where a module has a dependency on both
an external library and a module if the external library was
available and the module was not an infinite loop would
occur. This happened due to the code changing the dependecy
status to no failure on each dependency checking loop
iteration, resulting in the code thinking that it had
gone from no failure to failure each time triggering another
dependency check.

This change makes it so that the old dependency status is
preserved throughout the dependency checking allowing it to
determine that after the first iteration the dependency
status does not transition from no failure to failure.

ASTERISK-28930

Change-Id: Iea06d45d9fd6d8bfd068882a0bb7e23a53ec3e84

5 years agochan_pjsip: don't use PJSIP_SC_NULL as it only exists pjproject 2.8+
Kevin Harwell [Mon, 22 Jun 2020 20:27:32 +0000 (15:27 -0500)] 
chan_pjsip: don't use PJSIP_SC_NULL as it only exists pjproject 2.8+

A patch made a reference to the PJSIP_SC_NULL enumeration value, which
was added to pjproject 2.8 and above thus making it so Asterisk would
fail to compile with prior versions of pjproject.

This patch removes the reference, and instead initializes the value
to '0'.

ASTERISK-28886 #close

Change-Id: I68491c80da1a0154b2286c9458440141c98db9d7

5 years agochan_sip: chan_sip does not process 400 response to an INVITE.
Frederic LE FOLL [Mon, 22 Jun 2020 09:08:47 +0000 (11:08 +0200)] 
chan_sip: chan_sip does not process 400 response to an INVITE.

chan_sip handle_response() function, for a 400 response to an INVITE,
calls handle_response_invite() and does not generate ACK.
handle_response_invite() does not recognize 400 response and has no
default response processing for unexpected responses, thus it does not
generate ACK either.
The ACK on response repetition comes from handle_response() mechanism
"We must re-send ACKs to re-transmitted final responses".

According to code history, 400 response specific processing was
introduced with commit
"channels/chan_sip: Add improved support for 4xx error codes"
This commit added support for :
- 400/414/493 in handle_response_subscribe() handle_response_register()
  and handle_response().
- 414/493 only in handle_response_invite().

This fix adds 400 response support in handle_response_invite().

ASTERISK-28957

Change-Id: Ic71a087e5398dfc7273946b9ec6f9a36960218ad

5 years agores_corosync: Fix crash in huge distributed environment.
Università di Bologna - CESIA VoIP [Wed, 3 Jun 2020 10:05:20 +0000 (12:05 +0200)] 
res_corosync: Fix crash in huge distributed environment.

1) Fix memory-leaks
   Added code to release ast_events extracted from corosync and stasis messages

2) Clean stasis cache when a member of the corosync cluster leaves the group
   Added code to remove from the stasis cache of the members remained on the
   group all the messages with the EID of the left member.
   If the device states of the left member remain in the stasis cache of other
   members, they will not be updated anymore and high priority cached values,
   like BUSY, will take precedence over current device states.

3) Stop corosync event propagation when node is not joined to the group
   Updated dispatch_thread_handler code to detect when asterisk is not joined
   to the corosync group and added some condition in publish_event_to_corosync
   code to send corosync messages only when joined.
   When a node is not joined its corosync daemon can't send messages:
   the cpg_mcast_joined function append new messages to the FIFO buffer until
   it's full and then it blocks indefinitely.
   In this scenario if the stasis_message_cb callback, registered by
   res_corosync to handle stasis messages, try to send a corosync messages,
   the thread of the stasis thread-pool will be blocked until the node join
   the corosync cluster.

ASTERISK-28888
Reported by: Università di Bologna - CESIA VoIP

Change-Id: Ie8e99bc23f141a73c13ae6fb1948d148d4de17f2

5 years agores_http_websocket: Add payload masking to the websocket client
Moises Silva [Sat, 13 Jun 2020 16:29:13 +0000 (16:29 +0000)] 
res_http_websocket: Add payload masking to the websocket client

ASTERISK-28949

Change-Id: Id465030f2b1997b83d408933fdbabe01827469ca

5 years agochan_dadhi: Fix setvar in dahdi channels
Guido Falsi [Thu, 18 Jun 2020 10:14:26 +0000 (12:14 +0200)] 
chan_dadhi: Fix setvar in dahdi channels

The change to how setvar works for various channels performed in
ASTERISK~23756 missed some required change in the dahdi channel,
where the variables are actually set while reading configuration.
This change should fix the issue.

ASTERISK-28955

Change-Id: Ibfeb7f8cbdd735346dc4028de6a265f24f9df274

5 years agoapp_stream_echo: Fix state of added streams.
Joshua C. Colp [Thu, 18 Jun 2020 08:49:37 +0000 (05:49 -0300)] 
app_stream_echo: Fix state of added streams.

When stream support was added to Asterisk the stream state
was used inconsistently, resulting in odd behavior. This
was then standardized to be the state of a stream from the
perspective of Asterisk.

This change updates the StreamEcho dialplan application
to use the correct state, send only, since we are only
sending to the endpoint and not expecting them to send us
multiple video streams.

ASTERISK-28954

Change-Id: I35bfd533ef1184ffe62586b22bbd253c82872a56

5 years agores_pjsip_session: Preserve label on incoming re-INVITE.
Joshua C. Colp [Wed, 17 Jun 2020 08:58:44 +0000 (05:58 -0300)] 
res_pjsip_session: Preserve label on incoming re-INVITE.

When a re-INVITE is received we create a new set of
streams that are then swapped in as the active streams.
We did not preserve the SDP label from the previous
streams, resulting in the label getting lost.

This change ensures that if an SDP label is present
on the previous stream then it is set on the new stream.

ASTERISK-28953

Change-Id: I9dd63b88b562fe96ce5c791a3dae5bcaca258445

5 years agores_sorcery_memory_cache: Disallow per-object expire with full backend.
Joshua C. Colp [Wed, 10 Jun 2020 09:35:50 +0000 (06:35 -0300)] 
res_sorcery_memory_cache: Disallow per-object expire with full backend.

The AMI action and CLI command did not take into account the properties
of full backend caching. This resulted in an expired object remaining
removed until a full backend update occurred, instead of having the
object updated when needed.

This change makes it so that the AMI action and CLI command for object
expire will now fail instead of putting the cache into an undesired
state. If full backend caching is enabled then only operations
which act on the entire cache are available.

ASTERISK-28942

Change-Id: Id662d888f177ab566c8e802ad583083b742d21f4

5 years agoapp_queue: Read latest wrapuptime instead of (possibly stale) copy
Walter Doekes [Tue, 16 Jun 2020 13:18:11 +0000 (15:18 +0200)] 
app_queue: Read latest wrapuptime instead of (possibly stale) copy

Before this changeset, it was possible that a queue member (agent) was
called even though they just got out of a call, and wrapuptime seconds
hadn't passed yet.

This could happen if a member ended a call _between_ a new call attempt
and asterisk trying that particular member for a new call.

In that case, Asterisk would check the hangup time of the
call-before-the-last-call instead of the hangup time of the-last-call.

ASTERISK-28952

Change-Id: Ie0cab8f0e8d639c01cba633d4968ba19873d80b3

5 years agoapp_queue: Remove stale code in try_calling
Walter Doekes [Mon, 15 Jun 2020 11:53:31 +0000 (13:53 +0200)] 
app_queue: Remove stale code in try_calling

Because ring_entry() is not called, outgoing->chan is not touched here
either.

ASTERISK-28950
ASTERISK-28644

Change-Id: I564613715dfaf45af868251eb75a451f512af90f

5 years agores_pjsip: Include <pjsip_ua.h> instead of internal "pjsua-lib/pjsua.h"
Walter Doekes [Mon, 15 Jun 2020 12:09:19 +0000 (14:09 +0200)] 
res_pjsip: Include <pjsip_ua.h> instead of internal "pjsua-lib/pjsua.h"

Change-Id: I24b5453df412232cf7f9a171ea4a34b35ad3ae78

5 years agopjproject: Upgrade bundled version to pjproject 2.10
Kevin Harwell [Fri, 15 May 2020 21:08:20 +0000 (16:08 -0500)] 
pjproject: Upgrade bundled version to pjproject 2.10

This patch makes the usual necessary changes when upgrading to a new
version pjproject. For instance, version number bump, patches removed
from third-party, new *.md5 file added, etc..

This patch also includes a change to the Asterisk pjproject Makefile to
explicitly create the 'source/pjsip-apps/lib' directory. This directory
is no longer there by default so needs to be added so the Asterisk
malloc debug can be built.

This patch also includes some minor changes to Asterisk that were a result
of the upgrade. Specifically, there was a backward incompatibility change
made in 2.10 that modified the "expires header" variable field from a
signed to an unsigned value. This potentially effects comparison. Namely,
those check for a value less than zero. This patch modified a few locations
in the Asterisk code that may have been affected.

Lastly, this patch adds a new macro PJSIP_MINVERSION that can be used to
check a minimum version of pjproject at compile time.

ASTERISK-28899 #close

Change-Id: Iec8821c6cbbc08c369d0e3cd2f14e691b41d0c81

5 years agocore_unreal / core_local: Add multistream and re-negotiation.
Joshua C. Colp [Wed, 3 Jun 2020 16:47:42 +0000 (13:47 -0300)] 
core_unreal / core_local: Add multistream and re-negotiation.

When requesting a Local channel the requested stream topology
or a converted stream topology will now be placed onto the
resulting channels.

Frames written in on streams will now also preserve the stream
identifier as they are queued on the opposite channel.

Finally when a stream topology change is requested it is
immediately accepted and reflected on both channels. Each
channel also receives a queued frame to indicate that the
topology has changed.

ASTERISK-28938

Change-Id: I4e9d94da5230d4bd046dc755651493fce1d87186

5 years agores_ari: Fix create channel request channelId parameter parsing
sungtae kim [Fri, 12 Jun 2020 10:16:14 +0000 (10:16 +0000)] 
res_ari: Fix create channel request channelId parameter parsing

If channelId parameters were passed in the body, the Asterisk doesn't parsing it correctly.

Fixed it to parse the channelId, other_channel_id parameter correclty.

ASTERISK-28948

Change-Id: I59b49161a94869169ee19c1ffab5afcef7026157

5 years agores_rtp_asterisk: Don't assume setting retrans props means to enable.
Joshua C. Colp [Mon, 8 Jun 2020 11:27:53 +0000 (08:27 -0300)] 
res_rtp_asterisk: Don't assume setting retrans props means to enable.

The "value" passed in when setting an RTP property determines
whether it should be enabled or disabled. The RTP send and
receive retrans props did not examine this to know if the
buffers should be enabled. They assumed they always should be.

This change makes it so that the "value" passed in is
respected.

ASTERISK-28939

Change-Id: I9244cdbdc5fd065c7f6b02cbfa572bc55c7123dc

5 years agobridge_softmix: Add additional old states for adding new source.
Joshua C. Colp [Wed, 10 Jun 2020 17:11:16 +0000 (14:11 -0300)] 
bridge_softmix: Add additional old states for adding new source.

There are three states that an old stream can be in to allow
becoming a source stream in a new stream:

1. Removed
2. Inactive
3. Sendonly

This change adds the two missing ones, inactive and sendonly,
so if a stream transitions from those to a state where they are
providing video to Asterisk we properly re-negotiate the other
participants.

ASTERISK-28944

Change-Id: Id8256b9b254b403411586284bbaedbf50452de01

5 years agores_fax: Don't start a gateway if either channel is hung up
George Joseph [Wed, 3 Jun 2020 16:23:31 +0000 (10:23 -0600)] 
res_fax: Don't start a gateway if either channel is hung up

When fax_gateway_framehook is called and a gateway hasn't already
been started, the framehook gets the t38 state for both the current
channel and the peer.  That call trickles down to the channel
driver which determines the state.  If either channel is hung up
(or in the process of being hung up), the channel driver's tech_pvt
is going to be NULL which, in the case of chan_pjsip, will cause a
segfault.

* Added a hangup check for both the channel and peer channel
  before starting a fax gateway.

* Added a check for NULL tech_pvt to chan_pjsip_queryoption
  so we don't attempt to reference a tech_pvt that's already
  gone.

ASTERISK-28923
Reported by: Yury Kirsanov

Change-Id: I4e10e63b667bbb68c1c8623f977488f5d807897c

5 years agoapp_confbridge: Plug ref leak of bridge channel with send_events
George Joseph [Mon, 8 Jun 2020 00:02:00 +0000 (18:02 -0600)] 
app_confbridge: Plug ref leak of bridge channel with send_events

When send_events is enabled for a user, we were leaking a reference
to the bridge channel in confbridge_manager.c:send_message().  This
also caused the bridge snapshot to not be destroyed.

Change-Id: I87a7ae9175e3cd29f6d6a8750e0ec5427bd98e97

5 years agocli.c: Fix compiler error.
Ben Ford [Mon, 8 Jun 2020 19:34:10 +0000 (14:34 -0500)] 
cli.c: Fix compiler error.

Added default variable value to fix a compiler error.

Change-Id: I7b592adbb1274dc5464dea1c5e5de0685c928553

5 years agoCompiler fixes for gcc 10
Kevin Harwell [Mon, 1 Jun 2020 23:25:48 +0000 (18:25 -0500)] 
Compiler fixes for gcc 10

This patch fixes a few compile warnings/errors that now occur when using gcc
10+.

Also, the Makefile.rules check to turn off partial inlining in gcc versions
greater or equal to 8.2.1 had a bug where it only it only checked against
versions with at least 3 numbers (ex: 8.2.1 vs 10). This patch now ensures
any version above the specified version is correctly compared.

Change-Id: I54718496eb0c3ce5bd6d427cd279a29e8d2825f9

5 years agores_ari: Fix create request body parameter parsing.
sungtae kim [Tue, 9 Jun 2020 11:57:24 +0000 (11:57 +0000)] 
res_ari: Fix create request body parameter parsing.

If parameters were passed in the body as JSON to the
create route they were not being parsed before checking
to ensure that required fields were set.

This change moves the parsing so it occurs before
checking.

ASTERISK-28940

Change-Id: I898b4c3c7ae1cde19a6840e59f498822701cf5cf

5 years agobridge_channel: Don't queue unmapped frames.
Joshua C. Colp [Fri, 5 Jun 2020 09:45:18 +0000 (06:45 -0300)] 
bridge_channel: Don't queue unmapped frames.

If a frame is written to a channel in a bridge we
would normally queue this frame up and the channel
thread would then act upon it. If this frame had no
stream mapping on the channel it would then be
discarded.

This change adds a check before the queueing occurs
to determine if a mapping exists. If it does not
exist then the frame is not even queued at all. This
stops a frame duplication from happening and from
the channel thread having to wake up and deal with
it.

Change-Id: I17189b9b1dec45fc7e4490e8081d444a25a00bda

5 years agopjsip: Prevent invalid memory access when attempting to contact a non-sip URI
Walter Doekes [Fri, 5 Jun 2020 09:30:29 +0000 (11:30 +0200)] 
pjsip: Prevent invalid memory access when attempting to contact a non-sip URI

You cannot cast a pjsip_uri to a pjsip_sip_uri using pjsip_uri_get_uri,
without checking that it's a PJSIP_URI_SCHEME_IS_SIP(S).

ASTERISK-28936

Change-Id: I9f572b3677e4730458e9402719e580f8681afe2a

5 years agores_fax: Don't consume frames given to fax gateway on write.
Joshua C. Colp [Wed, 27 May 2020 08:47:07 +0000 (05:47 -0300)] 
res_fax: Don't consume frames given to fax gateway on write.

In a particular fax gateway scenario whereby it would
have to translate using the read translation path on a
channel the frame being translated would be consumed.
When the frame is in the write path it is not permitted
to free the frame as the caller expects it to continue
to exist.

This change makes it so that the frame is only consumed
on the read path where it is acceptable to free it.

ASTERISK-28900

Change-Id: I011c321288a1b056d92b37c85e229f4a28ee737d

5 years agopjproject_bundled: Honor --without-pjproject.
Alexander Traud [Tue, 2 Jun 2020 11:24:11 +0000 (13:24 +0200)] 
pjproject_bundled: Honor --without-pjproject.

The previous change missed that 'make' uses 'PJPROJECT_BUNDLED' anyway.

ASTERISK-28929

Change-Id: I7ef0e78a06ea391b59d95b99d46bbed3fec4fed9

5 years agores_pjsip_logger: use the correct pointer when logging tx_messages to pcap
Pirmin Walthert [Thu, 4 Jun 2020 06:50:35 +0000 (08:50 +0200)] 
res_pjsip_logger: use the correct pointer when logging tx_messages to pcap

When writing tx messages to pcap files, Asterisk is using the wrong
pointer resulting in lots of wasted space. This patch fixes it to use
the correct pointer.

ASTERISK-28932 #close

Change-Id: I5b8253dd59a083a2ca2c81f232f1d14d33c6fd23

5 years agobridge.c: Fixed null pointer exception
sungtae kim [Fri, 29 May 2020 01:03:24 +0000 (03:03 +0200)] 
bridge.c: Fixed null pointer exception

If the bridge show all command could not get the bridge snapshot, it causes null pointer exception.
Fixed it to check the snapshot is null.

ASTERISK-28920

Change-Id: I3521fc1b832bfc69644d0833f2c78177e1e51f58

5 years agoScope Tracing: A new facility for tracing scope enter/exit
George Joseph [Thu, 14 May 2020 18:24:19 +0000 (12:24 -0600)] 
Scope Tracing:  A new facility for tracing scope enter/exit

What's wrong with ast_debug?

  ast_debug is fine for general purpose debug output but it's not
  really geared for scope tracing since it doesn't present its
  output in a way that makes capturing and analyzing flow through
  Asterisk easy.

How is scope tracing better?

  Scope tracing uses the same "cleanup" attribute that RAII_VAR
  uses to print messages to a separate "trace" log level.  Even
  better, the messages are indented and unindented based on a
  thread-local call depth counter.  When output to a separate log
  file, the output is uncluttered and easy to follow.

  Here's an example of the output. The leading timestamps and
  thread ids are removed and the output cut off at 68 columns for
  commit message restrictions but you get the idea.

--> res_pjsip_session.c:3680 handle_incoming PJSIP/1173-00000001
--> res_pjsip_session.c:3661 handle_incoming_response PJSIP/1173
--> res_pjsip_session.c:3669 handle_incoming_response PJSIP/
--> chan_pjsip.c:3265 chan_pjsip_incoming_response_after
--> chan_pjsip.c:3194 chan_pjsip_incoming_response P
    chan_pjsip.c:3245 chan_pjsip_incoming_respon
<-- chan_pjsip.c:3194 chan_pjsip_incoming_response P
<-- chan_pjsip.c:3265 chan_pjsip_incoming_response_after
<-- res_pjsip_session.c:3669 handle_incoming_response PJSIP/
<-- res_pjsip_session.c:3661 handle_incoming_response PJSIP/1173
<-- res_pjsip_session.c:3680 handle_incoming PJSIP/1173-00000001

  The messages with the "-->" or "<--" were produced by including
  the following at the top of each function:

  SCOPE_TRACE(1, "%s\n", ast_sip_session_get_name(session));

  Scope isn't limited to functions any more than RAII_VAR is.  You
  can also see entry and exit from "if", "for", "while", etc blocks.

  There is also an ast_trace() macro that doesn't track entry or
  exit but simply outputs a message to the trace log using the
  current indent level.  The deepest message in the sample
  (chan_pjsip.c:3245) was used to indicate which "case" in a
  "select" was executed.

How do you use it?

  More documentation is available in logger.h but here's an overview:

  * Configure with --enable-dev-mode.  Like debug, scope tracing
    is #ifdef'd out if devmode isn't enabled.

  * Add a SCOPE_TRACE() call to the top of your function.

  * Set a logger channel in logger.conf to output the "trace" level.

  * Use the CLI (or cli.conf) to set a trace level similar to setting
    debug level... CLI> core set trace 2 res_pjsip.so

Summary Of Changes:

  * Added LOG_TRACE logger level.  Actually it occupies the slot
    formerly occupied by the now defunct "event" level.

  * Added core asterisk option "trace" similar to debug.  Includes
ability to specify global trace level in asterisk.conf and CLI
commands to turn on/off and set levels.  Levels can be set
globally (probably not a good idea), or by module/source file.

  * Updated sample asterisk.conf and logger.conf.  Tracing is
    disabled by default in both.

  * Added __ast_trace() to logger.c which keeps track of the indent
    level using TLS. It's #ifdef'd out if devmode isn't enabled.

  * Added ast_trace() and SCOPE_TRACE() macros to logger.h.
    These are all #ifdef'd out if devmode isn't enabled.

Why not use gcc's -finstrument-functions capability?

  gcc's facility doesn't allow access to local data and doesn't
  operate on non-function scopes.

Known Issues:

  The only know issue is that we currently don't know the line
  number where the scope exited.  It's reported as the same place
  the scope was entered.  There's probably a way to get around it
  but it might involve looking at the stack and doing an 'addr2line'
  to get the line number.  Kind of like ast_backtrace() does.
  Not sure if it's worth it.

Change-Id: Ic5ebb859883f9c10a08c5630802de33500cad027

5 years agores_pjsip_logger.c: correct the return value checks when writing to pcap
Pirmin Walthert [Fri, 29 May 2020 09:28:57 +0000 (11:28 +0200)] 
res_pjsip_logger.c: correct the return value checks when writing to pcap
files

fwrite() does return the number of elements written and not the
number of bytes. However asterisk is currently comparing the return
value to the size of the written element what means that asterisk logs
five WARNING messages on every packet written to the pcap file.

This patch changes the code to check for the correct value, which will
always be 1.

ASTERISK-28921 #close

Change-Id: I2455032d9cb4c5a500692923f9e2a22e68b08fc2

5 years agoUpdate CHANGES and UPGRADE.txt for 17.5.0
Asterisk Development Team [Thu, 28 May 2020 12:07:45 +0000 (07:07 -0500)] 
Update CHANGES and UPGRADE.txt for 17.5.0

5 years agoARI: Bump non-breaking version number to 5.1.1
Joshua C. Colp [Thu, 28 May 2020 11:55:21 +0000 (08:55 -0300)] 
ARI: Bump non-breaking version number to 5.1.1

The channel create call now allows setting variables.

Change-Id: I5e5bd34e0eb3df6e7feb2095e00a91c742ad5113

5 years agores_pjsip: Use correct pool for storing the contact_user value.
Joshua C. Colp [Wed, 27 May 2020 14:35:42 +0000 (11:35 -0300)] 
res_pjsip: Use correct pool for storing the contact_user value.

When replacing the user portion of the Contact URI the code
was using the ephemeral pool instead of the tdata pool. This
could cause the Contact user value to become invalid after a
period of time.

The code will now use the tdata pool which persists for the
lifetime of the message instead.

ASTERISK-28794

Change-Id: I31e7b958e397cbdaeedd0ebb70bcf8dd2ed3c4d5

5 years agores_pjsip_nat.c: remove x-ast-orig-host from request URI and To header
Pirmin Walthert [Wed, 13 May 2020 12:06:19 +0000 (14:06 +0200)] 
res_pjsip_nat.c: remove x-ast-orig-host from request URI and To header

While asterisk is filtering out the x-ast-orig-host parameter from the
contact on response messages, it is not filtering it out from the
request URI and the to header on SIP requests (for example INVITE).

ASTERISK-28884 #close

Change-Id: Id032b33098a1befea9b243ca994184baecccc59e

5 years agobridge: Don't try to match audio formats.
Joshua C. Colp [Mon, 18 May 2020 14:05:56 +0000 (11:05 -0300)] 
bridge: Don't try to match audio formats.

When bridging channels we were trying to match the audio
formats of both sides in combination with the configured
formats. While this is allowed in SDP in practice this
causes extra reinvites and problems. This change ensures
that audio streams use the formats of the first existing
active audio stream. It is only when other stream types
(like video) exist that this will result in re-negotiation
occurring for those streams only.

ASTERISK-28871

Change-Id: I22f5a3e7db29e00c165e74d05d10856f6086fe47

5 years agores_srtp: Set all possible flags while selecting the Crypto Suite.
Alexander Traud [Mon, 18 May 2020 15:10:01 +0000 (17:10 +0200)] 
res_srtp: Set all possible flags while selecting the Crypto Suite.

The flags of a previous selection could have been set within the
object 'srtp', for example, when the previous selection returned
failure after setting just 'some' flags. Now, not to clutter the
code, all possible flags are cleared first, and then the selected
flags are set as before.

ASTERISK-28903

Change-Id: I1b9d7aade7d5120244ce7e3a8865518cbd6e0eee

5 years agores_sorcery_config: Always reload configuration on errors.
Joshua C. Colp [Tue, 19 May 2020 12:55:32 +0000 (09:55 -0300)] 
res_sorcery_config: Always reload configuration on errors.

When a configuration file in Asterisk is loaded
information about it is stored such that on a
reload it is not reloaded if nothing has changed.
This can be problematic when an error exists in
a configuration file in PJSIP since the error
will be output at start and not subsequently on
reload if the file is unchanged.

This change makes it so that if an error is
encountered when res_sorcery_config is loading
a configuration file a reload will always read
in the configuration file, allowing the error
to be seen easier.

Change-Id: If2e05a017570f1f5f4f49120da09601e9ecdf9ed

5 years agobridge_softmix: Always remove audio from mixed frame.
Joshua C. Colp [Tue, 19 May 2020 09:18:58 +0000 (06:18 -0300)] 
bridge_softmix: Always remove audio from mixed frame.

When receiving audio from a channel we determine if it
is talking or silence based on a threshold value. If
this threshold is met we always mix the audio into the
conference bridge. If this threshold is not met we also
mix the audio into the conference bridge UNLESS the
drop silence option is enabled.

The code that removed the audio from the mixed frame
assumed that it was always not present if it did not
meet the threshold to be considered talking. This is
incorrect. If it has been stated that the audio was
mixed into the mixed frame then it has been mixed into
the mixed frame. By not removing audio that was
considered non-talking it was possible for a channel
to receive a slight echo of audio of itself at times.

This change ensures that the audio is always removed
from the mixed frame going back to the channel so it
no longer receives the slight echo.

ASTERISK-28898

Change-Id: I7b1b582cc1bcdb318ecc60c9d2e3d87ae31d55cb

5 years agores_pjsip_logger: Expand functionality to improve logging.
Joshua C. Colp [Thu, 30 Apr 2020 22:57:08 +0000 (19:57 -0300)] 
res_pjsip_logger: Expand functionality to improve logging.

The PJSIP packet logger now has the following CLI commands:

pjsip set logger pcap <filename>

When used this will create a pcap file containing the incoming
and outgoing SIP packets, in unencrypted form.

pjsip set logger verbose <on / off>

This allows you to toggle logging to verbose on and off.

pjsip set logger host <IP/subnet mask> add

This allows you to add an additional IP address or subnet
mask to logging, allowing you to log multiple instead of
just a single IP address or all traffic.

The normal "pjsip set logger host" CLI command has also been
expanded to allow subnet masks as well.

ASTERISK-28895

Change-Id: If5859161a72b0d7dd2d1f92d45bed88e0cd07d0e

5 years agores_musiconhold: Added check for dot character in path of playlist entries to avoid...
Nicholas John Koch [Wed, 13 May 2020 18:32:35 +0000 (20:32 +0200)] 
res_musiconhold: Added check for dot character in path of playlist entries to avoid warnings

A warning was triggered that there may be a problem regarding file
extension (which is correct and should not be set anyway). The warning
also appeared if there was dot within the path itself.

E.g.
[sales-queue-hold]
mode=playlist
entry=/var/www/domain.tld/moh/funky_music

The music played correctly but you get a warning message.

Now there will be a check if the position of a potential dot character
is after the last position of a slash character. This dot charachter
will be treated as a extension naming. Dots within the path then ignored.

ASTERISK-28892
Reported-By: Nicholas John Koch
Change-Id: I2ec35a613413affbf5fcc01c8c181eba24865b9e

5 years agores_rtp_asterisk.c: Fixed memory leak
sungtae kim [Mon, 18 May 2020 16:31:58 +0000 (16:31 +0000)] 
res_rtp_asterisk.c: Fixed memory leak

Added freeifaddrs() for memory releasing.

ASTERISK-28904

Change-Id: I109403866e85a30659351946903a679de9727a8f

5 years agoari: Allow variables to be set on channel create.
Joshua C. Colp [Tue, 12 May 2020 23:15:41 +0000 (20:15 -0300)] 
ari: Allow variables to be set on channel create.

This change adds the same variable functionality that
is available for originating a channel to the create
call. Now when creating a channel you can specify
dialplan variables to set instead of having to do another
API call.

ASTERISK-28896

Change-Id: If13997ba818136d7c070585504fc4164378aa992

5 years agopjsip_resolver.c: Ensure AAAA dns requests are made.
Roger James [Sun, 10 May 2020 10:01:56 +0000 (11:01 +0100)] 
pjsip_resolver.c: Ensure AAAA dns requests are made.

1. Modify sip_resolve and sip_resolve_callback to request AAAA lookups
   when an IPV6 transport type has been requested.

2. Rename all occurrences of pjsip_transport_get_type_name to
   pjsip_transport_get_type_desc. This ensures that the log/debug info
   shows whether the transport is IPv6 or IPv4.

3. Do not add the constant PJSIP_TRANSPORT_IPV6 to existing transport
   types. This results in invalid values. Use a bitwise or instead.

ASTERISK-26780
Patches:
    pjsip_resolver.c uploaded by Peter Sokolov (License #7070)

Change-Id: I8b1e298f8efa682d0a7644113258fe76d9889c58

5 years agopjproject: Fix race condition when building with parallel make
Guido Falsi [Fri, 8 May 2020 11:11:47 +0000 (13:11 +0200)] 
pjproject: Fix race condition when building with parallel make

Pjproject makefiles miss some dependencies which can cause race
conditions when building with parallel make processes. This patch
adds such dependencies correctly.

ASTERISK-28879 #close
Reported-by: Dmitry Wagin <dmitry.wagin@ya.ru>
Change-Id: Ie1b0dc365dafe4a84c5248097fe8d73804043c22

5 years agores_pjsip_history.c: Fix to stop SIGSEGV when IPv6 addresses are encountered.
Roger James [Sat, 9 May 2020 07:46:51 +0000 (08:46 +0100)] 
res_pjsip_history.c: Fix to stop SIGSEGV when IPv6 addresses are encountered.

Changed source and destination address fields in struct
pjsip_history_entry so that they are long enough to hold an IPv6
address.

ASTERISK-28854

Change-Id: Id65bb9aa961e9ecbcb500815e18170f774e34d3e

5 years agotcptls: Fix notice when TLS is enabled but not supported.
traud [Wed, 1 Apr 2020 13:38:44 +0000 (15:38 +0200)] 
tcptls: Fix notice when TLS is enabled but not supported.

ASTERISK-28797

Change-Id: Iab364a2c2519fd9d11d1c28293fda43d61b64c28