4 years agocodec_opus: Add download ability to menuselect
George Joseph [Thu, 22 Sep 2016 14:49:50 +0000 (08:49 -0600)]
codec_opus: Add download ability to menuselect

Updated codecs/codecs.xml to add codec_opus to the external
download list.


Change-Id: Ia07b36539f30e852125fb2b94147dc9774df31a4
(cherry picked from commit 2cdab0e36eec4997ca3bd85aa09efc477038e31c)
(cherry picked from commit e9684f3acd0e8def0df582c1505dd39dd3fd1610)

4 years agocodec_opus: Replace res_format_attr_opus with the one from codec_opus
George Joseph [Sat, 23 Jul 2016 19:50:37 +0000 (13:50 -0600)]
codec_opus: Replace res_format_attr_opus with the one from codec_opus



Change-Id: I9f20e7cce00c32464d9a180e81283d49d199d0a3
(cherry picked from commit 59f7662a93bf9c07204fb50e1020a0f5bfbbd5c9)

4 years agoformat_ogg_opus: New format
George Joseph [Sat, 23 Jul 2016 20:56:43 +0000 (14:56 -0600)]
format_ogg_opus: New format

Add Ogg/Opus playback support.

This uses libopusfile in order to be able to read .opus files and play
them back.

Writing/recording support is not present at this time.


Change-Id: I8815d23345108d8ca7c0bd640f6a1ce6b4f56955
(cherry picked from commit daee8bbd5209b4158bc1785eede845a26e6cbeaa)

4 years agoMerge "chan_sip: Address runaway when realtime peers subscribe to mailboxes"
zuul [Fri, 23 Sep 2016 21:59:59 +0000 (16:59 -0500)]
Merge "chan_sip:  Address runaway when realtime peers subscribe to mailboxes"

4 years agoMerge "channels/chan_pjsip: fix HANGUPCAUSE function bug."
zuul [Fri, 23 Sep 2016 20:38:53 +0000 (15:38 -0500)]
Merge "channels/chan_pjsip: fix HANGUPCAUSE function bug."

4 years agochan_sip: Address runaway when realtime peers subscribe to mailboxes
George Joseph [Tue, 20 Sep 2016 14:42:15 +0000 (08:42 -0600)]
chan_sip:  Address runaway when realtime peers subscribe to mailboxes

Users upgrading from asterisk 13.5 to a later version and who use
realtime with peers that have mailboxes were experiencing runaway
situations that manifested as a continuous stream of taskprocessor
congestion errors, memory leaks and an unresponsive chan_sip.

A related issue was that setting rtcachefriends=no NEVER worked in
asterisk 13 (since the move to stasis).  In 13.5 and earlier, when a
peer tried to register, all of the stasis threads would block and
chan_sip would again become unresponsive.  After 13.5, the runaway
would happen.

There were a number of causes...
* mwi_event_cb was (indirectly) calling build_peer even though calls to
  mwi_event_cb are often caused by build_peer.
* In an effort to prevent chan_sip from being unloaded while messages
  were still in flight, destroy_mailboxes was calling
  stasis_unsubscribe_and_join but in some cases waited forever for the
  final message.
* add_peer_mailboxes wasn't properly marking the existing mailboxes
  on a peer as "keep" so build_peer would always delete them all.
* add_peer_mwi_subs was unsubscribing existing mailbox subscriptions
  then just creating them again.

All of this was causing a flood of subscribes and unsubscribes on
multiple threads all for the same peer and mailbox.

* add_peer_mailboxes now marks mailboxes correctly and build_peer only
  deletes the ones that really are no longer needed by the peer.
* add_peer_mwi_subs now only adds subscriptions marked as "new" instead
  of unsubscribing and resubscribing everything.  It also adds the peer
  object's address to the mailbox instead of its name to the subscription
  userdata so mwi_event_cb doesn't have to call build_peer.

With these changes, with rtcachefriends=yes (the most common setting),
there are no leaks, locks, loops or crashes at shutdown.

rtcachefriends=no still causes leaks but at least it doesn't lock, loop
or crash.  Since making rtcachefriends=no work wasnt in scope for this
issue, further work will have to be deferred to a separate patch.

Side fixes...
 * The ast_lock_track structure had a member named "thread" which gdb
   doesn't like since it conflicts with it's "thread" command.  That
   member was renamed to "thread_id".

ASTERISK-25468 #close

Change-Id: I07519ef7f092629e1e844f855abd279d6475cdd0

4 years agoMerge "core: Ensure presencestate subtype and message are NULL."
Joshua Colp [Thu, 22 Sep 2016 13:45:38 +0000 (08:45 -0500)]
Merge "core: Ensure presencestate subtype and message are NULL."

4 years agoMerge "res_odbc: Make pooling option deprecation notice more useful."
Joshua Colp [Thu, 22 Sep 2016 12:10:47 +0000 (07:10 -0500)]
Merge "res_odbc: Make pooling option deprecation notice more useful."

4 years agoMerge "cdr_mysql: fix UTC support"
Joshua Colp [Thu, 22 Sep 2016 11:55:15 +0000 (06:55 -0500)]
Merge "cdr_mysql: fix UTC support"

4 years agochannels/chan_pjsip: fix HANGUPCAUSE function bug.
Aaron An [Thu, 22 Sep 2016 06:40:45 +0000 (14:40 +0800)]
channels/chan_pjsip: fix HANGUPCAUSE function bug.

HANGUPCAUSE not return 'SIP 200 Ok' when dialed channel answered.
This patch change the call order of ast_queue_control_data
and ast_queue_control in chan_pjsip_incoming_response.

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

Change-Id: Ide2d31723d8d425961e985de7de625694580be61

4 years agoMerge "logger: Simplify ast_callid handling code."
zuul [Wed, 21 Sep 2016 20:15:14 +0000 (15:15 -0500)]
Merge "logger: Simplify ast_callid handling code."

4 years agoMerge "logger: Always enable verbose for console channel."
Joshua Colp [Wed, 21 Sep 2016 19:35:27 +0000 (14:35 -0500)]
Merge "logger: Always enable verbose for console channel."

4 years agocore: Ensure presencestate subtype and message are NULL.
Joshua Colp [Wed, 21 Sep 2016 19:24:08 +0000 (19:24 +0000)]
core: Ensure presencestate subtype and message are NULL.

When retrieving presence state information there is no
guarantee that the subtype and message passed in are
set to NULL. This change ensures they are.

ASTERISK-26397 #close

Change-Id: If38cd730e409e9a9b6eb9adef6591d15a9e61f86

4 years agoMerge "logger: Fix default console settings."
zuul [Wed, 21 Sep 2016 17:22:35 +0000 (12:22 -0500)]
Merge "logger: Fix default console settings."

4 years agoMerge "core: Fix LOW_MEMORY missing symbol ast_pbx_uuid_get."
zuul [Wed, 21 Sep 2016 16:31:54 +0000 (11:31 -0500)]
Merge "core: Fix LOW_MEMORY missing symbol ast_pbx_uuid_get."

4 years agores_odbc: Make pooling option deprecation notice more useful.
Joshua Colp [Wed, 21 Sep 2016 15:48:47 +0000 (15:48 +0000)]
res_odbc: Make pooling option deprecation notice more useful.

This changes the notice for the deprecation of the old
pooling options to point to the new option for doing
pooling. This gives a clearer direction as to what to
look into.

ASTERISK-26389 #close

Change-Id: I2ca9cdfdcd75aec170a7db9d5ff69a4cd25b7c10

4 years agoodbc: Remove options that are no longer applicable.
Joshua Colp [Wed, 21 Sep 2016 13:46:36 +0000 (13:46 +0000)]
odbc: Remove options that are no longer applicable.

The pooling, shared_connection, limit, and idlecheck options
are no longer used in res_odbc.


Change-Id: I2fde7b467d01f9d1c82cc0a339bb4f7e1dd6bbe6

4 years agoMerge "asterisk.c: Non-root users also get the astcanary after core restart."
zuul [Wed, 21 Sep 2016 12:10:09 +0000 (07:10 -0500)]
Merge "asterisk.c: Non-root users also get the astcanary after core restart."

4 years agologger: Simplify ast_callid handling code.
Corey Farrell [Tue, 16 Aug 2016 20:21:33 +0000 (16:21 -0400)]
logger: Simplify ast_callid handling code.

Routines responsible for managing ast_callid's are overly complicated.
This is left-over code from when ast_callid was an AO2 object.  Now that
it is an integer the code can be reduced.

ast_callid handler code no longer prints it's own error message upon failure
to allocate threadstorage as ast_calloc would have already printed a
message.  Debug messages that were printed when TEST_FRAMEWORK was
enabled have been also been removed.

Change-Id: I65a768a78dc6cf3cfa071e97f33ce3dce280258e

4 years agocore: Fix LOW_MEMORY missing symbol ast_pbx_uuid_get.
Corey Farrell [Tue, 20 Sep 2016 20:17:42 +0000 (16:17 -0400)]
core: Fix LOW_MEMORY missing symbol ast_pbx_uuid_get.

Move the function outside the conditional block that excludes

ASTERISK-26273 #close

Change-Id: Ic290fa128222c410c3531107e30efacabc8493b4

4 years agoMerge "res_pjsip_multihomed: Change Contact port to listening port."
zuul [Tue, 20 Sep 2016 17:45:16 +0000 (12:45 -0500)]
Merge "res_pjsip_multihomed: Change Contact port to listening port."

4 years agologger: Always enable verbose for console channel.
Corey Farrell [Tue, 20 Sep 2016 14:22:45 +0000 (10:22 -0400)]
logger: Always enable verbose for console channel.

Previous versions of Asterisk did not require verbose to be specified in
logger.conf for the console channel, if it was requested by command line
or asterisk.conf it just worked.  This change causes Asterisk to always
enable verbose in the console channel level mask.  Verbose is displayed
on consoles if requested by command line, option_verbose or 'core set

This also delays initialization of the logger until after threadstorage
is initialized.  Initializing too early can cause messages to be printed
multiple times to the console (stdout).

ASTERISK-26391 #close

Change-Id: I52187d67c2fcb3efd5561bf04b3e5e23e5ee8a04

4 years agologger: Fix default console settings.
Corey Farrell [Tue, 20 Sep 2016 15:16:42 +0000 (11:16 -0400)]
logger: Fix default console settings.

When logger.conf is missing or invalid we should be printing notices,
warnings and errors to the console.  The logmask was incorrectly

Change-Id: Ibaa9465a8682854bc1a5e9ba07079bea1bfb6bb3

4 years agoMerge "sd_notify (systemd status notifications) support"
zuul [Tue, 20 Sep 2016 16:19:02 +0000 (11:19 -0500)]
Merge "sd_notify (systemd status notifications) support"

4 years agoMerge "rtp: Only accept the first payload for a format in SDP."
zuul [Tue, 20 Sep 2016 14:34:58 +0000 (09:34 -0500)]
Merge "rtp: Only accept the first payload for a format in SDP."

4 years agoMerge "Fix showing of swap details when sysinfo() is available"
zuul [Mon, 19 Sep 2016 21:05:02 +0000 (16:05 -0500)]
Merge "Fix showing of swap details when sysinfo() is available"

4 years agoasterisk.c: Non-root users also get the astcanary after core restart.
Walter Doekes [Mon, 19 Sep 2016 19:21:23 +0000 (21:21 +0200)]
asterisk.c: Non-root users also get the astcanary after core restart.

Without this change, a 'core restart' would kill the astcanary forever
if you're not running as root. Both with and without this patch, the
scheduling priority was still SCHED_RR after restart.

Additionally, the astcanary is now spawned if you start with high
priority and Asterisk doesn't get a chance to lower it. For example
through: `chrt -r 10 sudo -u asterisk asterisk -c`

Also reap killed astcanary processes on core restart.

ASTERISK-26352 #close

Change-Id: Iacb49f26491a0717084ad46ed96b0bea5f627a55

4 years agoMerge "res_config_odbc.c: Fix buffer size limitation creating invalid SQL."
zuul [Mon, 19 Sep 2016 20:21:30 +0000 (15:21 -0500)]
Merge "res_config_odbc.c: Fix buffer size limitation creating invalid SQL."

4 years agoMerge "asterisk.c: When astcanary dies on linux, reset priority on all threads."
zuul [Mon, 19 Sep 2016 20:02:09 +0000 (15:02 -0500)]
Merge "asterisk.c: When astcanary dies on linux, reset priority on all threads."

4 years agoasterisk.c: When astcanary dies on linux, reset priority on all threads.
Walter Doekes [Mon, 19 Sep 2016 14:40:40 +0000 (16:40 +0200)]
asterisk.c: When astcanary dies on linux, reset priority on all threads.

Previously only the canary checking thread itself had its priority set
to SCHED_OTHER. Now all threads are traversed and adjusted.

ASTERISK-19867 #close
Reported by: Xavier Hienne

Change-Id: Ie0dd02a3ec42f66a78303e9c1aac28f7ed9aae39

4 years agores_config_odbc.c: Fix buffer size limitation creating invalid SQL.
Richard Mudgett [Mon, 12 Sep 2016 23:00:22 +0000 (18:00 -0500)]
res_config_odbc.c: Fix buffer size limitation creating invalid SQL.

Creating ODBC SQL queries resulted in queries too large to fit into the
supplied buffer.  The resulting truncated buffer contained an invalid SQL

* Made SQL query generation code use a thread storage buffer that can
increase in size as needed.

* Fixed bad multi-line warning messages.

ASTERISK-26263 #close
Reported by: Jeppe Ryskov Larsen

Change-Id: I23f3cdd43c2dac80bed3ded4dd77d18cb17f21ae

4 years agortp: Only accept the first payload for a format in SDP.
Joshua Colp [Wed, 14 Sep 2016 11:53:36 +0000 (07:53 -0400)]
rtp: Only accept the first payload for a format in SDP.

When receiving an SDP offer with multiple payloads for
the same format we would generate an answer with the first
payload, but during the payload crossover operation
(to set the payloads for receiving) we would remove all
payloads but the last. This would result in incoming
traffic being matched against the wrong format and outgoing
traffic being sent using the wrong payload.

This change makes it so that once a format has a payload
number put into the mapping all subsequent ones are ignored.
This ensures there is only ever one payload in the mapping
and that it is the payload placed into the answer SDP.

ASTERISK-26365 #close

Change-Id: I1e8150860a3518cab36d00b1fab50f9352b64e60

4 years agores_pjsip_multihomed: Change Contact port to listening port.
Joshua Colp [Wed, 14 Sep 2016 13:42:46 +0000 (09:42 -0400)]
res_pjsip_multihomed: Change Contact port to listening port.

The res_pjsip_multihomed module determines what interface and transport
a request is going out on and updates the SIP message accordingly with
the address information. This currently incorrectly updates the Contact
header for connectionful protocols to the ephemeral connection port,
instead of the bound address for the listening socket which can actually
accept the connection back. If the remote side attempts to connect back on
the epehemeral port it will fail.

This change makes it so the port is updated to the bound port on
connectionful protocols and is maintained on UDP (as there can be
multiple of those).

ASTERISK-26374 #close

Change-Id: I50f8dab65b9f75117d73ba5f6bbcf6c9871854ab

4 years agopjproject_bundled: Prevent SERVFAIL from marking name server bad
George Joseph [Wed, 7 Sep 2016 19:48:48 +0000 (13:48 -0600)]
pjproject_bundled:  Prevent SERVFAIL from marking name server bad

A name server that returns "Server Failure" is indicating only that
the server couldn't process that particular request.  We should NOT
assume that the name server is incapable of serving other requests.

Here's the scenario we've been encountering...

* 2 local name servers configured in resolv.conf.
* An OPTIONS request causes a request for A and AAAA records to go out
  to both nameservers.
* The A responses both come back successfully resolved.
* Because of an issue at some upstream nameserver, the AAAA responses
  for that particular query come back as "SERVFAIL" from both local
  name servers.
* Both local servers are marked as bad and no further queries can be
  sent until the 60 second ttl expires.  Only previously cached results
  can be used.
* In this case, 60 seconds is just enough time for another OPTIONS
  request to go out to the same host so the cycle repeats.

We could set the bad ttl really low but that also affects REFUSED and
NOTAUTH which probably DO signal a real server issue.  Besides, even
a really low bad ttl would be an issue on a pbx.

Although we use our own resolver in 14 and master and don't have this
issue there, Teluu has merged this patch upstream so it's appropriate
to cherry-pick to 14 and master to keep pjproject consistent.

Change-Id: Ie03ba902288e274aff23f9b9bb2786e1e8be09e0

4 years agocdr_mysql: fix UTC support
Tzafrir Cohen [Mon, 12 Sep 2016 12:37:30 +0000 (15:37 +0300)]
cdr_mysql: fix UTC support

* Make 'cdrzone=UTC' work properly.
* Fix the documentation of cdr_mysql.conf: it's cdrzone and not timezone

ASTERISK-26359 #close

Change-Id: I2a6f67b71bbbe77cac31a34d0bbfb1d67c933778

4 years agosd_notify (systemd status notifications) support
Tzafrir Cohen [Mon, 27 Jun 2016 19:26:54 +0000 (21:26 +0200)]
sd_notify (systemd status notifications) support

sd_notify() is used to notify systemd of changes to the status of the
process. This allows the systemd daemon to know when the process
finished loading (and thus only start another program after Asterisk has
finished loading).

To use this, use a systemd unit with 'Type=notify' for Asterisk.

This commit also adds the function ast_sd_notify(), a wrapper around
sd_notify that does nothing if not built with systemd support.

Also adds support for libsystemd detection in the configure script.

Change-Id: Ied6a59dafd5ef331c5c7ae8f3ccd2dfc94be7811

4 years agoFix showing of swap details when sysinfo() is available
Timo Teräs [Fri, 9 Sep 2016 11:35:43 +0000 (14:35 +0300)]
Fix showing of swap details when sysinfo() is available

If sysinfo() is available, but not sysctl() or swapctl() the
printing code for swap buffer sizes is incorrectly omitted.
The above condition happens with musl c-library.

Fix #if rule to consider defined(HAVE_SYSINFO). And also
remove the redundant || defined(HAVE_SYSCTL) which was
incorrectly there to start with. Now swap information is
displayed only if an actual libc function to get it is

This also fixes warnings previously seen with musl libc:

   [CC] asterisk.c -> asterisk.o
asterisk.c: In function 'handle_show_sysinfo':
asterisk.c:773:6: warning: variable 'totalswap' set but not used
  int totalswap = 0;
asterisk.c:770:11: warning: variable 'freeswap' set but not used
  uint64_t freeswap = 0;

Change-Id: I1fb21dad8f27e416c60f138c6f2bff03fb626eca

4 years agoMerge "res_pjsip_transport_management: Convert time in log message to seconds."
zuul [Thu, 15 Sep 2016 03:35:43 +0000 (22:35 -0500)]
Merge "res_pjsip_transport_management: Convert time in log message to seconds."

4 years agoMerge "chan_sip: Fix session timeout on retransmit of non-UDP packets"
zuul [Thu, 15 Sep 2016 00:42:21 +0000 (19:42 -0500)]
Merge "chan_sip: Fix session timeout on retransmit of non-UDP packets"

4 years agoMerge "rtp: Preserve timestamps on video frames."
zuul [Wed, 14 Sep 2016 22:21:12 +0000 (17:21 -0500)]
Merge "rtp: Preserve timestamps on video frames."

4 years agoMerge " Map legacy_useroption_parsing."
zuul [Wed, 14 Sep 2016 20:03:46 +0000 (15:03 -0500)]
Merge " Map legacy_useroption_parsing."

4 years agortp: Preserve timestamps on video frames.
Joshua Colp [Wed, 14 Sep 2016 12:59:51 +0000 (08:59 -0400)]
rtp: Preserve timestamps on video frames.

Currently when receiving video over RTP we store only
a calculated samples on the frame. When starting the video
it can take some time for this calculation to actually yield
a value as it requires constant changing timestamps. As well
if a video frame passes over multiple RTP packets this calculation
will fail as the timestamp is the same as the previous RTP
packet and the number of samples calculated will be 0.

This change preserves the timestamp on the frame and allows
it to pass through the core. When sending the video this timestamp
is used instead of a new one being calculated.

ASTERISK-26367 #close

Change-Id: Iba8179fb5c14c9443aee4baf670d2185da3ecfbd

4 years agoMerge "res_pjsip: Add ignore_uri_user_options option."
zuul [Wed, 14 Sep 2016 17:27:28 +0000 (12:27 -0500)]
Merge "res_pjsip: Add ignore_uri_user_options option."

4 years agores_pjsip_transport_management: Convert time in log message to seconds.
Joshua Colp [Wed, 14 Sep 2016 14:51:53 +0000 (10:51 -0400)]
res_pjsip_transport_management: Convert time in log message to seconds.

ASTERISK-26375 #close

Change-Id: I46496af5cae41413e76d44d2068a7431279f09dc

4 years agoMerge "res_pjsip: Don't assume a request will have any addresses."
zuul [Tue, 13 Sep 2016 23:24:44 +0000 (18:24 -0500)]
Merge "res_pjsip: Don't assume a request will have any addresses."

4 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

4 years agoMerge "chan_sip: Allow target refresh (Contact update) on re-INVITE."
zuul [Tue, 13 Sep 2016 15:26:50 +0000 (10:26 -0500)]
Merge "chan_sip: Allow target refresh (Contact update) on re-INVITE."

4 years agoMerge "res_pjsip_messaging.c: Misc cleanups and fixes."
zuul [Tue, 13 Sep 2016 14:04:02 +0000 (09:04 -0500)]
Merge "res_pjsip_messaging.c: Misc cleanups and fixes."

4 years agores_pjsip: Don't assume a request will have any addresses.
Joshua Colp [Tue, 13 Sep 2016 11:08:18 +0000 (07:08 -0400)]
res_pjsip: Don't assume a request will have any addresses.

When performing DNS resolution the failover code present in
res_pjsip currently assumes that a request will always have
at least one viable address. In practice this is not true.
A domain may be used that has no records.

The code now checks that at least one address exists on the
request which prevents looping.

ASTERISK-26364 #close

Change-Id: Ic0761b0264864acd85915c94d878a81624940f4c

4 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

4 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."

4 years agochan_sip: Allow target refresh (Contact update) on re-INVITE.
Walter Doekes [Mon, 12 Sep 2016 08:28:17 +0000 (10:28 +0200)]
chan_sip: Allow target refresh (Contact update) on re-INVITE.

Previously, the Contact was stored only on initial INVITE and on any
18X and 200. That meant that after re-INVITEs from *us* the Contact
could get updated, but after re-INVITEs from the *peer*, it did not.

This changeset fixes this inconsistency, properly allowing target
refreshes through re-INVITES (RFC3261, 12.2).

If your strictrtp setting allows it, this change allows you to switch
the source IP of a connected/calling device mid-call with a simple
re-INVITE from the new IP.

ASTERISK-26358 #close

Change-Id: Ibb8512054ab27c8c3d2514022568fde943bf2435

4 years Map legacy_useroption_parsing.
Richard Mudgett [Wed, 31 Aug 2016 20:22:01 +0000 (15:22 -0500)] Map legacy_useroption_parsing.

Map the sip.conf general section legacy_useroption_parsing to the
new pjsip.conf global ignore_uri_user_options.

Reported by: Kevin Harwell

Change-Id: I78108a31995db19d41f4e1a07b3324692c5363fc

4 years agores_pjsip: Add ignore_uri_user_options option.
Richard Mudgett [Mon, 29 Aug 2016 23:08:22 +0000 (18:08 -0500)]
res_pjsip: Add ignore_uri_user_options option.

This implements the chan_sip legacy_useroption_parsing option but with a
better name.

* Made the caller-id number and redirecting number strings obtained from
incoming SIP URI user fields always truncated at the first semicolon.
People don't care about anything after the semicolon showing up on their
displays even though the RFC allows the semicolon.

ASTERISK-26316 #close
Reported by: Kevin Harwell

Change-Id: Ib42b0e940dd34d84c7b14bc2e90d1ba392624f62

4 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."

4 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

4 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

4 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

4 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

4 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

4 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."

4 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."

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

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

4 years agores_pjsip_messaging.c: Misc cleanups and fixes.
Richard Mudgett [Tue, 6 Sep 2016 16:46:16 +0000 (11:46 -0500)]
res_pjsip_messaging.c: Misc cleanups and fixes.

* Eliminated RAII_VAR in get_outbound_endpoint().

* Simplify update_to() coding.  However, this function can only be a NoOp
because the To string can only be a URI and not a name-address formatted

* Simplify update_from() coding.  Also fixed a code path modifying the
from string when the caller could still want to use the original string.

* Fixed msg_data_create() incompletely removing the "pjsip:" to then add
back the "sip:" string if needed.  The code didn't handle the "pjsip:sip:"
case because it left the colon after pjsip in the string.

Change-Id: I68a09a665f6d4daa9eaa59069045ab69122e28db

4 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

4 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."

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

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

4 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

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

4 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

4 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

4 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."

4 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."

4 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"."

4 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()."

4 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."

4 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."

4 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

4 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."

4 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."

4 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."

4 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."

4 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."

4 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

4 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."

4 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."

4 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

4 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

4 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."

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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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