3 years agochan_sip: Fix session timeout on retransmit of non-UDP packets
Steve Davies [Tue, 13 Sep 2016 10:34:47 +0000 (11:34 +0100)]
chan_sip: Fix session timeout on retransmit of non-UDP packets

Change-Id I1cd33453c77c56c8e1394cd60a6f17bb61c1d957 Enable Session-Timers for
SIP over TCP (and TLS) also disables SIP retransmits in chan_sip for non-UDP
connections, allowing the TCP layer to handle the retransmits. Unfortunately,
this caused sessions to be terminated with a retransmit timeout becasue it
stopped at the point of the first retrans call.

This patch waits for the 64*T1 timer to expire instead.


Change-Id: I844f26801aada10bc94e9bebe6e151f0a8443204

3 years agoapp_queue: Fix CLI "queue show" and AMI Queues action output truncation.
Richard Mudgett [Mon, 12 Sep 2016 17:25:54 +0000 (12:25 -0500)]
app_queue: Fix CLI "queue show" and AMI Queues action output truncation.

The output of CLI "queue show" and AMI Queues action is truncated and
"failed to extend from 240 to 327" messages are generated if the queue
member and interface names are lengthy.

* Increase the string buffer size from 240 to 512 in order to accommodate
for more information fields added to the output since v1.8.

ASTERISK-26360 #close
Reported by: Richard Mudgett

Change-Id: Id99c03cf5362453b80491a4b3b0434cb67aa966d

3 years agoMerge "contrib: Let safe_asterisk script continue without /dev/tty9."
zuul [Mon, 12 Sep 2016 13:42:18 +0000 (08:42 -0500)]
Merge "contrib: Let safe_asterisk script continue without /dev/tty9."

3 years agoMerge "res/res_pjsip: Add preferred_codec_only config to pjsip endpoint."
zuul [Fri, 9 Sep 2016 18:56:16 +0000 (13:56 -0500)]
Merge "res/res_pjsip: Add preferred_codec_only config to pjsip endpoint."

3 years agocontrib: Let safe_asterisk script continue without /dev/tty9.
Walter Doekes [Fri, 9 Sep 2016 11:26:01 +0000 (13:26 +0200)]
contrib: Let safe_asterisk script continue without /dev/tty9.

If you use the safe_asterisk script, it uses hardcoded defaults before
running configurable values from /etc/asterisk/startup.d. The hardcoded
default has TTY=9. Some containerized environments don't have such a
TTY, and safe_asterisk would stop.

The custom configuration from /etc/asterisk/startup.d/* isn't read until
after it stopped, so changing TTY in a custom config did not help.

This changeset changes safe_asterisk to continue if the TTY setting was
untouched and /dev/tty9 and /dev/vc/9 aren't found.

Change-Id: I2c7cdba549b77f418a0af4cb1227e8e6fe4148fc

3 years agores_pjsip: Only invoke unidentified endpoint logic when unidentified.
Joshua Colp [Fri, 9 Sep 2016 10:39:51 +0000 (10:39 +0000)]
res_pjsip: Only invoke unidentified endpoint logic when unidentified.

The code was incorrectly invoking the unidentified logic when
an endpoint had actually been identified, causing log messages
to be output.

ASTERISK-26349 #close

Change-Id: Id8104fc9e3d138d5e8b6f6977ecc08765fd17d4f

3 years agores/res_pjsip: Add preferred_codec_only config to pjsip endpoint.
Aaron An [Tue, 30 Aug 2016 03:26:03 +0000 (11:26 +0800)]
res/res_pjsip: Add preferred_codec_only config to pjsip endpoint.

This patch add config to pjsip by endpoint.
; Respond to a SIP invite with the single most preferred codec
; rather than advertising all joint codec capabilities. This
; limits the other side's codec choice to exactly what we prefer.

ASTERISK-26317 #close
Reported by: AaronAn
Tested by: AaronAn

Change-Id: Iad04dc55055403bbf5ec050997aee2dadc4f0762

3 years agores_pjsip: Do not crash on ACKs from unknown endpoints.
Mark Michelson [Tue, 16 Aug 2016 20:34:53 +0000 (15:34 -0500)]
res_pjsip: Do not crash on ACKs from unknown endpoints.

The endpoint identification PJSIP module is intended to identify which
endpoint an incoming request is from. If an endpoint is not identified,
then an artificial endpoint is used in its place when proceeding.

The problem is that the ACK request type is an exception to the rule.
The artificial endpoint is not used when processing an ACK. This results
in the possibility of having a NULL endpoint being used further on.

The reason ACK is an exception is an attempt not to spam security logs
with unidentified requests. Presumably, you've already logged the
unidentified request on the preceeding INVITE.

Up until Asterisk 13.10, retrieving a NULL endpoint in this fashion
didn't cause an issue. A new change in 13.10 added endpoint ACL checking
shortly after endpoint identification. Because we are accessing a NULL
endpoint, this ACL check resulted in a crash.

The fix here is to be sure to retrieve the artificial endpoint for all
request types. ACKs still do not generate unidentified request security

ASTERISK-26264 #close
Reported by nappsoft


Change-Id: Ie0c795ae2d72273decb972dd74b6a1489fb6b703

3 years agochan_sip: Don't allocate new RTP instances on top of old ones.
Joshua Colp [Tue, 23 Aug 2016 11:35:11 +0000 (11:35 +0000)]
chan_sip: Don't allocate new RTP instances on top of old ones.

In some scenarios dialog_initialize_rtp can be called multiple times on
the same dialog.  This can cause RTP instances to be leaked along with
multiple file descriptors for each instance.

This change makes it so the existing RTP instances are destroyed and
not overwritten, stopping the memory leak.

ASTERISK-26272 #close
  ASTERISK-26272-13.patch submitted by Corey Farrell (license 5909)

Change-Id: Id529de1184c68f2f4d254ab41a1f458dafdb5f73

3 years agoMerge "res_pjsip: Allow global headers to be overridden."
zuul [Thu, 8 Sep 2016 18:25:57 +0000 (13:25 -0500)]
Merge "res_pjsip: Allow global headers to be overridden."

3 years agoMerge "ConfBridge: Make some announcements asynchronous."
zuul [Thu, 8 Sep 2016 01:37:09 +0000 (20:37 -0500)]
Merge "ConfBridge: Make some announcements asynchronous."

3 years agoMerge "res/res_stasis_playback: Cancel the entire playlist when a stop occurs"
zuul [Thu, 8 Sep 2016 00:26:27 +0000 (19:26 -0500)]
Merge "res/res_stasis_playback: Cancel the entire playlist when a stop occurs"

3 years agoMerge "apps/app_dial: Fix crash on non-connect call paths for Privacy/Screening option"
zuul [Wed, 7 Sep 2016 22:23:45 +0000 (17:23 -0500)]
Merge "apps/app_dial: Fix crash on non-connect call paths for Privacy/Screening option"

3 years agores_pjsip: Allow global headers to be overridden.
Joshua Colp [Wed, 7 Sep 2016 21:00:16 +0000 (21:00 +0000)]
res_pjsip: Allow global headers to be overridden.

Currently when you add global headers from the dialplan both
the header in the dialplan and the globally configured header
are added to the resulting SIP INVITE. This change makes it
so the headers in the dialplan take precedence and are the
only ones added.

Change-Id: I36f864298f38db3632ad503edc11267cb8ffb3ad

3 years agoMerge "res_resolver_unbound: Fix config documentation."
zuul [Wed, 7 Sep 2016 20:44:04 +0000 (15:44 -0500)]
Merge "res_resolver_unbound: Fix config documentation."

3 years agoMerge "res_pjsip_session: segfault on already disconnected session"
zuul [Wed, 7 Sep 2016 19:41:27 +0000 (14:41 -0500)]
Merge "res_pjsip_session: segfault on already disconnected session"

3 years agoMerge "apps/app_dial: Set the DIALSTATUS to NOANSWER on privacy option 5"
zuul [Wed, 7 Sep 2016 19:04:24 +0000 (14:04 -0500)]
Merge "apps/app_dial: Set the DIALSTATUS to NOANSWER on privacy option 5"

3 years agoConfBridge: Make some announcements asynchronous.
Mark Michelson [Wed, 10 Aug 2016 20:14:09 +0000 (15:14 -0500)]
ConfBridge: Make some announcements asynchronous.

Confbridge announcements tend to block a channel while they are being
played. In some circumstances, this is warranted since you want that
particular channel not to hear the announcement (Example: "John Doe has
entered the conference"). For others it makes less sense.

This change first introduces methods for playing sounds asynchronously
into the conference. This is very similar to how synchronous sounds are
played, except the channel initiating the playback does not wait for the
sound to complete before moving on.

Asynchronous announcements are used for two circumstances:
* Sounds played for a user after they have left the bridge
* Sounds that play first to a single user and then the rest of the
  conference (if the channel and conference use the same language)

ASTERISK-26289 #close
Reported by Mark Michelson

Change-Id: Ie486bb3de1646d50894489030326a423e594ab0a

3 years agoMerge "build: Add download capability for external packages"
zuul [Wed, 7 Sep 2016 13:19:40 +0000 (08:19 -0500)]
Merge "build: Add download capability for external packages"

3 years agochan_sip: Allow Preferred sRTP.
Alexander Traud [Tue, 19 Jul 2016 14:41:44 +0000 (16:41 +0200)]
chan_sip: Allow Preferred sRTP.

Following the Encrypt-all-the-things paradigm:

The user enters his SIP-URI and password. Thanks to DNS-NAPTR, the phone
determines SIP-over-TLS as preferred transport. In SIP/SDP, the phone starts
the call with a crypto attribute, but not as RTP/sAVP but the RTP/AVP profile
(sRTP is preferred aka optional; not mandatory). If the VoIP server does not
support sRTP and TLS, the phone shows an open padlock icon.

This paradigm is supported by several VoIP/SIP clients on default. Some
implementations even cannot be changed to RTP/sAVP. Therefore here, this
change allows Preferred sRTP for ingress. For egress, please, create a dial
plan which starts with RTP/SAVP, and when rejected tries again with RTP/AVP.

ASTERISK-20234 #close
Reported by: tootai
Tested by: tootai, Alexander Traud
 srtp_patches.diff submitted by Matt Jordan

Change-Id: I42cb779df3a9c7b3dd03a629fb3a296aa4ceb0fd

3 years agores_resolver_unbound: Fix config documentation.
Joshua Colp [Wed, 7 Sep 2016 10:59:26 +0000 (10:59 +0000)]
res_resolver_unbound: Fix config documentation.

The code was referencing the config section as 'globals'
instead of 'general'. This change swaps it over to 'general'.

Change-Id: I9dfe7788f41c4a6754c77e103880dc1a747de7fe

3 years agoMerge "chan_sip: Don't refuse calls with "optional crypto"; fall back to RTP."
Joshua Colp [Wed, 7 Sep 2016 10:03:24 +0000 (05:03 -0500)]
Merge "chan_sip: Don't refuse calls with "optional crypto"; fall back to RTP."

3 years agoMerge "pjsip_configuration.c: Ignore repeated identify by methods."
Joshua Colp [Wed, 7 Sep 2016 10:02:55 +0000 (05:02 -0500)]
Merge "pjsip_configuration.c: Ignore repeated identify by methods."

3 years agoMerge "resource_channels.c: add hangup reason "answered_elsewhere"."
zuul [Wed, 7 Sep 2016 07:05:47 +0000 (02:05 -0500)]
Merge "resource_channels.c: add hangup reason "answered_elsewhere"."

3 years agoMerge "res_pjsip_registrar.c: Reduce stack usage in find_aor_name()."
zuul [Wed, 7 Sep 2016 03:47:50 +0000 (22:47 -0500)]
Merge "res_pjsip_registrar.c: Reduce stack usage in find_aor_name()."

3 years agoMerge "config_global.c: Comments and a default expression adjustment."
zuul [Wed, 7 Sep 2016 00:45:03 +0000 (19:45 -0500)]
Merge "config_global.c: Comments and a default expression adjustment."

3 years agoMerge " Map canreinvite as directmedia alias."
zuul [Tue, 6 Sep 2016 21:30:33 +0000 (16:30 -0500)]
Merge " Map canreinvite as directmedia alias."

3 years agores/res_stasis_playback: Cancel the entire playlist when a stop occurs
Matt Jordan [Tue, 6 Sep 2016 20:25:28 +0000 (15:25 -0500)]
res/res_stasis_playback: Cancel the entire playlist when a stop occurs

Prior to this patch, a stop issued by a delete of a Playback resource
(indicated by the control frame AST_CONTROL_STREAM_STOP) would only stop
the current media URI playing. Subsequent URIs specified by a playback
operation would then proceed on, even though we had just indicated to
the User that the Playback was finished *and* after they had just
'deleted' the resource. Whoops.

This patch corrects it by bailing out of the sequence of URIs to play if
one of them is terminated with an AST_CONTROL_STREAM_STOP indication.

ASTERISK-26341 #close

Change-Id: I2da9ec43545ba46cdfffe287c7e4907eae7fca42

3 years agoMerge " Fix typo converting outboundproxy registration."
zuul [Tue, 6 Sep 2016 20:26:23 +0000 (15:26 -0500)]
Merge " Fix typo converting outboundproxy registration."

3 years agoMerge " Fix comment typo and tabs."
zuul [Tue, 6 Sep 2016 19:14:04 +0000 (14:14 -0500)]
Merge " Fix comment typo and tabs."

3 years agoMerge "Sample configs: Eliminate false multiline comment block starts."
zuul [Tue, 6 Sep 2016 17:42:49 +0000 (12:42 -0500)]
Merge "Sample configs: Eliminate false multiline comment block starts."

3 years agoMerge "sorcery: Create function ast_sorcery_lockable_alloc."
zuul [Tue, 6 Sep 2016 17:14:03 +0000 (12:14 -0500)]
Merge "sorcery: Create function ast_sorcery_lockable_alloc."

3 years agoMerge "named_locks: Use ao2_weakproxy to deal with cleanup from container."
zuul [Tue, 6 Sep 2016 16:20:57 +0000 (11:20 -0500)]
Merge "named_locks: Use ao2_weakproxy to deal with cleanup from container."

3 years agobuild: Add download capability for external packages
George Joseph [Tue, 2 Aug 2016 01:55:33 +0000 (19:55 -0600)]
build: Add download capability for external packages

The DPMA and g729a, silk, siren7 and siren14 codecs hosted at are now listed in the
"External" sections of the "Resource Modules" and "Codec Translators"
pages in menuselect.  Any that are selected will automatically be
downloaded and installed when "make install" is run.  Their LICENSE and
README (if avaialble) files will be installed to

Example use with codecs:

The codecs/codecs.xml file is a menuselect style xml file that lists
the codecs to be included.  Their support levels are 'external', which
triggers the download and install, and defaultenabled is no.  Also
because codec_g729a is actually in a directory named codec_g729 on the
download server, the newly added 'member_data' element is used to
override the default of the directory name being the package name.  You
can use the 'directory_name' attribute to keep default base URL
( but use the new directory,
or you use the 'remote_url' attribute to specify a full URL to the
download directory.  In this case, you must still follow the same
subdirectory naming conventions as that used for the packages located
at ''.

A new configure option '--with-externals-cache' was added and like
'--with-sounds-cache' it allows the installer to cache tarballs so
they're not downloaded every time.

To assist with the download and install process, each external package
now has a manifest.xml file that, among other things, contains a package
version and checksums for each file in the tarball.  The manifest is
saved to both the cache directory and ASTMODDIR and together with the
manifest.xml on the downloads site, tells the install scripts whether
a download and/or update is needed.

bash and xmlstarlet are required for downloader operation.  If they're
not installed, the external items in menuselect will be unavailable.

Change-Id: Id3dcf1289ffd3cb0bbd7dfab3cafbb87be60323a

3 years agoMerge "format_cap.c: Fix CLI "core show channeltype Surrogate" crash."
Joshua Colp [Tue, 6 Sep 2016 15:06:10 +0000 (10:06 -0500)]
Merge "format_cap.c: Fix CLI "core show channeltype Surrogate" crash."

3 years agoMerge "astobj2: Support using a separate object for locking."
zuul [Tue, 6 Sep 2016 14:37:32 +0000 (09:37 -0500)]
Merge "astobj2: Support using a separate object for locking."

3 years agores_pjsip_session: segfault on already disconnected session
Alexei Gradinari [Thu, 18 Aug 2016 19:45:59 +0000 (15:45 -0400)]
res_pjsip_session: segfault on already disconnected session

On heavy loaded system the TCP/TLS incoming calls could be
disconnected by pjproject while these calls are being
processed by asterisk which could use the session's memory pools.
If the session in the disconnected state then the session memory
pools were already freed, so we get segfault.

This patch adds a lifetime control on an INVITE session to pjproject.
The lifetime of the session is manipulated by calling
This patch uses these functions to inform pjproject that the
session is in use.

This patch adds check if the session state is not disconnected
and also checks if the memory pool is not NULL.

This patch also places tasks 'session_end' and 'session_end_completion'
into session's serializer to avoid race condition.

ASTERISK-26291 #close

Change-Id: I4d28b1fb3b91f0492a911d110049d670fdc3c8d7

3 years agochan_sip: Don't refuse calls with "optional crypto"; fall back to RTP.
Walter Doekes [Tue, 6 Sep 2016 07:41:06 +0000 (09:41 +0200)]
chan_sip: Don't refuse calls with "optional crypto"; fall back to RTP.

Certain SNOM phones send so-called "optional crypto" in their SDP body.
Regular SRTP setup looks like this:

    m=audio 64620 RTP/SAVP 8 0 9 99 3 18 4 101
    a=crypto:1 AES_CM_128_HMAC_SHA1_32 inline:...

SNOM-style "optional crypto" looks like this:

    m=audio 61438 RTP/AVP 8 0 9 99 3 18 4 101
    a=crypto:1 AES_CM_128_HMAC_SHA1_32 inline:...

A crypto line is supplied, but the m-line does not have SAVP.

When is *not* loaded, then treats the optional
crypto as regular RTP, but when *is* loaded, it refuses the
incoming call with the following message:

    WARNING: process_sdp: Failed to receive SDP offer/answer with
    required SRTP crypto attributes for audio

For platforms that want to start providing SRTP this presents a
compatibility problem.

This changeset lets chan_sip handle the SDP as if no crypto-line was
supplied: i.e. accept the call as regular RTP, just like it did before
res_srtp was loaded.

Now you'll get this informative warning instead:

    WARNING: Ignoring crypto attribute in SDP because RTP transport is

ASTERISK-23989 #close
Reported by: Olle Johansson

Change-Id: I91a15ae05a0296e398d6b65f53bb11afde1d80e2

3 years agoMerge "codecs: Add Codec 2 mode 2400."
Joshua Colp [Sun, 4 Sep 2016 19:11:34 +0000 (14:11 -0500)]
Merge "codecs: Add Codec 2 mode 2400."

3 years agoMerge "app_mp3: Use correct buffer size and the same sample rate as the channel"
zuul [Sun, 4 Sep 2016 17:54:47 +0000 (12:54 -0500)]
Merge "app_mp3: Use correct buffer size and the same sample rate as the channel"

3 years agoapps/app_dial: Fix crash on non-connect call paths for Privacy/Screening option
Matt Jordan [Sat, 3 Sep 2016 21:04:21 +0000 (16:04 -0500)]
apps/app_dial: Fix crash on non-connect call paths for Privacy/Screening option

In any scenario in which the callee is not connected to the caller, the
current code in app_dial will crash due to raising a Dial End Stasis
Message after the callee channel has been hung up. This patch corrects
the error by simply moving the explicit hangup of the callee (peer)
channel until after the dial end message.

ASTERISK-25691 #close

Change-Id: I816a414014424d0d8c80e2a3cbef13ef8c63798d

3 years agoapps/app_dial: Set the DIALSTATUS to NOANSWER on privacy option 5
Matt Jordan [Sat, 3 Sep 2016 21:02:37 +0000 (16:02 -0500)]
apps/app_dial: Set the DIALSTATUS to NOANSWER on privacy option 5

If the callee selects option '5' using the Dial application's privacy
(P) option, the DIALSTATUS is erroneously set to ANSWER. This option
reflects the callee sending the caller to VoiceMail one time; the call
is definitely *not* ANSWERed in such a scenario. With this patch, the
DIALSTATUS is instead set to NOANSWER, which is the same DIALSTATUS that
is set when the 'send to VoiceMail every time' option is set.


Change-Id: Iaf0c9f0fa00545e7366443875e2bb7d9a89a1358

3 years agores_pjsip_registrar.c: Reduce stack usage in find_aor_name().
Richard Mudgett [Tue, 30 Aug 2016 21:40:59 +0000 (16:40 -0500)]
res_pjsip_registrar.c: Reduce stack usage in find_aor_name().

Change-Id: I8aebad1fdcf303bd115b59a4b57fbbd5b2267f09

3 years agopjsip_configuration.c: Ignore repeated identify by methods.
Richard Mudgett [Mon, 29 Aug 2016 23:06:48 +0000 (18:06 -0500)]
pjsip_configuration.c: Ignore repeated identify by methods.

Change-Id: Ied0c06043d1dfef8fdc9c9a808cf89b118119838

3 years agoconfig_global.c: Comments and a default expression adjustment.
Richard Mudgett [Tue, 30 Aug 2016 22:26:43 +0000 (17:26 -0500)]
config_global.c: Comments and a default expression adjustment.

Change-Id: Ia6a58f8c73a30da6874b3f94364dce162d6f1ad3

3 years Map canreinvite as directmedia alias.
Richard Mudgett [Wed, 31 Aug 2016 20:14:32 +0000 (15:14 -0500)] Map canreinvite as directmedia alias.

Change-Id: I48b8e150f96a3d2a24d8fc25fbe4f5aff9f4a6b2

3 years Fix typo converting outboundproxy registration.
Richard Mudgett [Wed, 31 Aug 2016 20:37:44 +0000 (15:37 -0500)] Fix typo converting outboundproxy registration.

Change-Id: I6f30e5f9fcf8469ba0079fbf884047d54c2c0b15

3 years Fix comment typo and tabs.
Richard Mudgett [Wed, 31 Aug 2016 20:13:19 +0000 (15:13 -0500)] Fix comment typo and tabs.

Change-Id: If35174614545727817d329c60ba4456c028941b5

3 years agoSample configs: Eliminate false multiline comment block starts.
Richard Mudgett [Wed, 31 Aug 2016 20:56:41 +0000 (15:56 -0500)]
Sample configs: Eliminate false multiline comment block starts.

Change-Id: Ie627def9604ae30abd80754f9e6f09874825aec6

3 years agoformat_cap.c: Fix CLI "core show channeltype Surrogate" crash.
Richard Mudgett [Fri, 2 Sep 2016 16:36:38 +0000 (11:36 -0500)]
format_cap.c: Fix CLI "core show channeltype Surrogate" crash.

* Make ast_format_cap_get_names() NULL tolerant.

ASTERISK-26331 #close
Reported by: CGI.NET

Change-Id: Id67e93936dc8ec2a33a9d33655843d43b59285a3

3 years agosorcery: Create function ast_sorcery_lockable_alloc.
Corey Farrell [Fri, 26 Aug 2016 22:22:51 +0000 (18:22 -0400)]
sorcery: Create function ast_sorcery_lockable_alloc.

Create an alternative to ast_sorcery_generic_alloc which uses astobj2
shared locking. Use this new method for the 'struct ast_sip_aor' allocator.

Change-Id: I3f62f2ada64b622571950278fbb6ad57395b5d6f

3 years agonamed_locks: Use ao2_weakproxy to deal with cleanup from container.
Corey Farrell [Thu, 18 Aug 2016 18:28:57 +0000 (14:28 -0400)]
named_locks: Use ao2_weakproxy to deal with cleanup from container.

This allows standard ao2 functions to be used to release references to
an ast_named_lock.  This change can cause less frequent locking of the
global named_locks container.  The container is no longer locked when a
named_lock reference is being release except when this causes the
named_lock to be destroyed.

Change-Id: I644e39c6d83a153d71b3fae77ec05599d725e7e6

3 years agoastobj2: Support using a separate object for locking.
Corey Farrell [Fri, 26 Aug 2016 18:18:10 +0000 (14:18 -0400)]
astobj2: Support using a separate object for locking.

Create ao2_alloc_with_lockobj function to support shared locking.

Change-Id: Iba687eb9843922be7e481e23a32c0700ecf88a80

3 years agoMerge "res_pjsip: qualify/unqualify added/deleted realtime endpoints"
zuul [Thu, 1 Sep 2016 18:21:54 +0000 (13:21 -0500)]
Merge "res_pjsip: qualify/unqualify added/deleted realtime endpoints"

3 years agoMerge "sip_to_pjsip: Migrate IPv4/IPv6 (Dual Stack) configurations."
Joshua Colp [Thu, 1 Sep 2016 17:20:46 +0000 (12:20 -0500)]
Merge "sip_to_pjsip: Migrate IPv4/IPv6 (Dual Stack) configurations."

3 years agoapp_mp3: Use correct buffer size and the same sample rate as the channel
Michael Kuron [Wed, 31 Aug 2016 17:23:09 +0000 (19:23 +0200)]
app_mp3: Use correct buffer size and the same sample rate as the channel

Previously, the buffer used for MP3 streamed from HTTP servers had a size of
1 MB. For 8 kHz mono audio at 16 bit resolution, such a buffer covers about 1
minute. Only when the buffer is full does audio start to play.
For MP3 files streamed from a server, that is usually not a big deal as long as
the connection to the server is fast enough to supply that much data within a
second or two. For MP3 live streams however, it takes 1 minute to download 1
minute of audio, so without this change, app_mp3 wasn't really usable for MP3
live streams.
This commit changes the buffer size so that it covers 6 seconds of an MP3 file
streamed from a server and 0.5 seconds of an MP3 live stream. The latter is
identified by the use of a .m3u file extension.

app_mp3 so far only supported 8 kHz audio.
Now it always runs at the sample rate of the channel.

ASTERISK-26085 #close

Change-Id: Id1ee274733cd804a0edecf7450329b72f1235af0

3 years agoresource_channels.c: add hangup reason "answered_elsewhere".
Jean Aunis [Wed, 31 Aug 2016 10:33:28 +0000 (12:33 +0200)]
resource_channels.c: add hangup reason "answered_elsewhere".

In ARI, the channels API allows to hangup a channel with a hangup reason.
This commit adds a new reason "answered_elsewhere".
When using a SIP channel, this will eventually allow Asterisk to add a proper
"Reason" header to a CANCEL message.


Change-Id: Ia97675bd4acd6a7f58eb467953dfb94559f6583d

3 years agores_pjsip: qualify/unqualify added/deleted realtime endpoints
Alexei Gradinari [Fri, 26 Aug 2016 15:39:11 +0000 (11:39 -0400)]
res_pjsip: qualify/unqualify added/deleted realtime endpoints

If the PJSIP endpoint's AOR with the permanent contact
was deleted from the realtime storage the res_pjsip module
continues trying to qualify this contact.
The error 'Unable to find an endpoint to qualify contact'
appeares every 'qualify_frequency' seconds.
This patch deletes this contact in this case.

The PJSIP endpoint's AOR with the permanent contact
is never qualified if it is added to realtime storage
after asterisk started.
This patch adds qualifying for the AOR's permanent contacts
on the first handling of this AOR.

ASTERISK-26319 #close

Change-Id: Ib93dded9121edb113076903d1aa95402f799f8fe

3 years agoMerge "res_pjsip: Default endpoints to the "offline" status."
zuul [Tue, 30 Aug 2016 00:01:40 +0000 (19:01 -0500)]
Merge "res_pjsip: Default endpoints to the "offline" status."

3 years agoMerge "pjproject_bundled: Disable srtp use by pjmedia"
zuul [Mon, 29 Aug 2016 23:06:38 +0000 (18:06 -0500)]
Merge "pjproject_bundled:  Disable srtp use by pjmedia"

3 years agoMerge "pbx.c: Prevent infinite recursion in manager_show_dialplan_helper."
zuul [Mon, 29 Aug 2016 21:50:23 +0000 (16:50 -0500)]
Merge "pbx.c: Prevent infinite recursion in manager_show_dialplan_helper."

3 years agoMerge "app_queue: Ensure member is removed from pending when hanging up."
zuul [Mon, 29 Aug 2016 19:56:27 +0000 (14:56 -0500)]
Merge "app_queue: Ensure member is removed from pending when hanging up."

3 years agoMerge "app_macro: Consider '~~s~~' as a macro start extension."
zuul [Mon, 29 Aug 2016 18:16:45 +0000 (13:16 -0500)]
Merge "app_macro: Consider '~~s~~' as a macro start extension."

3 years agores_pjsip: Default endpoints to the "offline" status.
Mark Michelson [Mon, 22 Aug 2016 22:08:19 +0000 (17:08 -0500)]
res_pjsip: Default endpoints to the "offline" status.

A recent change attempted to optimize startup by not updating contact
status. Instead, code responsible for qualifying contacts updates the
status as it becomes known. The code even accounts for contacts/AORs
that are not set to be qualified.

The problem, though, is when there are no contacts associated with an
endpoint. A common case is when an endpoint is set to register its
contacts but has not done so yet. In this case, prior to registration,
the endpoint's device state will appear to be "not in use" and hints
associated with that device will appear to be "idle". In actuality, the
device state and hint should both appear as "unavailable". The reason
for the failure is that the optimization change made all persistent
endpoint states set to "unknown".

The fix here is to change the hard-coded "unknown" to be "offline"
instead. The default state will be offline until the qualifying code
determines that the contact is actually online. This way, if there are
no contacts at all, then the state stays as offline, and device state
and hints appear correctly.

ASTERISK-26269 #close
Reported by nappsoft

Change-Id: Ie99b84169393983453076f5e9c0d35ff313a456a

3 years agopbx.c: Prevent infinite recursion in manager_show_dialplan_helper.
Etienne Lessard [Mon, 29 Aug 2016 12:07:38 +0000 (08:07 -0400)]
pbx.c: Prevent infinite recursion in manager_show_dialplan_helper.

Previously, if context A was including context B and context B was including
context A, i.e. if there was a circular dependency between contexts, then
calling manager_show_dialplan_helper could lead to an infinite recursion,
resulting in a crash.

This commit applies the same solution as the one implemented in the
show_dialplan_helper function. The manager_show_dialplan_helper and
show_dialplan_helper functions contain lots of code in common, but the former
was missing the "infinite recursion avoidance" code.

ASTERISK-26226 #close

Change-Id: I1aea85133c21787226f4f8442253a93000aa0897

3 years agoapp_queue: Ensure member is removed from pending when hanging up.
Joshua Colp [Thu, 25 Aug 2016 12:06:41 +0000 (12:06 +0000)]
app_queue: Ensure member is removed from pending when hanging up.

When dialing channels it is possible that they may not ever
leave the not in use state (Local channels in particular) by
the time we cancel them. If this occurs but we know they were
dialed we explicitly remove them from the pending members
container so that subsequent call attempts occur.

ASTERISK-26299 #close

Change-Id: I6ad0d17c36480c92cebf840626228ce3f7e4bd65

3 years agoMerge "res_pjsip: Cache global config options."
zuul [Sat, 27 Aug 2016 03:17:40 +0000 (22:17 -0500)]
Merge "res_pjsip: Cache global config options."

3 years agoMerge "channel: No hung-up on failing security requirements."
zuul [Sat, 27 Aug 2016 00:40:15 +0000 (19:40 -0500)]
Merge "channel: No hung-up on failing security requirements."

3 years agopjproject_bundled: Disable srtp use by pjmedia
George Joseph [Fri, 26 Aug 2016 19:34:22 +0000 (13:34 -0600)]
pjproject_bundled:  Disable srtp use by pjmedia

The reason for the disable is that while Asterisk works fine with older
libsrtp versions, newer versions of pjproject won't compile with them.
Debian 6 for instance, has libsrtp 1.4.4 which is older than what
pjproject is expecting.

We don't use most of pjmedia but we DO use it for SDP negotiation.
Luckily disabling srtp in pjmedia doesn't interfere with it's ability
to negitiate a secure channel.  The proper crypto attributes are
negotiated in both directions.

ASTERISK-26279 #close

Change-Id: Id25a92cdf3df97a26c53cffae65b6b82de33c8e2

3 years agoMerge "res_fax: Fix deadlock in ast_channel_get_t38_state()."
Joshua Colp [Fri, 26 Aug 2016 19:03:10 +0000 (14:03 -0500)]
Merge "res_fax: Fix deadlock in ast_channel_get_t38_state()."

3 years agoMerge "res_fax: Fix deadlock setting FAXMODE channel variable."
Joshua Colp [Fri, 26 Aug 2016 19:03:05 +0000 (14:03 -0500)]
Merge "res_fax: Fix deadlock setting FAXMODE channel variable."

3 years agoMerge "res_fax.c: Fix deadlock in fax_gateway_indicate_t38()."
Joshua Colp [Fri, 26 Aug 2016 19:02:59 +0000 (14:02 -0500)]
Merge "res_fax.c: Fix deadlock in fax_gateway_indicate_t38()."

3 years agoMerge "res_fax.c: Add chan locked precondition comments."
Joshua Colp [Fri, 26 Aug 2016 19:02:54 +0000 (14:02 -0500)]
Merge "res_fax.c: Add chan locked precondition comments."

3 years agoMerge "ast_framehook_detach() must be called with the channel locked."
Joshua Colp [Fri, 26 Aug 2016 19:02:45 +0000 (14:02 -0500)]
Merge "ast_framehook_detach() must be called with the channel locked."

3 years agoMerge "ast_framehook_attach() must be called with the channel locked."
zuul [Fri, 26 Aug 2016 18:27:16 +0000 (13:27 -0500)]
Merge "ast_framehook_attach() must be called with the channel locked."

3 years agoMerge "Fix checks for allocation debugging."
zuul [Fri, 26 Aug 2016 17:55:22 +0000 (12:55 -0500)]
Merge "Fix checks for allocation debugging."

3 years agoMerge "Fix naming mismatch of allocator functions."
zuul [Fri, 26 Aug 2016 17:55:19 +0000 (12:55 -0500)]
Merge "Fix naming mismatch of allocator functions."

3 years agochannel: No hung-up on failing security requirements.
Alexander Traud [Fri, 26 Aug 2016 13:41:16 +0000 (15:41 +0200)]
channel: No hung-up on failing security requirements.

In your Diaplan, if you specify
 same => n,Set(CHANNEL(secure_bridge_media)=1)
 same => n,Set(CHANNEL(secure_bridge_signaling)=1)
only the SIP channel driver chan_sip supports this. All other channels drivers
like res_pjsip fail. In case of failure, the original sRTP source code released
the whole channel, even if not hung-up, yet. This change does not release the
channel but instead hangs-up the channel.


Change-Id: I0489f0cb660fab6673b0db8af027d116e70a66db

3 years agosip_to_pjsip: Migrate IPv4/IPv6 (Dual Stack) configurations.
Alexander Traud [Sat, 20 Aug 2016 14:04:13 +0000 (16:04 +0200)]
sip_to_pjsip: Migrate IPv4/IPv6 (Dual Stack) configurations.

When using the migration script, and your sip.conf is
configured with bindaddr=::, two transports are written to pjsip.conf, one for (IPv4) and one for [::] (IPv6). That way, PJProject listens on the IPv4
and IPv6 wildcards; a IPv4/IPv6 Dual Stack configuration on a single interface
like in chan_sip.

Furthermore, the script internal functions "build_host" and "split_hostport"
did not parse Literal IPv6 addresses as expected (like [::1]:5060). This change
makes sure, even such addresses are parsed correctly.


Change-Id: Ia4799a0f80fc30c0550fc373efc207c3330aeb48

3 years agores_pjsip: Cache global config options.
Richard Mudgett [Fri, 5 Aug 2016 01:11:29 +0000 (20:11 -0500)]
res_pjsip: Cache global config options.

We may check a global config option hundreds of times a second or more.
Asking sorcery for the global configuration from the config files backend
involves several allocations and container traversals.  Using realtime
without a memory cache is a lot worse because you have to lookup in the
realtime database each time to reconstitute the sorcery object.  With a
memory cache for realtime, there is about the same amount of overhead as
for config files.  Either way, it is still fairly expensive to access the
sorcery object that much.

* Cache the global config options so we can access them faster.  You must
now always perform a res_pjsip reload to change the global options.

Change-Id: Ice16c7a4cbca4614da344aaea21a072b86263ef7

3 years agores_fax: Fix deadlock in ast_channel_get_t38_state().
Richard Mudgett [Tue, 23 Aug 2016 16:02:35 +0000 (11:02 -0500)]
res_fax: Fix deadlock in ast_channel_get_t38_state().

ast_channel_get_t38_state() calls ast_channel_queryoption() with
AST_OPTION_T38_STATE.  If the passed in channel is a local channel then a
deadlock can happen if a channel lock is held when called.

* Made ast_channel_get_t38_state() callers not hold a channel lock before

* Update ast_channel_get_t38_state() doxygen to note that no channel locks
can be held when calling the function.

ASTERISK-26203 #close
Reported by: Etienne Lessard

ASTERISK-24822 #close
Reported by: David Brillert

ASTERISK-22732 #close
Reported by: Richard Mudgett

Change-Id: I49fd76fa9af628b4198009b5c0b82c8b03681214

3 years agores_fax: Fix deadlock setting FAXMODE channel variable.
Richard Mudgett [Tue, 23 Aug 2016 15:39:01 +0000 (10:39 -0500)]
res_fax: Fix deadlock setting FAXMODE channel variable.

ASTERISK-25980 added the FAXMODE channel variable to res_fax.c.
Unfortunately, it also introduced a deadlock potential because
set_channel_variables() which sets FAXMODE can be called during a
masquerade.  The ast_channel_get_t38_state() which gets the value used to
set FAXMODE cannot be called with the channel locked.  As a result, local
channels can deadlock because of how they must acquire the locks necessary
to operate.

The intent of FAXMODE is for dialplan to know how a fax was transferred
after the fax completes.  However, the previous patch sets FAXMODE to the
channel's current T.38 state AFTER the fax has completed and where T.38
may have already disconnected.

* Set FAXMODE based upon T.38 negotiations exchanged either with the fax
applications or the fax framehooks.

Reported by: Etienne Lessard

Reported by: David Brillert

Reported by: Richard Mudgett

Change-Id: Id525747254b64c1efe8b1b5973d52ff9719c2ae1

3 years agores_fax.c: Fix deadlock in fax_gateway_indicate_t38().
Richard Mudgett [Mon, 22 Aug 2016 17:31:24 +0000 (12:31 -0500)]
res_fax.c: Fix deadlock in fax_gateway_indicate_t38().

fax_gateway_indicate_t38() calls ast_indicate_data() which cannot be
called with any channel locks already held.  A deadlock can happen if the
function is operating on a local channel.

* Made fax_gateway_indicate_t38() unlock the channel before calling
ast_indicate_data() since fax_gateway_indicate_t38() is always called with
the channel locked.

* Made fax_gateway_indicate_t38() return void since nothing cared about
its return value.

Reported by: Etienne Lessard

Reported by: David Brillert

Reported by: Richard Mudgett

Change-Id: I701ff2d26c5fc23e0d5a48a3fd98759a9fd09407

3 years agores_fax.c: Add chan locked precondition comments.
Richard Mudgett [Tue, 23 Aug 2016 16:16:04 +0000 (11:16 -0500)]
res_fax.c: Add chan locked precondition comments.

Change-Id: Ic10ae434536bbf7fb7055d6ab36cc50b8748a4e7

3 years agoast_framehook_detach() must be called with the channel locked.
Richard Mudgett [Tue, 23 Aug 2016 15:42:08 +0000 (10:42 -0500)]
ast_framehook_detach() must be called with the channel locked.

The framehook container could become corrupted if the channel lock is not
held before calling.

Change-Id: If0a1c7ba0484ed3a191106a7516526b905952584

3 years agoast_framehook_attach() must be called with the channel locked.
Richard Mudgett [Mon, 22 Aug 2016 20:01:37 +0000 (15:01 -0500)]
ast_framehook_attach() must be called with the channel locked.

The framehook container could become corrupted if the channel lock is not
held before calling.

Change-Id: I1a6b957a1f7b899eb29a186915f8cccab886a438

3 years agoapp_macro: Consider '~~s~~' as a macro start extension.
chrisderock [Wed, 17 Aug 2016 07:51:17 +0000 (09:51 +0200)]
app_macro: Consider '~~s~~' as a macro start extension.

As described in issue ASTERISK-26282 the AEL parser creates macros with
extension '~~s~~'.  app_macro searches only for extension 's' so the
created extension cannot be found.  with this patch app_macro searches for
both extensions and performs the right extension.

ASTERISK-26282 #close

Change-Id: I939aa2a694148cc1054dd75ec0c47c47f47c90fb

3 years agochan_iax2: Set plaintext auth to deprecated as per ASTERISK-22820
varnav [Wed, 24 Aug 2016 09:44:15 +0000 (12:44 +0300)]
chan_iax2: Set plaintext auth to deprecated as per ASTERISK-22820

Starting from draft 2 of RFC 5456 (October 23, 2006) plaintext auth
is not supported in IAX2 protocol. Please refer to section 8.6.13 of
RFC 5456.

But plaintext auth is still supported by Asterisk implementation of IAX2.
This support should be dropped.

Patch, based on asterisk-dev discussion, adds deprecation warning on
startup if 'auth' is set to 'plaintext', changes default values of
'auth' from 'md5, plaintext' to 'md5'.

Patch is safe in terms of backwards compatibility, will work even if
remote peers have auth=plaintext and we have defaults.

auth=plaintext setting will remain deprecated in Asterisk 14 and 15,
and IAX2 plaintext support will be removed in Asterisk 16.

ASTERISK-22820 #close

Change-Id: I5d2f3830cb57645604818f87518916e8a5c317bf

3 years agores_rtp_multicast: Fix SEGV in ast_multicast_rtp_create_options
George Joseph [Wed, 24 Aug 2016 19:42:34 +0000 (13:42 -0600)]
res_rtp_multicast:  Fix SEGV in ast_multicast_rtp_create_options

ast_multicast_rtp_create_options now checks for NULL or empty options

Change-Id: Ib845eae46a67a9787e89a87ebd1027344e5e0362

3 years agocodecs: Add Codec 2 mode 2400.
Alexander Traud [Tue, 19 Jul 2016 18:14:21 +0000 (20:14 +0200)]
codecs: Add Codec 2 mode 2400.

ASTERISK-26217 #close

Change-Id: I1e45d8084683fab5f2b272bf35f4a149cea8b8d6

3 years agoConfBridge: Rework announcer channel methodology
Mark Michelson [Wed, 10 Aug 2016 20:14:09 +0000 (15:14 -0500)]
ConfBridge: Rework announcer channel methodology

NOTE: This patch was submitted earlier and reverted because of a failing
test. The test has been patched so that it adjusts for the changes here,
so this is being resubmitted for review.

One feature that confbridge has is the ability to play sounds to all
participants in the conference. Prior to this commit, the algorithm for
this was as follows:

* Grab the playback lock
* Push the conference announcer channel into the bridge
* Play back the sound
* Pull the conference announcer channel from the bridge
* Release the playback lock

The issue here is that the act of adding the playback channel to the
bridge and removing it for each announcement is expensive. Amongst the

* The announcer channel is imparted into the bridge, meaning a new
  thread is spun up for each playback.
* When the announcer is added or removed from the bridge, it results
  in the BRIDGEPEER channel variable being set on all channels in the
  bridge. This requires keeping the bridge locked and locking each
  individual channel in order to set it.
* There's also just the general overhead of adding the channel and
  removing it from the bridge. The bridge potentially has to reconfigure
  every single time

With this commit, the paradigm for playing back announcements has

* The announcer channel is now added to the bridge when the conference
  is allocated, and it is hung up when the conference is destroyed.
* A taskprocessor is used to queue playbacks onto the announcer channel.
  This keeps the behavior from before where playbacks do not overlap.
* The announcer channel is no longer placed into the bridge as
  departable. Since we are not constantly removing the channel from
  the bridge, it is safe to add the channel using an independent thread
  and simply hang the channel up when it is time for the conference to
  be destroyed.

The use of the taskprocessor for playbacks opens up the interesting
possibility of having asynchronous announcements played. In this commit,
however, the behavior is still exactly the same as it previously was.

Reported by Mark Michelson

Change-Id: Ica9fa4907c2f3728cdd1cf0bc564ef4eb40754a0

3 years agoMerge "Revert "ConfBridge: Rework announcer channel methodology""
Joshua Colp [Tue, 23 Aug 2016 10:54:10 +0000 (05:54 -0500)]
Merge "Revert "ConfBridge: Rework announcer channel methodology""

3 years agoRevert "ConfBridge: Rework announcer channel methodology"
Joshua Colp [Tue, 23 Aug 2016 10:54:02 +0000 (05:54 -0500)]
Revert "ConfBridge: Rework announcer channel methodology"

This reverts commit 5aa877305223faab5a1119276a934893ab9dc138.

Change-Id: I9ab45776e54a54ecf1bac9ae62d976dec30ef491

3 years agoMerge "ConfBridge: Rework announcer channel methodology"
zuul [Tue, 23 Aug 2016 03:33:15 +0000 (22:33 -0500)]
Merge "ConfBridge: Rework announcer channel methodology"

3 years agoMerge "followme: initialize all config items on reload"
zuul [Mon, 22 Aug 2016 21:35:33 +0000 (16:35 -0500)]
Merge "followme: initialize all config items on reload"

3 years agoMerge "compilation failed with -Werror=maybe-uninitialized"
zuul [Mon, 22 Aug 2016 16:22:13 +0000 (11:22 -0500)]
Merge "compilation failed with -Werror=maybe-uninitialized"

3 years agoMerge "res_odbc_transaction: add dep on generic_odbc"
zuul [Mon, 22 Aug 2016 14:57:09 +0000 (09:57 -0500)]
Merge "res_odbc_transaction: add dep on generic_odbc"

3 years agoMerge "pjproject_bundled: Allow IPv4/IPv6 (Dual Stack) configurations."
Joshua Colp [Mon, 22 Aug 2016 14:22:04 +0000 (09:22 -0500)]
Merge "pjproject_bundled: Allow IPv4/IPv6 (Dual Stack) configurations."

3 years agocompilation failed with -Werror=maybe-uninitialized
Alexei Gradinari [Fri, 19 Aug 2016 15:21:01 +0000 (11:21 -0400)]
compilation failed with -Werror=maybe-uninitialized

The compilation failed for devmode
--enable DO_CRASH

res_pjsip/pjsip_configuration.c: In function dtls_handler:
res_pjsip/pjsip_configuration.c:974:20: error:
back may be used uninitialized in this function [-Werror=maybe-uninitialized]
int size = strlen(front);
cc1: all warnings being treated as errors

Change-Id: I7f082ead0312792a577ec7c73015ba64dabca580

3 years agoMerge "res_ari: Add http prefix to generated docs"
zuul [Mon, 22 Aug 2016 12:32:46 +0000 (07:32 -0500)]
Merge "res_ari: Add http prefix to generated docs"