[Pkg-voip-commits] [asterisk] 01/03: Imported Upstream version 11.13.1~dfsg

tzafrir at debian.org tzafrir at debian.org
Sun Oct 26 04:59:58 UTC 2014


This is an automated email from the git hooks/post-receive script.

tzafrir pushed a commit to branch master
in repository asterisk.

commit dbd07fb838e4c5793e22b8f8c08798c504add39a
Author: Tzafrir Cohen <tzafrir at debian.org>
Date:   Sun Oct 26 05:28:06 2014 +0200

    Imported Upstream version 11.13.1~dfsg
---
 .version                      |   2 +-
 ChangeLog                     | 401 ++++++++++++++++++++++++
 LICENSE                       |   2 +-
 UPGRADE.txt                   |  12 +
 apps/app_dial.c               |   4 +-
 apps/app_voicemail.c          |   7 +-
 asterisk-11.12.0-summary.html | 180 -----------
 asterisk-11.12.0-summary.txt  | 237 --------------
 asterisk-11.13.1-summary.html |  65 ++++
 asterisk-11.13.1-summary.txt  |  95 ++++++
 channels/chan_iax2.c          |  38 ++-
 channels/chan_sip.c           |  31 +-
 configs/sip.conf.sample       |   4 +-
 configure                     | 508 +++++++++++++++---------------
 configure.ac                  |   6 +-
 contrib/scripts/refcounter.py |  82 ++++-
 doc/aelparse.8                |  28 ++
 doc/smsq.8                    | 146 +++++++++
 funcs/func_config.c           |   4 +-
 include/asterisk/config.h     |   5 +-
 include/asterisk/utils.h      |   9 +
 main/app.c                    |   4 +-
 main/astobj2.c                |  12 +-
 main/callerid.c               |  65 ++--
 main/channel.c                |  15 +-
 main/cli.c                    |   4 +-
 main/config.c                 |  68 ++--
 main/file.c                   |   4 +-
 main/logger.c                 |  45 ++-
 main/manager.c                |  18 +-
 main/tcptls.c                 |  24 +-
 main/utils.c                  |  25 +-
 menuselect/menuselect.c       |   2 +-
 res/res_fax_spandsp.c         |  21 +-
 res/res_jabber.c              |   7 +-
 res/res_musiconhold.c         |  27 +-
 res/res_rtp_asterisk.c        | 709 ++++++++++++++++++++++++++++--------------
 res/res_xmpp.c                |   8 +-
 sounds/Makefile               |   7 +-
 sounds/sounds.xml             |  27 ++
 tests/test_callerid.c         | 165 ++++++++++
 tests/test_utils.c            | 100 +++++-
 42 files changed, 2150 insertions(+), 1073 deletions(-)

diff --git a/.version b/.version
index a098073..5f7d6d2 100644
--- a/.version
+++ b/.version
@@ -1 +1 @@
-11.12.0
+11.13.1
diff --git a/ChangeLog b/ChangeLog
index 23848e6..fd58c5f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,404 @@
+2014-10-20  Asterisk Development Team <asteriskteam at digium.com>
+
+	* Asterisk 11.13.1 Released.
+
+	* AST-2014-011: Fix POODLE security issues
+
+	  There are two aspects to the vulnerability:
+	  (1) res_jabber/res_xmpp use SSLv3 only. This patch updates the module
+	      to use TLSv1+. At this time, it does not refactor res_jabber/
+	      res_xmpp to use the TCP/TLS core, which should be done as an
+	      improvement at a latter date.
+	  (2) The TCP/TLS core, when tlsclientmethod/sslclientmethod is left
+	      unspecified, will default to the OpenSSL SSLv23_method. This
+	      method allows for all encryption methods, including SSLv2/SSLv3.
+	      A MITM can exploit this by forcing a fallback to SSLv3, which
+	      leaves the server vulnerable to POODLE. This patch adds WARNINGS
+	      if a user uses SSLv2/SSLv3 in their configuration, and explicitly
+	      disables SSLv2/SSLv3 if using SSLv23_method.
+
+	  For TLS clients, Asterisk will default to TLSv1+ and WARN if SSLv2 or
+	  SSLv3 is explicitly chosen. For TLS servers, Asterisk will no longer
+	  support SSLv2 or SSLv3.
+
+	  Much thanks to abelbeck for reporting the vulnerability and providing
+	  a patch for the res_jabber/res_xmpp modules.
+
+2014-09-24  Asterisk Development Team <asteriskteam at digium.com>
+
+	* Asterisk 11.13.0 Released.
+
+2014-09-19  Asterisk Development Team <asteriskteam at digium.com>
+
+	* Asterisk 11.13.0-rc1 Released.
+
+2014-09-18 16:30 +0000 [r423400]  Richard Mudgett <rmudgett at digium.com>
+
+	* /, main/astobj2.c, contrib/scripts/refcounter.py:
+	  astobj2.c/refcounter.py: Fix to deal with invalid object refs. *
+	  Make astob2 REF_DEBUG output an invalid object line when an
+	  invalid ao2 object ref/unref is attempted. This is similar to the
+	  constructor/destructor lines. * Fixed refcounter.py to handle
+	  skewed objects that have constructor/destructor states. * Made
+	  refcounter.py highlight the invalid ao2 object refs by putting
+	  them in their own section of the processed output file. * Made
+	  refcounter.py highlight unreffing an object by more than one that
+	  results in a negative ref count and the object being destroyed.
+	  The abnormally destroyed object is reported in the invalid and
+	  finalized object sections of the output. Review:
+	  https://reviewboard.asterisk.org/r/3971/ ........ Merged
+	  revisions 423349 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-09-18 16:19 +0000 [r423360]  Mark Michelson <mmichelson at digium.com>
+
+	* res/res_fax_spandsp.c: res_fax_spandsp: Properly handle cleanup
+	  before starting FAXes. If faxing fails at a very early stage,
+	  then it is possible for us to pass a NULL t30 state pointer to
+	  spandsp, which spandsp is none too pleased with. This patch
+	  ensures that we pass the correct pointer to spandsp in the
+	  situation where we have not yet set our local t30 state pointer.
+	  ASTERISK-24301 #close Reported by Matt Jordan Patches:
+	  ASTERISK-24301-fax.diff Uploaded by Mark Michelson (License
+	  #5049)
+
+2014-09-18 14:42 +0000 [r423277]  George Joseph <george.joseph at fairview5.com>
+
+	* main/config.c, main/manager.c, /, include/asterisk/config.h:
+	  config: bug: Fix SEGV in ast_category_insert when matching
+	  category isn't found If you call ast_category_insert with a match
+	  category that doesn't exist, the list traverse runs out of 'next'
+	  categories and you get a SEGV. This patch adds check for the
+	  end-of-list condition and changes the signature to return an int
+	  for success/failure indication instead of a void. The only
+	  consumer of this function is manager and it was also changed to
+	  use the return value. Tested by: George Joseph Review:
+	  https://reviewboard.asterisk.org/r/3993/ ........ Merged
+	  revisions 423276 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-09-17 18:02 +0000 [r423150-423253]  Joshua Colp <jcolp at digium.com>
+
+	* res/res_rtp_asterisk.c: res_rtp_asterisk: Ensure that the thread
+	  terminating pj stuff is registered.
+
+	* res/res_rtp_asterisk.c: res_rtp_asterisk: Fix 100% CPU usage due
+	  to timer heap thread spinning. Side note: I need a vacation.
+
+	* res/res_rtp_asterisk.c: res_rtp_asterisk: Fix building when
+	  pjproject is not used.
+
+	* res/res_rtp_asterisk.c: res_rtp_asterisk: Fix a myriad of TURN
+	  client issues. 1. The number of file descriptors an ioqueue
+	  instance can handle is fixed, so we now spawn the required number
+	  to handle the load. 2. Our transport identifiers were exceeding
+	  the range supported by pjnath. 3. The TURN client did not set up
+	  client binding causing needless bandwidth usage. 4. The code no
+	  longer updates address information on each packet. 5. STUN
+	  traffic was getting looped back to Asterisk instead of going
+	  through the TURN server. 6. Synchronization now ensures things
+	  are completely setup or destroyed. 7. Logging now reflects the
+	  target the TURN server is sending to/receiving from on our
+	  behalf. ASTERISK-23577 #close Reported by: Jay Jideliov
+	  ASTERISK-23634 #close Reported by: Roman Skvirsky Review:
+	  https://reviewboard.asterisk.org/r/3982/
+
+2014-09-14 15:49 +0000 [r423067]  Walter Doekes <walter+asterisk at wjd.nu>
+
+	* configs/sip.conf.sample, /: chan_sip: Clarify that sipdebug=yes
+	  cannot be undone by the CLI. Document it in sip.conf.
+	  ASTERISK-24249 #close Reported by: Avinash Mohod Review:
+	  https://reviewboard.asterisk.org/r/3926/ ........ Merged
+	  revisions 423066 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-09-12 18:18 +0000 [r423010]  Kinsey Moore <kmoore at digium.com>
+
+	* main/channel.c, /: Bridging: Fix bouncing native bridge This
+	  fixes a situation in Asterisk 1.8 and 11 where ast_channel_bridge
+	  could cause a bouncing native bridge. In the case of the
+	  dial_LS_options test, this was a remote RTP bridge which caused
+	  the audio path to continually cycle between Asterisk and the
+	  remote endpoints generating a large number of SIP messages and
+	  delaying the test long enough to cause it to fail (checking
+	  timing was part of the test). The root cause was that the code to
+	  decide whether to use native bridging was expecting a
+	  time-remaining value of 0 to be the default instead of the actual
+	  default value of -1. A value of 0 or negative numbers could also
+	  be generated by preceding code in some circumstances. Both issues
+	  are addressed in this patch. ASTERISK-24211 #close Reported by:
+	  Matt Jordan Review: https://reviewboard.asterisk.org/r/3987/
+	  ........ Merged revisions 423006 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-09-10 16:01 +0000 [r422903]  George Joseph <george.joseph at fairview5.com>
+
+	* /, main/config.c: config: bug: fix truncation of included config
+	  files on permissions error ast_config_text_file_save() currently
+	  truncates include files as they are processed. If a subsequent
+	  include file or the main config file has a permissions error that
+	  prevents writing, earlier include files are left truncated
+	  resulting in a frantic search for backups. This patch causes
+	  ast_config_text_file_save to check for write access on all files
+	  before it truncates any of them. Will be applied 1.8 > trunk.
+	  Tested by: George Joseph Review:
+	  https://reviewboard.asterisk.org/r/3986/ ........ Merged
+	  revisions 422900 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-09-07 00:08 +0000 [r422790]  Rusty Newton <rnewton at digium.com>
+
+	* sounds/sounds.xml, sounds/Makefile, /: Sounds/BuildSystem:
+	  Modifications to include new releases and Japanese language.
+	  Modifying Makefile and sounds.xml to include new core 1.4.26 and
+	  extra 1.4.15 sound prompt releases, plus the new Japanese core
+	  sound prompts contributed by QLOOG. ASTERISK-23324 Reported by:
+	  Kevin McCoy Tested by: Rusty Newton ........ Merged revisions
+	  422789 from http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-09-04 20:39 +0000 [r422625]  Jonathan Rose <jrose at digium.com>
+
+	* main/manager.c, /: Manager: Require read permission for SYSTEM in
+	  order to send FullyBooted Review:
+	  https://reviewboard.asterisk.org/r/3969/ ........ Merged
+	  revisions 422584 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-30 17:22 +0000 [r422440]  George Joseph <george.joseph at fairview5.com>
+
+	* main/manager.c, /: manager: Make WaitEvent action respect
+	  eventfilters A WaitEvent issued via an http session isn't
+	  respecting eventfilters defined for the user. I just added a
+	  match_filter to the predicate that controls astman_append. Tested
+	  by: George Joseph Review:
+	  https://reviewboard.asterisk.org/r/3958/ ........ Merged
+	  revisions 422439 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-29 19:39 +0000 [r422294-422377]  Matthew Jordan <mjordan at digium.com>
+
+	* doc/smsq.8 (added), /: doc: Add a manpage for the smsq utility
+	  This patch adds a manpage for the smsq utility. Note that this is
+	  one of the patches the Debian distro applies for the Asterisk
+	  project, as per ASTERISK-24191. Review:
+	  https://reviewboard.asterisk.org/r/3895/ ASTERISK-24171 #close
+	  Reported by: Jeremy Laine patches: smsq.8 uploaded by Jeremy
+	  Laine (License 6561) ........ Merged revisions 422376 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+	* doc/aelparse.8 (added), /: doc: Add a manpage for the aelparse
+	  utility This patch adds a manpage for the aelparse utility. Note
+	  that this is one of the patches the Debian distro applies for the
+	  Asterisk project, as per ASTERISK-24191. Review:
+	  https://reviewboard.asterisk.org/r/3896/ ASTERISK-24171 #close
+	  Reported by: Jeremy Laine patches: aelparse.8 uploaded by Jeremy
+	  Laine (License 6561) ........ Merged revisions 422371 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+	* /, LICENSE: LICENSE: Clarify language in Asterisk's LICENSE to
+	  allow for linking to UniMRCP The UniMRCP project distributes
+	  Asterisk modules that integrate Asterisk with UniMRCP, and other
+	  Asterisk users use the UniMRCP library as well. Unfortunately,
+	  the UniMRCP license is Apache 2.0, which per the Free Software
+	  Foundation, is not a compatible license with the GPLv2. "Please
+	  note that this license is not compatible with GPL version 2,
+	  because it has some requirements that are not in that GPL
+	  version. These include certain patent termination and
+	  indemnification provisions. The patent termination provision is a
+	  good thing, which is why we recommend the Apache 2.0 license for
+	  substantial programs over other lax permissive licenses." On the
+	  other hand, UniMRCP is a great project and we'd like to let
+	  people use it with Asterisk. This patch updates the LICENSE text
+	  to allow users to link Asterisk with UniMRCP and distribute the
+	  resulting binaries. ........ Merged revisions 422293 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-28 20:26 +0000 [r422274]  Michael L. Young <elgueromexicano at gmail.com>
+
+	* channels/chan_iax2.c: chan_iax2: Fix Dynamic IAX2 Registrations
+	  After Temporary DNS Failure The reporter on the issue found some
+	  issues when upgrading from version 10 to 11 on 55 hosts. Two
+	  situations that can occur with dynamic registrations. 1. With
+	  dnsmgr disabled, if the host is not resolvable we are not trying
+	  to resolve the host again when it is time to attempt to register
+	  again. This results in never registering to the host. 2. With
+	  dnsmgr enabled, when the host is temporarily not resolvable the
+	  address is set to 0.0.0.0:0 and then when the host is resolvable
+	  the port is not being restored and stays set to 0. This patch
+	  resolves these two issues by: * Storing the hostname so that it
+	  can be used for resolving with DNS. * Resolve the hostname on the
+	  next scheduled attempt to register. * Storing the port used to
+	  reach the host so that when the hostname is resolvable again, we
+	  can set the port again if the port is still unset after looking
+	  up the host. ASTERISK-23767 #close Reported by: David Herselman
+	  Tested by: David Herselman, Michael L. Young Patches:
+	  asterisk-23767-dns_reg_retry_and_set_port_11_v3.diff uploaded by
+	  Michael L. Young (license 5026) Review:
+	  https://reviewboard.asterisk.org/r/3856/
+
+2014-08-27 15:01 +0000 [r422113]  Kinsey Moore <kmoore at digium.com>
+
+	* /, channels/chan_sip.c, tests/test_callerid.c (added),
+	  tests/test_utils.c, main/callerid.c, main/utils.c,
+	  include/asterisk/utils.h: CallerID: Fix parsing of malformed
+	  callerid This allows the callerid parsing function to handle
+	  malformed input strings and strings containing escaped and
+	  unescaped double quotes. This also adds a unittest to cover many
+	  of the cases where the parsing algorithm previously failed.
+	  Review: https://reviewboard.asterisk.org/r/3923/ ........ Merged
+	  revisions 422112 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-25 16:07 +0000 [r421977]  Richard Mudgett <rmudgett at digium.com>
+
+	* /, res/res_musiconhold.c: res_musiconhold: Fix MOH restarting
+	  where it left off from the last hold. Restore code removed by
+	  https://reviewboard.asterisk.org/r/3536/ that introduced a
+	  regression that prevents MOH from restarting were it left off the
+	  last time. ASTERISK-24019 #close Reported by: Jason Richards
+	  Patches: jira_asterisk_24019_v1.8.patch (license #5621) patch
+	  uploaded by rmudgett Review:
+	  https://reviewboard.asterisk.org/r/3928/ ........ Merged
+	  revisions 421976 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-24 17:19 +0000 [r421909]  Joshua Colp <jcolp at digium.com>
+
+	* channels/chan_sip.c: chan_sip: Use the server reflexive ICE
+	  candidate RTCP port as provided. This code originally worked
+	  around an issue within res_rtp_asterisk itself. The wrong socket
+	  was being used for the STUN check for RTCP, causing the port to
+	  be the same as RTP. This was subsequently fixed and the RTCP port
+	  provided for the ICE candidate is correct and does not need to be
+	  incremented. ASTERISK-23997 #close Reported by: Badalian
+	  Vyacheslav Patches: plus1.diff submitted by Badalian Vyacheslav
+	  (license 5249)
+
+2014-08-21 22:03 +0000 [r421800]  Richard Mudgett <rmudgett at digium.com>
+
+	* /, res/res_musiconhold.c: res_musiconhold.c: Remove obsolete
+	  REF_DEBUG code. Remove unneeded code that writes to the wrong
+	  file location in an obsolete format. ........ Merged revisions
+	  421799 from http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-21 21:00 +0000 [r421777]  Jonathan Rose <jrose at digium.com>
+
+	* res/res_musiconhold.c, /: res_musiconhold: Fix reference leaks
+	  caused when reloading with REF_DEBUG set Due to a faulty function
+	  for debugging reference decrementing, it was possible to reduce
+	  the refcount on the wrong object if two moh classes of the same
+	  name were in the moh class container. (closes issue
+	  ASTERISK-22252) Reported by: Walter Doekes Patches:
+	  18_moh_debug_ref_patch.diff Uploaded by Jonathan Rose (license
+	  6182) ........ Merged revisions 398937 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-21 17:32 +0000 [r421718]  Matthew Jordan <mjordan at digium.com>
+
+	* /, channels/chan_sip.c: chan_sip: Don't use port derived from
+	  fromdomain if it isn't set If a user does not provide a port in
+	  the fromdomain setting, chan_sip will set the fromdomainport to
+	  STANDARD_SIP_PORT (5060). The fromdomainport value will then get
+	  used unilaterally in certain places. This causes issues with TLS,
+	  where the default port is expected to be 5061. This patch
+	  modifies chan_sip such that fromdomainport is only used if it is
+	  not the standard SIP port; otherwise, the port from the SIP pvt's
+	  recorded self IP address is used. Review:
+	  https://reviewboard.asterisk.org/r/3893/ ASTERISK-24178 #close
+	  Reported by: Elazar Broad patches: fromdomainport_fix.diff
+	  uploaded by Elazar Broad (License 5835) ........ Merged revisions
+	  421717 from http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-20 22:17 +0000 [r421602]  Richard Mudgett <rmudgett at digium.com>
+
+	* /, main/cli.c: cli.c: Fix tab completion of "module load" when
+	  MALLOC_DEBUG is enabled. filename_completion_function() returns
+	  memory that was not allocated by the MALLOC_DEBUG allocation
+	  tracker so the memory must be freed by ast_std_free(). ........
+	  Merged revisions 421600 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-19 19:41 +0000 [r421443]  Kinsey Moore <kmoore at digium.com>
+
+	* main/manager.c, /: AMI Docs: Fix Status channel parameter
+	  optionality ........ Merged revisions 421442 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-18 20:16 +0000 [r421328]  George Joseph <george.joseph at fairview5.com>
+
+	* funcs/func_config.c, /: func_config: Change 'Not Found' message
+	  from ERROR to DEBUG When you call the CONFIG dialplan function
+	  with the name of a variable that doesn't exist in the target
+	  context you get an ERROR. This does nothing but clutter up the
+	  logs with messages that may be perfectly acceptable. Just because
+	  a variable wasn't in the context doesn't mean it's an error.
+	  Maybei t's optional or just needs to be defaulted or ignored.
+	  This patch changes the log level from ERROR to DEBUG. If a
+	  dialplan developer wants to debug their dialplan they still canby
+	  setting the console debug level as needed. Tested by: George
+	  Joseph Review: https://reviewboard.asterisk.org/r/3919/ ........
+	  Merged revisions 421327 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-17 23:07 +0000 [r421228-421233]  Matthew Jordan <mjordan at digium.com>
+
+	* apps/app_dial.c, /: apps/app_dial: Fix Dial 'z' option The 'z'
+	  option is supposed to disable the dial timeout in the case of a
+	  call forward. Unfortunately, the wrong timeout timer was passed
+	  to the do_forward function, resulting in the option not working.
+	  ASTERISK-24225 #close Reported by: dimitripietro Tested by:
+	  dimitripietro patches: jira_asterisk_24225_v1.8.patch uploaded by
+	  rmudgett (License 5621) jira_asterisk_24225_v11.patch uploaded by
+	  rmudgett (License 5621) ........ Merged revisions 421232 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+	* /, configure, configure.ac: configure: Undefine FORTIFY_SOURCE
+	  prior to defining it for patched gcc Some distributions of Linux
+	  patch gcc to define FORTIFY_SOURCE when gcc is executed with
+	  optimization. This "help" unfortunately results in re-definition
+	  warnings when FORTIFY_SOURCE is later defined in Asterisk's build
+	  system. This patch undefines FORTIFY_SOURCE prior to defining it
+	  to prevent this warning. Review:
+	  https://reviewboard.asterisk.org/r/3912/ ASTERISK-24032 #close
+	  Reported by: Kilburn Tested by: Kilburn, wdoekes patches:
+	  1.8.diff uploaded by cloos (License 5956) 10.diff uploaded by
+	  cloos (License 5956) 11.diff uploaded by cloos (License 5956)
+	  12.diff uploaded by cloos (License 5956) 13.diff uploaded by
+	  cloos (License 5956) ........ Merged revisions 421227 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-15 15:36 +0000 [r421060-421164]  Matthew Jordan <mjordan at digium.com>
+
+	* apps/app_voicemail.c, main/app.c: app_voicemail/app: Remove test
+	  events that were duplicated by r421059 Moving the test event
+	  raised when a file is played back (which occurred in r421059)
+	  broke the ever loving snot out of the voicemail tests. This
+	  caused duplicate test events to get raised, as app_voicemail and
+	  main/app were raising events prior to call ast_streamfile. The
+	  voicemail tests did not enjoy getting multiple events. Since
+	  raising the playback event in ast_streamfile is far more useful
+	  to the vast majority of tests, this patch keeps the call there
+	  and simply removes the extraneous calls that duplicated the
+	  event. ........ Merged revisions 421125 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+	* /, main/file.c, main/app.c: main/file: Move test event to emit
+	  PLAYBACK event more consistently This is being done in advance of
+	  the test for ASTERISK-23953 ........ Merged revisions 421059 from
+	  http://svn.asterisk.org/svn/asterisk/branches/1.8
+
+2014-08-13 07:47 +0000 [r420897]  Walter Doekes <walter+asterisk at wjd.nu>
+
+	* main/logger.c: logger: Don't store verbose-magic in the log
+	  files. In r399267, the verbose2magic stuff was edited. This time
+	  it results in magic characters in the log files for multiline
+	  messages. In trunk (and 13) this was fixed by the "stripping" of
+	  those characters from multiline messages (in r414798). This is a
+	  backport of that fix to 11. That fix is altered to actually strip
+	  the characters and not replace them with blanks. Review:
+	  https://reviewboard.asterisk.org/r/3901/ Review:
+	  https://reviewboard.asterisk.org/r/3902/
+
 2014-08-19  Asterisk Development Team <asteriskteam at digium.com>
 
 	* Asterisk 11.12.0 Released.
diff --git a/LICENSE b/LICENSE
index d530d18..16230ff 100644
--- a/LICENSE
+++ b/LICENSE
@@ -25,7 +25,7 @@ GPL'd products (although if you've written a module for Asterisk we
 would strongly encourage you to make the same exception that we do).
 
 Specific permission is also granted to link Asterisk with OpenSSL, OpenH323
-and/or the UW IMAP Toolkit and distribute the resulting binary files.
+UniMRCP, and/or the UW IMAP Toolkit and distribute the resulting binary files.
 
 In addition, Asterisk implements two management/control protocols: the
 Asterisk Manager Interface (AMI) and the Asterisk Gateway Interface
diff --git a/UPGRADE.txt b/UPGRADE.txt
index f79f048..1ec4811 100644
--- a/UPGRADE.txt
+++ b/UPGRADE.txt
@@ -20,6 +20,18 @@
 ===
 ===========================================================
 
+from 11.13.0 to 11.13.1:
+
+* Due to the POODLE vulnerability (see 
+  https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566), the
+  default TLS method for TLS clients will no longer allow SSLv3. As
+  SSLv2 was already deprecated, it is no longer allowed by default as
+  well. TLS servers no longer allow SSLv2 or SSLv3 connections. This
+  affects the chan_sip channel driver, AMI, and the Asterisk HTTP server.
+
+* The res_jabber resource module no longer uses SSLv3 to connect to an
+  XMPP server. It will now only use TLSv1 or later methods.
+
 from 11.10.2 to 11.11.0
  - Added a compatibility option for chan_sip, 'websocket_write_timeout'.
    When a websocket connection exists where Asterisk writes a substantial
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 827b869..da881fd 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -33,7 +33,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 413587 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 421233 $")
 
 #include <sys/time.h>
 #include <sys/signal.h>
@@ -1267,7 +1267,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
 					ast_channel_unlock(in);
 				}
 
-				do_forward(o, &num, peerflags, single, caller_entertained, to,
+				do_forward(o, &num, peerflags, single, caller_entertained, &orig,
 					forced_clid, stored_clid);
 
 				if (single && o->chan
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index a552c10..4ef09dd 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -91,7 +91,7 @@
 #endif
 #endif
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 419284 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 421164 $")
 
 #include "asterisk/paths.h"	/* use ast_config_AST_SPOOL_DIR */
 #include <sys/time.h>
@@ -7981,7 +7981,6 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
 			}
 		} else {
 			/* Ask for an extension */
-			ast_test_suite_event_notify("PLAYBACK", "Message: vm-extension");
 			res = ast_streamfile(chan, "vm-extension", ast_channel_language(chan));	/* "extension" */
 			prompt_played++;
 			if (res || prompt_played > 4)
@@ -10533,7 +10532,6 @@ static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_
 	adsi_begin(chan, &useadsi);
 	if (!skipuser && useadsi)
 		adsi_login(chan);
-	ast_test_suite_event_notify("PLAYBACK", "Message: vm-login");
 	if (!silent && !skipuser && ast_streamfile(chan, "vm-login", ast_channel_language(chan))) {
 		ast_log(AST_LOG_WARNING, "Couldn't stream login file\n");
 		return -1;
@@ -10581,7 +10579,6 @@ static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_
 			/* saved password is blank, so don't bother asking */
 			password[0] = '\0';
 		} else {
-			ast_test_suite_event_notify("PLAYBACK", "Message: %s", vm_password);
 			if (ast_streamfile(chan, vm_password, ast_channel_language(chan))) {
 				ast_log(AST_LOG_WARNING, "Unable to stream password file\n");
 				return -1;
@@ -10618,13 +10615,11 @@ static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_
 		logretries++;
 		if (!valid) {
 			if (skipuser || logretries >= max_logins) {
-				ast_test_suite_event_notify("PLAYBACK", "Message: vm-incorrect");
 				if (ast_streamfile(chan, "vm-incorrect", ast_channel_language(chan))) {
 					ast_log(AST_LOG_WARNING, "Unable to stream incorrect message\n");
 					return -1;
 				}
 			} else {
-				ast_test_suite_event_notify("PLAYBACK", "Message: vm-incorrect-mailbox");
 				if (useadsi)
 					adsi_login(chan);
 				if (ast_streamfile(chan, "vm-incorrect-mailbox", ast_channel_language(chan))) {
diff --git a/asterisk-11.12.0-summary.html b/asterisk-11.12.0-summary.html
deleted file mode 100644
index 0503a58..0000000
--- a/asterisk-11.12.0-summary.html
+++ /dev/null
@@ -1,180 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Release Summary - asterisk-11.12.0</title></head>
-<body>
-<h1 align="center"><a name="top">Release Summary</a></h1>
-<h3 align="center">asterisk-11.12.0</h3>
-<h3 align="center">Date: 2014-08-19</h3>
-<h3 align="center"><asteriskteam at digium.com></h3>
-<hr/>
-<h2 align="center">Table of Contents</h2>
-<ol>
-   <li><a href="#summary">Summary</a></li>
-   <li><a href="#contributors">Contributors</a></li>
-   <li><a href="#issues">Closed Issues</a></li>
-   <li><a href="#commits">Other Changes</a></li>
-   <li><a href="#diffstat">Diffstat</a></li>
-</ol>
-<hr/>
-<a name="summary"><h2 align="center">Summary</h2></a>
-<center><a href="#top">[Back to Top]</a></center><br/><p>This release includes only bug fixes.  The changes included were made only to address problems that have been identified in this release series.  Users should be able to safely upgrade to this version if this release series is already in use.  Users considering upgrading from a previous release series are strongly encouraged to review the UPGRADE.txt document as well as the CHANGES document for information about upgrading to this r [...]
-<p>The data in this summary reflects changes that have been made since the previous release, asterisk-11.11.0.</p>
-<hr/>
-<a name="contributors"><h2 align="center">Contributors</h2></a>
-<center><a href="#top">[Back to Top]</a></center><br/><p>This table lists the people who have submitted code, those that have tested patches, as well as those that reported issues on the issue tracker that were resolved in this release.  For coders, the number is how many of their patches (of any size) were committed into this release.  For testers, the number is the number of times their name was listed as assisting with testing a patch.  Finally, for reporters, the number is the number [...]
-<table width="100%" border="0">
-<tr>
-<td width="33%"><h3>Coders</h3></td>
-<td width="33%"><h3>Testers</h3></td>
-<td width="33%"><h3>Reporters</h3></td>
-</tr>
-<tr valign="top">
-<td>
-3 coreyfarrell<br/>
-3 rmudgett<br/>
-2 mjordan<br/>
-2 sgriepentrog<br/>
-2 wdoekes<br/>
-1 Elazar Broad<br/>
-1 gtjoseph<br/>
-1 jrose<br/>
-1 kmoore<br/>
-1 newtonr<br/>
-1 qwell<br/>
-</td>
-<td>
-1 Arnd Schmitter<br/>
-1 George Joseph<br/>
-1 JoshE<br/>
-1 Rusty Newton<br/>
-</td>
-<td>
-2 mjordan<br/>
-1 arnd<br/>
-1 coreyfarrell<br/>
-1 dennis.guse<br/>
-1 igorg<br/>
-1 rnewton<br/>
-1 stephane.chazelas<br/>
-</td>
-</tr>
-</table>
-<hr/>
-<a name="issues"><h2 align="center">Closed Issues</h2></a>
-<center><a href="#top">[Back to Top]</a></center><br/><p>This is a list of all issues from the issue tracker that were closed by changes that went into this release.</p>
-<h3>Category: Addons/chan_ooh323</h3><br/>
-<a href="https://issues.asterisk.org/jira/browse/ASTERISK-23814">ASTERISK-23814</a>: No call started after peer dialed<br/>
-Revision: <a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=419375">419375</a><br/>
-Reporter: igorg<br/>
-Coders: qwell<br/>
-<br/>
-<h3>Category: Channels/chan_sip/Subscriptions</h3><br/>
-<a href="https://issues.asterisk.org/jira/browse/ASTERISK-24087">ASTERISK-24087</a>: [patch]chan_sip: sip_subscribe_mwi_destroy should not call sip_destroy<br/>
-Revision: <a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=419441">419441</a><br/>
-Reporter: coreyfarrell<br/>
-Coders: coreyfarrell<br/>
-<br/>
-<h3>Category: Channels/chan_sip/TCP-TLS</h3><br/>
-<a href="https://issues.asterisk.org/jira/browse/ASTERISK-18345">ASTERISK-18345</a>: [patch] sips connection dropped by asterisk with a large INVITE<br/>
-Revision: <a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=420435">420435</a><br/>
-Reporter: stephane.chazelas<br/>
-Coders: Elazar Broad<br/>
-<br/>
-<h3>Category: Core/ManagerInterface</h3><br/>
-<a href="https://issues.asterisk.org/jira/browse/ASTERISK-21178">ASTERISK-21178</a>: Improve documentation for manager command Getvar, Setvar<br/>
-Revision: <a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=419943">419943</a><br/>
-Reporter: rnewton<br/>
-Testers: Rusty Newton<br/>
-Coders: newtonr<br/>
-<br/>
-<a href="https://issues.asterisk.org/jira/browse/ASTERISK-23985">ASTERISK-23985</a>: PresenceState Action response does not contain ActionID; duplicates Message Header<br/>
-Revision: <a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=418713">418713</a><br/>
-Reporter: mjordan<br/>
-Coders: mjordan<br/>
-<br/>
-<h3>Category: Documentation</h3><br/>
-<a href="https://issues.asterisk.org/jira/browse/ASTERISK-21178">ASTERISK-21178</a>: Improve documentation for manager command Getvar, Setvar<br/>
-Revision: <a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=419943">419943</a><br/>
-Reporter: rnewton<br/>
-Testers: Rusty Newton<br/>
-Coders: newtonr<br/>
-<br/>
-<h3>Category: Functions/func_uri</h3><br/>
-<a href="https://issues.asterisk.org/jira/browse/ASTERISK-23911">ASTERISK-23911</a>: URIENCODE/URIDECODE: WARNING about passing an empty string is a bit over zealous<br/>
-Revision: <a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=418649">418649</a><br/>
-Reporter: mjordan<br/>
-Coders: jrose<br/>
-<br/>
-<h3>Category: PBX/pbx_lua</h3><br/>
-<a href="https://issues.asterisk.org/jira/browse/ASTERISK-23818">ASTERISK-23818</a>: PBX_Lua: after asterisk startup module is loaded, but dialplan not available<br/>
-Revision: <a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=420147">420147</a><br/>
-Reporter: dennis.guse<br/>
-Testers: George Joseph<br/>
-Coders: gtjoseph<br/>
-<br/>
-<h3>Category: Utilities/General</h3><br/>
-<a href="https://issues.asterisk.org/jira/browse/ASTERISK-23508">ASTERISK-23508</a>: Memory Corruption in __ast_string_field_ptr_build_va<br/>
-Revision: <a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=420715">420715</a><br/>
-Reporter: arnd<br/>
-Testers: Arnd Schmitter, JoshE<br/>
-Coders: wdoekes<br/>
-<br/>
-<hr/>
-<a name="commits"><h2 align="center">Commits Not Associated with an Issue</h2></a>
-<center><a href="#top">[Back to Top]</a></center><br/><p>This is a list of all changes that went into this release that did not directly close an issue from the issue tracker.  The commits may have been marked as being related to an issue.  If that is the case, the issue numbers are listed here, as well.</p>
-<table width="100%" border="1">
-<tr><td><b>Revision</b></td><td><b>Author</b></td><td><b>Summary</b></td><td><b>Issues Referenced</b></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=418262">418262</a></td><td>rmudgett</td><td>chan_dahdi/sig_pri: Fix type mismatch in the idledial feature's channel creation.</td>
-<td></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=418323">418323</a></td><td>mjordan</td><td>include/asterisk/xmpp.h: Convert indentation to tabs</td>
-<td></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=418366">418366</a></td><td>sgriepentrog</td><td>config: inform config hook of change when writing file</td>
-<td></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=418465">418465</a></td><td>coreyfarrell</td><td>Fix minor reference leaks in app_skel and TEST_FRAMEWORK</td>
-<td></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=418505">418505</a></td><td>coreyfarrell</td><td>astobj2: work around REF_DEBUG race which causes out of order log entries</td>
-<td></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=419162">419162</a></td><td>kmoore</td><td>Fix more dev-mode build issues</td>
-<td></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=419284">419284</a></td><td>sgriepentrog</td><td>app_voicemail: use a consistent generator string</td>
-<td></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=419685">419685</a></td><td>rmudgett</td><td>datastores: Audit ast_channel_datastore_remove usage.</td>
-<td></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=420054">420054</a></td><td>rmudgett</td><td>format.c: Add reason comments for the format_list ordering.</td>
-<td></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/branches/11?view=revision&revision=420655">420655</a></td><td>wdoekes</td><td>tcptls: Avoid compiler warning on non-dev-mode.</td>
-<td></td></tr></table>
-<hr/>
-<a name="diffstat"><h2 align="center">Diffstat Results</h2></a>
-<center><a href="#top">[Back to Top]</a></center><br/><p>This is a summary of the changes to the source code that went into this release that was generated using the diffstat utility.</p>
-<pre>
-addons/chan_ooh323.c              |   32 +++---
-addons/ooh323c/src/ooq931.c       |   12 +-
-addons/ooh323c/src/printHandler.c |    2
-apps/app_meetme.c                 |    8 -
-apps/app_queue.c                  |    2
-apps/app_skel.c                   |    1
-apps/app_speech_utils.c           |   56 +++++++----
-apps/app_voicemail.c              |    4
-channels/chan_sip.c               |  185 +++-----------------------------------
-channels/sig_pri.c                |    8 -
-contrib/scripts/refcounter.py     |   17 ++-
-funcs/func_frame_trace.c          |    1
-funcs/func_jitterbuffer.c         |    1
-funcs/func_uri.c                  |    8 -
-include/asterisk/xmpp.h           |   84 ++++++++---------
-main/astobj2.c                    |   15 +--
-main/config.c                     |    7 +
-main/features.c                   |    8 +
-main/format.c                     |   20 +++-
-main/manager.c                    |   20 ++--
-main/pbx.c                        |    5 +
-main/tcptls.c                     |    5 +
-main/utils.c                      |   18 +++
-pbx/pbx_lua.c                     |    2
-res/res_jabber.c                  |    2
-tests/test_abstract_jb.c          |   11 ++
-tests/test_aoc.c                  |    2
-tests/test_astobj2.c              |    2
-tests/test_astobj2_thrash.c       |    2
-tests/test_config.c               |   14 +-
-tests/test_event.c                |   18 +--
-tests/test_format_api.c           |    2
-tests/test_hashtab_thrash.c       |    2
-tests/test_logger.c               |   24 ++--
-tests/test_voicemail_api.c        |   12 +-
-35 files changed, 273 insertions(+), 339 deletions(-)
-</pre><br/>
-<hr/>
-</body>
-</html>
diff --git a/asterisk-11.12.0-summary.txt b/asterisk-11.12.0-summary.txt
deleted file mode 100644
index 9fd3583..0000000
--- a/asterisk-11.12.0-summary.txt
+++ /dev/null
@@ -1,237 +0,0 @@
-                                Release Summary
-
-                                asterisk-11.12.0
-
-                                Date: 2014-08-19
-
-                           <asteriskteam at digium.com>
-
-     ----------------------------------------------------------------------
-
-                               Table of Contents
-
-    1. Summary
-    2. Contributors
-    3. Closed Issues
-    4. Other Changes
-    5. Diffstat
-
-     ----------------------------------------------------------------------
-
-                                    Summary
-
-                                 [Back to Top]
-
-   This release includes only bug fixes. The changes included were made only
-   to address problems that have been identified in this release series.
-   Users should be able to safely upgrade to this version if this release
-   series is already in use. Users considering upgrading from a previous
-   release series are strongly encouraged to review the UPGRADE.txt document
-   as well as the CHANGES document for information about upgrading to this
-   release series.
-
-   The data in this summary reflects changes that have been made since the
-   previous release, asterisk-11.11.0.
-
-     ----------------------------------------------------------------------
-
-                                  Contributors
-
-                                 [Back to Top]
-
-   This table lists the people who have submitted code, those that have
-   tested patches, as well as those that reported issues on the issue tracker
-   that were resolved in this release. For coders, the number is how many of
-   their patches (of any size) were committed into this release. For testers,
-   the number is the number of times their name was listed as assisting with
-   testing a patch. Finally, for reporters, the number is the number of
-   issues that they reported that were closed by commits that went into this
-   release.
-
-     Coders                   Testers                  Reporters              
-   3 coreyfarrell           1 Arnd Schmitter         2 mjordan                
-   3 rmudgett               1 George Joseph          1 arnd                   
-   2 mjordan                1 JoshE                  1 coreyfarrell           
-   2 sgriepentrog           1 Rusty Newton           1 dennis.guse            
-   2 wdoekes                                         1 igorg                  
-   1 Elazar Broad                                    1 rnewton                
-   1 gtjoseph                                        1 stephane.chazelas      
-   1 jrose                  
-   1 kmoore                 
-   1 newtonr                
-   1 qwell                  
-
-     ----------------------------------------------------------------------
-
-                                 Closed Issues
-
-                                 [Back to Top]
-
-   This is a list of all issues from the issue tracker that were closed by
-   changes that went into this release.
-
-  Category: Addons/chan_ooh323
-
-   ASTERISK-23814: No call started after peer dialed
-   Revision: 419375
-   Reporter: igorg
-   Coders: qwell
-
-  Category: Channels/chan_sip/Subscriptions
-
-   ASTERISK-24087: [patch]chan_sip: sip_subscribe_mwi_destroy should not call
-   sip_destroy
-   Revision: 419441
-   Reporter: coreyfarrell
-   Coders: coreyfarrell
-
-  Category: Channels/chan_sip/TCP-TLS
-
-   ASTERISK-18345: [patch] sips connection dropped by asterisk with a large
-   INVITE
-   Revision: 420435
-   Reporter: stephane.chazelas
-   Coders: Elazar Broad
-
-  Category: Core/ManagerInterface
-
-   ASTERISK-21178: Improve documentation for manager command Getvar, Setvar
-   Revision: 419943
-   Reporter: rnewton
-   Testers: Rusty Newton
-   Coders: newtonr
-
-   ASTERISK-23985: PresenceState Action response does not contain ActionID;
-   duplicates Message Header
-   Revision: 418713
-   Reporter: mjordan
-   Coders: mjordan
-
-  Category: Documentation
-
-   ASTERISK-21178: Improve documentation for manager command Getvar, Setvar
-   Revision: 419943
-   Reporter: rnewton
-   Testers: Rusty Newton
-   Coders: newtonr
-
-  Category: Functions/func_uri
-
-   ASTERISK-23911: URIENCODE/URIDECODE: WARNING about passing an empty string
-   is a bit over zealous
-   Revision: 418649
-   Reporter: mjordan
-   Coders: jrose
-
-  Category: PBX/pbx_lua
-
-   ASTERISK-23818: PBX_Lua: after asterisk startup module is loaded, but
-   dialplan not available
-   Revision: 420147
-   Reporter: dennis.guse
-   Testers: George Joseph
-   Coders: gtjoseph
-
-  Category: Utilities/General
-
-   ASTERISK-23508: Memory Corruption in __ast_string_field_ptr_build_va
-   Revision: 420715
-   Reporter: arnd
-   Testers: Arnd Schmitter, JoshE
-   Coders: wdoekes
-
-     ----------------------------------------------------------------------
-
-                      Commits Not Associated with an Issue
-
-                                 [Back to Top]
-
-   This is a list of all changes that went into this release that did not
-   directly close an issue from the issue tracker. The commits may have been
-   marked as being related to an issue. If that is the case, the issue
-   numbers are listed here, as well.
-
-   +------------------------------------------------------------------------+
-   | Revision | Author       | Summary                         | Issues     |
-   |          |              |                                 | Referenced |
-   |----------+--------------+---------------------------------+------------|
-   |          |              | chan_dahdi/sig_pri: Fix type    |            |
-   | 418262   | rmudgett     | mismatch in the idledial        |            |
-   |          |              | feature's channel creation.     |            |
-   |----------+--------------+---------------------------------+------------|
-   | 418323   | mjordan      | include/asterisk/xmpp.h:        |            |
-   |          |              | Convert indentation to tabs     |            |
-   |----------+--------------+---------------------------------+------------|
-   | 418366   | sgriepentrog | config: inform config hook of   |            |
-   |          |              | change when writing file        |            |
-   |----------+--------------+---------------------------------+------------|
-   | 418465   | coreyfarrell | Fix minor reference leaks in    |            |
-   |          |              | app_skel and TEST_FRAMEWORK     |            |
-   |----------+--------------+---------------------------------+------------|
-   |          |              | astobj2: work around REF_DEBUG  |            |
-   | 418505   | coreyfarrell | race which causes out of order  |            |
-   |          |              | log entries                     |            |
-   |----------+--------------+---------------------------------+------------|
-   | 419162   | kmoore       | Fix more dev-mode build issues  |            |
-   |----------+--------------+---------------------------------+------------|
-   | 419284   | sgriepentrog | app_voicemail: use a consistent |            |
-   |          |              | generator string                |            |
-   |----------+--------------+---------------------------------+------------|
-   |          |              | datastores: Audit               |            |
-   | 419685   | rmudgett     | ast_channel_datastore_remove    |            |
-   |          |              | usage.                          |            |
-   |----------+--------------+---------------------------------+------------|
-   | 420054   | rmudgett     | format.c: Add reason comments   |            |
-   |          |              | for the format_list ordering.   |            |
-   |----------+--------------+---------------------------------+------------|
-   | 420655   | wdoekes      | tcptls: Avoid compiler warning  |            |
-   |          |              | on non-dev-mode.                |            |
-   +------------------------------------------------------------------------+
-
-     ----------------------------------------------------------------------
-
-                                Diffstat Results
-
-                                 [Back to Top]
-
-   This is a summary of the changes to the source code that went into this
-   release that was generated using the diffstat utility.
-
- addons/chan_ooh323.c              |   32 +++---
- addons/ooh323c/src/ooq931.c       |   12 +-
- addons/ooh323c/src/printHandler.c |    2
- apps/app_meetme.c                 |    8 -
- apps/app_queue.c                  |    2
- apps/app_skel.c                   |    1
- apps/app_speech_utils.c           |   56 +++++++----
- apps/app_voicemail.c              |    4
- channels/chan_sip.c               |  185 +++-----------------------------------
- channels/sig_pri.c                |    8 -
- contrib/scripts/refcounter.py     |   17 ++-
- funcs/func_frame_trace.c          |    1
- funcs/func_jitterbuffer.c         |    1
- funcs/func_uri.c                  |    8 -
- include/asterisk/xmpp.h           |   84 ++++++++---------
- main/astobj2.c                    |   15 +--
- main/config.c                     |    7 +
- main/features.c                   |    8 +
- main/format.c                     |   20 +++-
- main/manager.c                    |   20 ++--
- main/pbx.c                        |    5 +
- main/tcptls.c                     |    5 +
- main/utils.c                      |   18 +++
- pbx/pbx_lua.c                     |    2
- res/res_jabber.c                  |    2
- tests/test_abstract_jb.c          |   11 ++
- tests/test_aoc.c                  |    2
- tests/test_astobj2.c              |    2
- tests/test_astobj2_thrash.c       |    2
- tests/test_config.c               |   14 +-
- tests/test_event.c                |   18 +--
- tests/test_format_api.c           |    2
- tests/test_hashtab_thrash.c       |    2
- tests/test_logger.c               |   24 ++--
- tests/test_voicemail_api.c        |   12 +-
- 35 files changed, 273 insertions(+), 339 deletions(-)
-
-     ----------------------------------------------------------------------
diff --git a/asterisk-11.13.1-summary.html b/asterisk-11.13.1-summary.html
new file mode 100644
index 0000000..ea84b98
--- /dev/null
+++ b/asterisk-11.13.1-summary.html
@@ -0,0 +1,65 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Release Summary - asterisk-11.13.1</title></head>
+<body>
+<h1 align="center"><a name="top">Release Summary</a></h1>
+<h3 align="center">asterisk-11.13.1</h3>
+<h3 align="center">Date: 2014-10-20</h3>
+<h3 align="center"><asteriskteam at digium.com></h3>
+<hr/>
+<h2 align="center">Table of Contents</h2>
+<ol>
+   <li><a href="#summary">Summary</a></li>
+   <li><a href="#contributors">Contributors</a></li>
+   <li><a href="#commits">Other Changes</a></li>
+   <li><a href="#diffstat">Diffstat</a></li>
+</ol>
+<hr/>
+<a name="summary"><h2 align="center">Summary</h2></a>
+<center><a href="#top">[Back to Top]</a></center><br/><p>This release has been made to address one or more security vulnerabilities that have been identified.  A security advisory document has been published for each vulnerability that includes additional information.  Users of versions of Asterisk that are affected are strongly encouraged to review the advisories and determine what action they should take to protect their systems from these issues.</p>
+<p>Security Advisories: <a href="http://downloads.asterisk.org/pub/security/AST-2014-011.html">AST-2014-011</a></p>
+<p>The data in this summary reflects changes that have been made since the previous release, asterisk-11.13.0.</p>
+<hr/>
+<a name="contributors"><h2 align="center">Contributors</h2></a>
+<center><a href="#top">[Back to Top]</a></center><br/><p>This table lists the people who have submitted code, those that have tested patches, as well as those that reported issues on the issue tracker that were resolved in this release.  For coders, the number is how many of their patches (of any size) were committed into this release.  For testers, the number is the number of times their name was listed as assisting with testing a patch.  Finally, for reporters, the number is the number [...]
+<table width="100%" border="0">
+<tr>
+<td width="33%"><h3>Coders</h3></td>
+<td width="33%"><h3>Testers</h3></td>
+<td width="33%"><h3>Reporters</h3></td>
+</tr>
+<tr valign="top">
+<td>
+3 bebuild<br/>
+</td>
+<td>
+</td>
+<td>
+</td>
+</tr>
+</table>
+<hr/>
+<a name="commits"><h2 align="center">Commits Not Associated with an Issue</h2></a>
+<center><a href="#top">[Back to Top]</a></center><br/><p>This is a list of all changes that went into this release that did not directly close an issue from the issue tracker.  The commits may have been marked as being related to an issue.  If that is the case, the issue numbers are listed here, as well.</p>
+<table width="100%" border="1">
+<tr><td><b>Revision</b></td><td><b>Author</b></td><td><b>Summary</b></td><td><b>Issues Referenced</b></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/tags/11.13.1?view=revision&revision=425989">425989</a></td><td>bebuild</td><td>Create 11.13.1</td>
+<td></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/tags/11.13.1?view=revision&revision=426002">426002</a></td><td>bebuild</td><td>Update .version, remove summaries</td>
+<td></td></tr><tr><td><a href="http://svn.digium.com/view/asterisk/tags/11.13.1?view=revision&revision=426019">426019</a></td><td>bebuild</td><td>Merge 425986</td>
+<td></td></tr></table>
+<hr/>
+<a name="diffstat"><h2 align="center">Diffstat Results</h2></a>
+<center><a href="#top">[Back to Top]</a></center><br/><p>This is a summary of the changes to the source code that went into this release that was generated using the diffstat utility.</p>
+<pre>
+.version                      |    2
+ChangeLog                     |   26 +++
+UPGRADE.txt                   |   12 +
+asterisk-11.13.0-summary.html |  237 -------------------------------
+asterisk-11.13.0-summary.txt  |  321 ------------------------------------------
+main/tcptls.c                 |   22 ++
+res/res_jabber.c              |    5
+res/res_xmpp.c                |    6
+8 files changed, 65 insertions(+), 566 deletions(-)
+</pre><br/>
+<hr/>
+</body>
+</html>
diff --git a/asterisk-11.13.1-summary.txt b/asterisk-11.13.1-summary.txt
new file mode 100644
index 0000000..a57fd63
--- /dev/null
+++ b/asterisk-11.13.1-summary.txt
@@ -0,0 +1,95 @@
+                                Release Summary
+
+                                asterisk-11.13.1
+
+                                Date: 2014-10-20
+
+                           <asteriskteam at digium.com>
+
+     ----------------------------------------------------------------------
+
+                               Table of Contents
+
+    1. Summary
+    2. Contributors
+    3. Other Changes
+    4. Diffstat
+
+     ----------------------------------------------------------------------
+
+                                    Summary
+
+                                 [Back to Top]
+
+   This release has been made to address one or more security vulnerabilities
+   that have been identified. A security advisory document has been published
+   for each vulnerability that includes additional information. Users of
+   versions of Asterisk that are affected are strongly encouraged to review
+   the advisories and determine what action they should take to protect their
+   systems from these issues.
+
+   Security Advisories: AST-2014-011
+
+   The data in this summary reflects changes that have been made since the
+   previous release, asterisk-11.13.0.
+
+     ----------------------------------------------------------------------
+
+                                  Contributors
+
+                                 [Back to Top]
+
+   This table lists the people who have submitted code, those that have
+   tested patches, as well as those that reported issues on the issue tracker
+   that were resolved in this release. For coders, the number is how many of
+   their patches (of any size) were committed into this release. For testers,
+   the number is the number of times their name was listed as assisting with
+   testing a patch. Finally, for reporters, the number is the number of
+   issues that they reported that were closed by commits that went into this
+   release.
+
+     Coders                   Testers                  Reporters              
+   3 bebuild                
+
+     ----------------------------------------------------------------------
+
+                      Commits Not Associated with an Issue
+
+                                 [Back to Top]
+
+   This is a list of all changes that went into this release that did not
+   directly close an issue from the issue tracker. The commits may have been
+   marked as being related to an issue. If that is the case, the issue
+   numbers are listed here, as well.
+
+   +------------------------------------------------------------------------+
+   | Revision | Author  | Summary                       | Issues Referenced |
+   |----------+---------+-------------------------------+-------------------|
+   | 425989   | bebuild | Create 11.13.1                |                   |
+   |----------+---------+-------------------------------+-------------------|
+   | 426002   | bebuild | Update .version, remove       |                   |
+   |          |         | summaries                     |                   |
+   |----------+---------+-------------------------------+-------------------|
+   | 426019   | bebuild | Merge 425986                  |                   |
+   +------------------------------------------------------------------------+
+
+     ----------------------------------------------------------------------
+
+                                Diffstat Results
+
+                                 [Back to Top]
+
+   This is a summary of the changes to the source code that went into this
+   release that was generated using the diffstat utility.
+
+ .version                      |    2
+ ChangeLog                     |   26 +++
+ UPGRADE.txt                   |   12 +
+ asterisk-11.13.0-summary.html |  237 -------------------------------
+ asterisk-11.13.0-summary.txt  |  321 ------------------------------------------
+ main/tcptls.c                 |   22 ++
+ res/res_jabber.c              |    5
+ res/res_xmpp.c                |    6
+ 8 files changed, 65 insertions(+), 566 deletions(-)
+
+     ----------------------------------------------------------------------
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index e78bedd..9c99146 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -38,7 +38,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 413587 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 422274 $")
 
 #include <sys/mman.h>
 #include <dirent.h>
@@ -612,6 +612,8 @@ struct iax2_registry {
 	struct sockaddr_in us;			/*!< Who the server thinks we are */
 	struct ast_dnsmgr_entry *dnsmgr;	/*!< DNS refresh manager */
 	AST_LIST_ENTRY(iax2_registry) entry;
+	int port;
+	char hostname[];
 };
 
 static AST_LIST_HEAD_STATIC(registrations, iax2_registry);
@@ -8480,6 +8482,17 @@ static int iax2_do_register(struct iax2_registry *reg);
 static void __iax2_do_register_s(const void *data)
 {
 	struct iax2_registry *reg = (struct iax2_registry *)data;
+
+	if (ast_sockaddr_isnull(&reg->addr)) {
+		reg->addr.ss.ss_family = AST_AF_UNSPEC;
+		ast_dnsmgr_lookup(reg->hostname, &reg->addr, &reg->dnsmgr, srvlookup ? "_iax._udp" : NULL);
+		if (!ast_sockaddr_port(&reg->addr)) {
+			ast_sockaddr_set_port(&reg->addr, reg->port);
+		} else {
+			reg->port = ast_sockaddr_port(&reg->addr);
+		}
+	}
+
 	reg->expire = -1;
 	iax2_do_register(reg);
 }
@@ -8707,8 +8720,9 @@ static int iax2_append_register(const char *hostname, const char *username,
 {
 	struct iax2_registry *reg;
 
-	if (!(reg = ast_calloc(1, sizeof(*reg))))
+	if (!(reg = ast_calloc(1, sizeof(*reg) + strlen(hostname) + 1))) {
 		return -1;
+	}
 
 	reg->addr.ss.ss_family = AF_INET;
 	if (ast_dnsmgr_lookup(hostname, &reg->addr, &reg->dnsmgr, srvlookup ? "_iax._udp" : NULL) < 0) {
@@ -8717,18 +8731,29 @@ static int iax2_append_register(const char *hostname, const char *username,
 	}
 
 	ast_copy_string(reg->username, username, sizeof(reg->username));
+	strcpy(reg->hostname, hostname); /* Note: This is safe */
 
-	if (secret)
+	if (secret) {
 		ast_copy_string(reg->secret, secret, sizeof(reg->secret));
+	}
 
 	reg->expire = -1;
 	reg->refresh = IAX_DEFAULT_REG_EXPIRE;
-	ast_sockaddr_set_port(&reg->addr, porta ? atoi(porta) : IAX_DEFAULT_PORTNO);
+
+	reg->port = ast_sockaddr_port(&reg->addr);
+
+	if (!porta && !reg->port) {
+		reg->port = IAX_DEFAULT_PORTNO;
+	} else if (porta) {
+		sscanf(porta, "%5d", &reg->port);
+	}
+
+	ast_sockaddr_set_port(&reg->addr, reg->port);
 
 	AST_LIST_LOCK(&registrations);
 	AST_LIST_INSERT_HEAD(&registrations, reg, entry);
 	AST_LIST_UNLOCK(&registrations);
-	
+
 	return 0;
 }
 
@@ -12200,6 +12225,9 @@ static int iax2_do_register(struct iax2_registry *reg)
 			(5 * reg->refresh / 6) * 1000, iax2_do_register_s, reg);
 		return -1;
 	}
+	if (!ast_sockaddr_port(&reg->addr) && reg->port) {
+		ast_sockaddr_set_port(&reg->addr, reg->port);
+	}
 
 	if (!reg->callno) {
 		struct sockaddr_in reg_addr;
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index a172944..67ccc22 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -210,7 +210,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 420435 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 422113 $")
 
 #include <signal.h>
 #include <sys/signal.h>
@@ -12385,6 +12385,7 @@ static int add_rpid(struct sip_request *req, struct sip_pvt *p)
 {
 	struct ast_str *tmp = ast_str_alloca(256);
 	char tmp2[256];
+	char lid_name_buf[128];
 	char *lid_num;
 	char *lid_name;
 	int lid_pres;
@@ -12410,6 +12411,7 @@ static int add_rpid(struct sip_request *req, struct sip_pvt *p)
 	if (!lid_name) {
 		lid_name = lid_num;
 	}
+	ast_escape_quoted(lid_name, lid_name_buf, sizeof(lid_name_buf));
 	lid_pres = ast_party_id_presentation(&connected_id);
 
 	if (((lid_pres & AST_PRES_RESTRICTION) != AST_PRES_ALLOWED) &&
@@ -12433,7 +12435,7 @@ static int add_rpid(struct sip_request *req, struct sip_pvt *p)
 		if (ast_test_flag(&p->flags[1], SIP_PAGE2_TRUST_ID_OUTBOUND) != SIP_PAGE2_TRUST_ID_OUTBOUND_LEGACY) {
 			/* trust_id_outbound = yes - Always give full information even if it's private, but append a privacy header
 			 * When private data is included */
-			ast_str_set(&tmp, -1, "\"%s\" <sip:%s@%s>", lid_name, lid_num, fromdomain);
+			ast_str_set(&tmp, -1, "\"%s\" <sip:%s@%s>", lid_name_buf, lid_num, fromdomain);
 			if ((lid_pres & AST_PRES_RESTRICTION) != AST_PRES_ALLOWED) {
 				add_header(req, "Privacy", "id");
 			}
@@ -12441,14 +12443,14 @@ static int add_rpid(struct sip_request *req, struct sip_pvt *p)
 			/* trust_id_outbound = legacy - behave in a non RFC-3325 compliant manner and send anonymized data when
 			 * when handling private data. */
 			if ((lid_pres & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED) {
-				ast_str_set(&tmp, -1, "\"%s\" <sip:%s@%s>", lid_name, lid_num, fromdomain);
+				ast_str_set(&tmp, -1, "\"%s\" <sip:%s@%s>", lid_name_buf, lid_num, fromdomain);
 			} else {
 				ast_str_set(&tmp, -1, "%s", anonymous_string);
 			}
 		}
 		add_header(req, "P-Asserted-Identity", ast_str_buffer(tmp));
 	} else {
-		ast_str_set(&tmp, -1, "\"%s\" <sip:%s@%s>;party=%s", lid_name, lid_num, fromdomain, p->outgoing_call ? "calling" : "called");
+		ast_str_set(&tmp, -1, "\"%s\" <sip:%s@%s>;party=%s", lid_name_buf, lid_num, fromdomain, p->outgoing_call ? "calling" : "called");
 
 		switch (lid_pres) {
 		case AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED:
@@ -12538,12 +12540,7 @@ static void add_ice_to_sdp(struct ast_rtp_instance *instance, struct ast_str **a
 		ast_str_append(a_buf, 0, "a=candidate:%s %u %s %d ", candidate->foundation, candidate->id, candidate->transport, candidate->priority);
 		ast_str_append(a_buf, 0, "%s ", ast_sockaddr_stringify_host(&candidate->address));
 
-		if (candidate->type == AST_RTP_ICE_CANDIDATE_TYPE_SRFLX
-			&& candidate->id == AST_RTP_ICE_COMPONENT_RTCP) {
-			ast_str_append(a_buf, 0, "%d typ ", ast_sockaddr_port(&candidate->address) + 1);
-		} else {
-			ast_str_append(a_buf, 0, "%s typ ", ast_sockaddr_stringify_port(&candidate->address));
-		}
+		ast_str_append(a_buf, 0, "%s typ ", ast_sockaddr_stringify_port(&candidate->address));
 
 		if (candidate->type == AST_RTP_ICE_CANDIDATE_TYPE_HOST) {
 			ast_str_append(a_buf, 0, "host");
@@ -13795,7 +13792,7 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmetho
 		ast_uri_encode(l, tmp_l, sizeof(tmp_l), ast_uri_sip_user);
 	}
 
-	ourport = (p->fromdomainport) ? p->fromdomainport : ast_sockaddr_port(&p->ourip);
+	ourport = (p->fromdomainport && (p->fromdomainport != STANDARD_SIP_PORT)) ? p->fromdomainport : ast_sockaddr_port(&p->ourip);
 
 	/* If a caller id name was specified, add a display name. */
 	if (cid_has_name || !cid_has_num) {
@@ -13928,8 +13925,11 @@ static void add_diversion(struct sip_request *req, struct sip_pvt *pvt)
 		snprintf(header_text, sizeof(header_text), "<sip:%s@%s>;reason=%s", diverting_from.number.str,
 				ast_sockaddr_stringify_host_remote(&pvt->ourip), reason);
 	} else {
+		char diverting_name_buf[128];
+
+		ast_escape_quoted(diverting_from.name.str, diverting_name_buf, sizeof(diverting_name_buf));
 		snprintf(header_text, sizeof(header_text), "\"%s\" <sip:%s@%s>;reason=%s",
-				diverting_from.name.str, diverting_from.number.str,
+				diverting_name_buf, diverting_from.number.str,
 				ast_sockaddr_stringify_host_remote(&pvt->ourip), reason);
 	}
 
@@ -14737,7 +14737,7 @@ static int transmit_notify_with_mwi(struct sip_pvt *p, int newmsgs, int oldmsgs,
 {
 	struct sip_request req;
 	struct ast_str *out = ast_str_alloca(500);
-	int ourport = (p->fromdomainport) ? p->fromdomainport : ast_sockaddr_port(&p->ourip);
+	int ourport = (p->fromdomainport && (p->fromdomainport != STANDARD_SIP_PORT)) ? p->fromdomainport : ast_sockaddr_port(&p->ourip);
 	const char *domain;
 	const char *exten = S_OR(vmexten, default_vmexten);
 
@@ -18604,7 +18604,10 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req, struct a
 	from = (char *) get_calleridname(from, from_name, sizeof(from_name));
 	from = get_in_brackets(from);
 	if (from_name[0]) {
-		res |= ast_msg_set_from(msg, "\"%s\" <%s>", from_name, from);
+		char from_buf[128];
+
+		ast_escape_quoted(from_name, from_buf, sizeof(from_buf));
+		res |= ast_msg_set_from(msg, "\"%s\" <%s>", from_buf, from);
 	} else {
 		res |= ast_msg_set_from(msg, "<%s>", from);
 	}
diff --git a/configs/sip.conf.sample b/configs/sip.conf.sample
index 24f2e51..b2489dc 100644
--- a/configs/sip.conf.sample
+++ b/configs/sip.conf.sample
@@ -638,7 +638,9 @@ srvlookup=yes                   ; Enable DNS SRV lookups on outbound calls
 ;
 ;--------------------------- SIP DEBUGGING ---------------------------------------------------
 ;sipdebug = yes                 ; Turn on SIP debugging by default, from
-                                ; the moment the channel loads this configuration
+                                ; the moment the channel loads this configuration.
+                                ; NOTE: You cannot use the CLI to turn it off. You'll
+                                ; need to edit this and reload the config.
 ;recordhistory=yes              ; Record SIP history by default
                                 ; (see sip history / sip no history)
 ;dumphistory=yes                ; Dump SIP history at end of SIP dialogue
diff --git a/configure b/configure
index 2cf5f8d..0674ac5 100755
--- a/configure
+++ b/configure
@@ -1,12 +1,14 @@
 #! /bin/sh
 # From configure.ac Revision: 413765 .
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for asterisk trunk.
+# Generated by GNU Autoconf 2.68 for asterisk trunk.
 #
 # Report bugs to <https://issues.asterisk.org>.
 #
 #
-# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+# Foundation, Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -137,31 +139,6 @@ export LANGUAGE
 # CDPATH.
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
-# Use a proper internal environment variable to ensure we don't fall
-  # into an infinite loop, continuously re-executing ourselves.
-  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
-    _as_can_reexec=no; export _as_can_reexec;
-    # We cannot yet assume a decent shell, so we have to provide a
-# neutralization value for shells without unset; and this also
-# works around shells that cannot unset nonexistent variables.
-# Preserve -v and -x to the replacement shell.
-BASH_ENV=/dev/null
-ENV=/dev/null
-(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-case $- in # ((((
-  *v*x* | *x*v* ) as_opts=-vx ;;
-  *v* ) as_opts=-v ;;
-  *x* ) as_opts=-x ;;
-  * ) as_opts= ;;
-esac
-exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-# Admittedly, this is quite paranoid, since all the known shells bail
-# out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-as_fn_exit 255
-  fi
-  # We don't want this to propagate to other subprocesses.
-          { _as_can_reexec=; unset _as_can_reexec;}
 if test "x$CONFIG_SHELL" = x; then
   as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
@@ -195,8 +172,7 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
 else
   exitcode=1; echo positional parameters were not saved.
 fi
-test x\$exitcode = x0 || exit 1
-test -x / || exit 1"
+test x\$exitcode = x0 || exit 1"
   as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@@ -241,25 +217,21 @@ IFS=$as_save_IFS
 
 
       if test "x$CONFIG_SHELL" != x; then :
-  export CONFIG_SHELL
-             # We cannot yet assume a decent shell, so we have to provide a
-# neutralization value for shells without unset; and this also
-# works around shells that cannot unset nonexistent variables.
-# Preserve -v and -x to the replacement shell.
-BASH_ENV=/dev/null
-ENV=/dev/null
-(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-case $- in # ((((
-  *v*x* | *x*v* ) as_opts=-vx ;;
-  *v* ) as_opts=-v ;;
-  *x* ) as_opts=-x ;;
-  * ) as_opts= ;;
-esac
-exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-# Admittedly, this is quite paranoid, since all the known shells bail
-# out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-exit 255
+  # We cannot yet assume a decent shell, so we have to provide a
+	# neutralization value for shells without unset; and this also
+	# works around shells that cannot unset nonexistent variables.
+	# Preserve -v and -x to the replacement shell.
+	BASH_ENV=/dev/null
+	ENV=/dev/null
+	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+	export CONFIG_SHELL
+	case $- in # ((((
+	  *v*x* | *x*v* ) as_opts=-vx ;;
+	  *v* ) as_opts=-v ;;
+	  *x* ) as_opts=-x ;;
+	  * ) as_opts= ;;
+	esac
+	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
 fi
 
     if test x$as_have_required = xno; then :
@@ -362,14 +334,6 @@ $as_echo X"$as_dir" |
 
 
 } # as_fn_mkdir_p
-
-# as_fn_executable_p FILE
-# -----------------------
-# Test if FILE is an executable regular file.
-as_fn_executable_p ()
-{
-  test -f "$1" && test -x "$1"
-} # as_fn_executable_p
 # as_fn_append VAR VALUE
 # ----------------------
 # Append the text in VALUE to the end of the definition contained in VAR. Take
@@ -491,10 +455,6 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
   chmod +x "$as_me.lineno" ||
     { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
-  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
-  # already done that, so ensure we don't try to do so again and fall
-  # in an infinite loop.  This has already happened in practice.
-  _as_can_reexec=no; export _as_can_reexec
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
   # original and so on.  Autoconf is especially sensitive to this).
@@ -529,16 +489,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -pR'.
+    # In both cases, we have to default to `cp -p'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
+      as_ln_s='cp -p'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -pR'
+    as_ln_s='cp -p'
   fi
 else
-  as_ln_s='cp -pR'
+  as_ln_s='cp -p'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -550,8 +510,28 @@ else
   as_mkdir_p=false
 fi
 
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+	test -d "$1/.";
+      else
+	case $1 in #(
+	-*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -1791,6 +1771,8 @@ target=$target_alias
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
+    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used" >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -2136,9 +2118,9 @@ test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
 asterisk configure trunk
-generated by GNU Autoconf 2.69
+generated by GNU Autoconf 2.68
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2010 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 
@@ -2492,7 +2474,7 @@ $as_echo "$ac_try_echo"; } >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 test -x conftest$ac_exeext
+	 $as_test_x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -2706,8 +2688,7 @@ int
 main ()
 {
 static int test_array [1 - 2 * !(($2) >= 0)];
-test_array [0] = 0;
-return test_array [0];
+test_array [0] = 0
 
   ;
   return 0;
@@ -2723,8 +2704,7 @@ int
 main ()
 {
 static int test_array [1 - 2 * !(($2) <= $ac_mid)];
-test_array [0] = 0;
-return test_array [0];
+test_array [0] = 0
 
   ;
   return 0;
@@ -2750,8 +2730,7 @@ int
 main ()
 {
 static int test_array [1 - 2 * !(($2) < 0)];
-test_array [0] = 0;
-return test_array [0];
+test_array [0] = 0
 
   ;
   return 0;
@@ -2767,8 +2746,7 @@ int
 main ()
 {
 static int test_array [1 - 2 * !(($2) >= $ac_mid)];
-test_array [0] = 0;
-return test_array [0];
+test_array [0] = 0
 
   ;
   return 0;
@@ -2802,8 +2780,7 @@ int
 main ()
 {
 static int test_array [1 - 2 * !(($2) <= $ac_mid)];
-test_array [0] = 0;
-return test_array [0];
+test_array [0] = 0
 
   ;
   return 0;
@@ -2990,7 +2967,7 @@ $as_echo "$ac_try_echo"; } >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 test -x conftest$ac_exeext
+	 $as_test_x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -3044,7 +3021,7 @@ This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by asterisk $as_me trunk, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
 
@@ -3576,7 +3553,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3620,7 +3597,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4064,7 +4041,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-struct stat;
+#include <sys/types.h>
+#include <sys/stat.h>
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
@@ -4305,7 +4283,7 @@ do
     for ac_prog in grep ggrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_GREP" || continue
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
 # Check for GNU ac_path_GREP and select it if it is found.
   # Check for GNU $ac_path_GREP
 case `"$ac_path_GREP" --version 2>&1` in
@@ -4371,7 +4349,7 @@ do
     for ac_prog in egrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_EGREP" || continue
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
 # Check for GNU ac_path_EGREP and select it if it is found.
   # Check for GNU $ac_path_EGREP
 case `"$ac_path_EGREP" --version 2>&1` in
@@ -4578,8 +4556,8 @@ else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-#         define __EXTENSIONS__ 1
-          $ac_includes_default
+#	  define __EXTENSIONS__ 1
+	  $ac_includes_default
 int
 main ()
 {
@@ -4782,7 +4760,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_UNAME="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4825,7 +4803,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_ac_pt_UNAME="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4890,7 +4868,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4930,7 +4908,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CC="gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4982,7 +4960,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CXX="${ac_tool_prefix}g++"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5022,7 +5000,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CXX="g++"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5074,7 +5052,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_LD="${ac_tool_prefix}ld"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5114,7 +5092,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_LD="ld"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5166,7 +5144,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5206,7 +5184,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_RANLIB="ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5272,7 +5250,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5316,7 +5294,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CXX="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5795,7 +5773,7 @@ do
     for ac_prog in sed gsed; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_SED" || continue
+      { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
 # Check for GNU ac_path_SED and select it if it is found.
   # Check for GNU $ac_path_SED
 case `"$ac_path_SED" --version 2>&1` in
@@ -5980,7 +5958,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_AWK="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6041,7 +6019,7 @@ case $as_dir/ in #((
     # by default.
     for ac_prog in ginstall scoinst install; do
       for ac_exec_ext in '' $ac_executable_extensions; do
-	if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
 	  if test $ac_prog = install &&
 	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
 	    # AIX install.  It has an incompatible calling convention.
@@ -6125,7 +6103,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6165,7 +6143,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_RANLIB="ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6247,7 +6225,7 @@ do
     for ac_prog in egrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      as_fn_executable_p "$ac_path_EGREP" || continue
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
 # Check for GNU ac_path_EGREP and select it if it is found.
   # Check for GNU $ac_path_EGREP
 case `"$ac_path_EGREP" --version 2>&1` in
@@ -6315,7 +6293,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_STRIP="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6359,7 +6337,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_STRIP="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6415,7 +6393,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6459,7 +6437,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_AR="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6521,7 +6499,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_BISON="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6562,7 +6540,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_CMP="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6603,7 +6581,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_FLEX="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6644,7 +6622,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_GREP="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6685,7 +6663,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6726,7 +6704,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_FIND="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6767,7 +6745,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_COMPRESS="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6808,7 +6786,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_BASENAME="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6849,7 +6827,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_DIRNAME="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6890,7 +6868,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_SHELL="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6931,7 +6909,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_LN="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6972,7 +6950,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_DOT="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7013,7 +6991,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_WGET="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7054,7 +7032,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_CURL="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7095,7 +7073,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_RUBBER="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7136,7 +7114,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_CATDVI="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7177,7 +7155,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_KPATHSEA="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7218,7 +7196,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_XMLLINT="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7259,7 +7237,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_XMLSTARLET="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7300,7 +7278,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_GIT="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7346,7 +7324,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_FETCH="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7391,7 +7369,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_LDCONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7432,7 +7410,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_SHA1SUM="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7473,7 +7451,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_OPENSSL="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7565,7 +7543,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_SOXMIX="${ac_tool_prefix}soxmix"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7605,7 +7583,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_SOXMIX="soxmix"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7664,7 +7642,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_MD5="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7830,7 +7808,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_acx_pthread_config="yes"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7986,7 +7964,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_PTHREAD_CC="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -8999,7 +8977,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_AWK="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -9049,7 +9027,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path__libcurl_config="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -9091,7 +9069,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path__libcurl_config="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -11255,20 +11233,23 @@ else
 /* end confdefs.h.  */
 $ac_includes_default
 int
-find_stack_direction (int *addr, int depth)
+find_stack_direction ()
 {
-  int dir, dummy = 0;
-  if (! addr)
-    addr = &dummy;
-  *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
-  dir = depth ? find_stack_direction (addr, depth - 1) : 0;
-  return dir + dummy;
+  static char *addr = 0;
+  auto char dummy;
+  if (addr == 0)
+    {
+      addr = &dummy;
+      return find_stack_direction ();
+    }
+  else
+    return (&dummy > addr) ? 1 : -1;
 }
 
 int
-main (int argc, char **argv)
+main ()
 {
-  return find_stack_direction (0, argc + !argv + 20) < 0;
+  return find_stack_direction () < 0;
 }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -12084,7 +12065,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_CONFIG_LIBXML2="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -12128,7 +12109,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_ac_pt_CONFIG_LIBXML2="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -12457,8 +12438,6 @@ _ACEOF
 esac
 rm -rf conftest*
   fi
-
-
 fi
 
 
@@ -12471,60 +12450,60 @@ else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-             #include <stdbool.h>
-             #ifndef bool
-              "error: bool is not defined"
-             #endif
-             #ifndef false
-              "error: false is not defined"
-             #endif
-             #if false
-              "error: false is not 0"
-             #endif
-             #ifndef true
-              "error: true is not defined"
-             #endif
-             #if true != 1
-              "error: true is not 1"
-             #endif
-             #ifndef __bool_true_false_are_defined
-              "error: __bool_true_false_are_defined is not defined"
-             #endif
-
-             struct s { _Bool s: 1; _Bool t; } s;
-
-             char a[true == 1 ? 1 : -1];
-             char b[false == 0 ? 1 : -1];
-             char c[__bool_true_false_are_defined == 1 ? 1 : -1];
-             char d[(bool) 0.5 == true ? 1 : -1];
-             /* See body of main program for 'e'.  */
-             char f[(_Bool) 0.0 == false ? 1 : -1];
-             char g[true];
-             char h[sizeof (_Bool)];
-             char i[sizeof s.t];
-             enum { j = false, k = true, l = false * true, m = true * 256 };
-             /* The following fails for
-                HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
-             _Bool n[m];
-             char o[sizeof n == m * sizeof n[0] ? 1 : -1];
-             char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
-             /* Catch a bug in an HP-UX C compiler.  See
-                http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
-                http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
-              */
-             _Bool q = true;
-             _Bool *pq = &q;
-
-int
-main ()
-{
-
-             bool e = &s;
-             *pq |= q;
-             *pq |= ! q;
-             /* Refer to every declared value, to avoid compiler optimizations.  */
-             return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
-                     + !m + !n + !o + !p + !q + !pq);
+#include <stdbool.h>
+#ifndef bool
+ "error: bool is not defined"
+#endif
+#ifndef false
+ "error: false is not defined"
+#endif
+#if false
+ "error: false is not 0"
+#endif
+#ifndef true
+ "error: true is not defined"
+#endif
+#if true != 1
+ "error: true is not 1"
+#endif
+#ifndef __bool_true_false_are_defined
+ "error: __bool_true_false_are_defined is not defined"
+#endif
+
+	struct s { _Bool s: 1; _Bool t; } s;
+
+	char a[true == 1 ? 1 : -1];
+	char b[false == 0 ? 1 : -1];
+	char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+	char d[(bool) 0.5 == true ? 1 : -1];
+	/* See body of main program for 'e'.  */
+	char f[(_Bool) 0.0 == false ? 1 : -1];
+	char g[true];
+	char h[sizeof (_Bool)];
+	char i[sizeof s.t];
+	enum { j = false, k = true, l = false * true, m = true * 256 };
+	/* The following fails for
+	   HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
+	_Bool n[m];
+	char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+	char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+	/* Catch a bug in an HP-UX C compiler.  See
+	   http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+	   http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+	 */
+	_Bool q = true;
+	_Bool *pq = &q;
+
+int
+main ()
+{
+
+	bool e = &s;
+	*pq |= q;
+	*pq |= ! q;
+	/* Refer to every declared value, to avoid compiler optimizations.  */
+	return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+		+ !m + !n + !o + !p + !q + !pq);
 
   ;
   return 0;
@@ -12539,7 +12518,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
 $as_echo "$ac_cv_header_stdbool_h" >&6; }
-   ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
+ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
 if test "x$ac_cv_type__Bool" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
@@ -12549,7 +12528,6 @@ _ACEOF
 
 fi
 
-
 if test $ac_cv_header_stdbool_h = yes; then
 
 $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
@@ -12567,11 +12545,11 @@ else
 int
 main ()
 {
-
+/* FIXME: Include the comments suggested by Paul. */
 #ifndef __cplusplus
-  /* Ultrix mips cc rejects this sort of thing.  */
+  /* Ultrix mips cc rejects this.  */
   typedef int charset[2];
-  const charset cs = { 0, 0 };
+  const charset cs;
   /* SunOS 4.1.1 cc rejects this.  */
   char const *const *pcpcc;
   char **ppc;
@@ -12588,9 +12566,8 @@ main ()
   ++pcpcc;
   ppc = (char**) pcpcc;
   pcpcc = (char const *const *) ppc;
-  { /* SCO 3.2v4 cc rejects this sort of thing.  */
-    char tx;
-    char *t = &tx;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
     char const *s = 0 ? (char *) 0 : (char const *) 0;
 
     *t++ = 0;
@@ -12606,10 +12583,10 @@ main ()
     iptr p = 0;
     ++p;
   }
-  { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying
+  { /* AIX XL C 1.02.0.0 rejects this saying
        "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
-    struct s { int j; const int *ap[3]; } bx;
-    struct s *b = &bx; b->j = 5;
+    struct s { int j; const int *ap[3]; };
+    struct s *b; b->j = 5;
   }
   { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
     const int foo = 10;
@@ -12739,8 +12716,7 @@ static int test_array [1 - 2 * !((0 < ((DBL_MAX_EXP < LDBL_MAX_EXP)
 		   - (LDBL_MANT_DIG < DBL_MANT_DIG)))
 	    && (int) LDBL_EPSILON == 0
 	  )];
-test_array [0] = 0;
-return test_array [0];
+test_array [0] = 0
 
   ;
   return 0;
@@ -16257,10 +16233,10 @@ fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FORTIFY_SOURCE support" >&5
 $as_echo_n "checking for _FORTIFY_SOURCE support... " >&6; }
-if $(${CC} -D_FORTIFY_SOURCE=2 -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
+if $(${CC} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-	AST_FORTIFY_SOURCE=-D_FORTIFY_SOURCE=2
+	AST_FORTIFY_SOURCE="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
 else
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
@@ -17153,7 +17129,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -17196,7 +17172,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -20774,7 +20750,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_CONFIG_MYSQLCLIENT="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -20818,7 +20794,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_ac_pt_CONFIG_MYSQLCLIENT="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -21028,7 +21004,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_CONFIG_NEON="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -21072,7 +21048,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_ac_pt_CONFIG_NEON="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -21177,7 +21153,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_CONFIG_NEON29="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -21221,7 +21197,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_ac_pt_CONFIG_NEON29="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -21328,7 +21304,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_CONFIG_NETSNMP="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -21372,7 +21348,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_ac_pt_CONFIG_NETSNMP="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -22425,7 +22401,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_PG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -22468,7 +22444,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_ac_pt_PG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -22537,7 +22513,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_PG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -22580,7 +22556,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_ac_pt_PG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -25797,7 +25773,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_PTLIB_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -25859,7 +25835,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_PTLIB_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -29662,7 +29638,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_CONFIG_SDL="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -29706,7 +29682,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_ac_pt_CONFIG_SDL="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -31331,16 +31307,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -pR'.
+    # In both cases, we have to default to `cp -p'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
+      as_ln_s='cp -p'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -pR'
+    as_ln_s='cp -p'
   fi
 else
-  as_ln_s='cp -pR'
+  as_ln_s='cp -p'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -31400,16 +31376,28 @@ else
   as_mkdir_p=false
 fi
 
-
-# as_fn_executable_p FILE
-# -----------------------
-# Test if FILE is an executable regular file.
-as_fn_executable_p ()
-{
-  test -f "$1" && test -x "$1"
-} # as_fn_executable_p
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+	test -d "$1/.";
+      else
+	case $1 in #(
+	-*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -31431,7 +31419,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # values after options handling.
 ac_log="
 This file was extended by asterisk $as_me trunk, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -31493,10 +31481,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
 asterisk config.status trunk
-configured by $0, generated by GNU Autoconf 2.69,
+configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2010 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -31586,7 +31574,7 @@ fi
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
-  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
   shift
   \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
   CONFIG_SHELL='$SHELL'
diff --git a/configure.ac b/configure.ac
index e72a8d5..630c946 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@ AC_CONFIG_SRCDIR([main/asterisk.c])
 AC_CONFIG_AUX_DIR(`pwd`)
 
 AC_COPYRIGHT("Asterisk")
-AC_REVISION($Revision: 413765 $)
+AC_REVISION($Revision: 421228 $)
 
 # preserve any CFLAGS or LDFLAGS that may be set
 # NOTE: This must be done before calling any macros that end up
@@ -1005,9 +1005,9 @@ fi
 AC_SUBST(AST_TRAMPOLINES)
 
 AC_MSG_CHECKING(for _FORTIFY_SOURCE support)
-if $(${CC} -D_FORTIFY_SOURCE=2 -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
+if $(${CC} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
 	AC_MSG_RESULT(yes)
-	AST_FORTIFY_SOURCE=-D_FORTIFY_SOURCE=2
+	AST_FORTIFY_SOURCE="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
 else
 	AC_MSG_RESULT(no)
 	AST_FORTIFY_SOURCE=
diff --git a/contrib/scripts/refcounter.py b/contrib/scripts/refcounter.py
index 9bad400..1a97e90 100755
--- a/contrib/scripts/refcounter.py
+++ b/contrib/scripts/refcounter.py
@@ -60,11 +60,17 @@ def process_file(options):
     Returns:
     A tuple containing:
         - A list of objects whose lifetimes were completed
+            (i.e., finished objects)
+        - A list of objects referenced after destruction
+            (i.e., invalid objects)
         - A list of objects whose lifetimes were not completed
+            (i.e., leaked objects)
         - A list of objects whose lifetimes are skewed
+            (i.e., Object history starting with an unusual ref count)
     """
 
     finished_objects = []
+    invalid_objects = []
     leaked_objects = []
     skewed_objects = []
     current_objects = {}
@@ -76,35 +82,69 @@ def process_file(options):
             if not parsed_line:
                 continue
 
+            invalid = False
             obj = parsed_line['addr']
 
             if obj not in current_objects:
-                current_objects[obj] = {'log': [], 'curcount': 1,}
-                if 'constructor' not in parsed_line['state']:
-                    current_objects[obj]['curcount'] = parsed_line['state']
+                current_objects[obj] = {'log': [], 'curcount': 1}
+                if 'constructor' in parsed_line['state']:
+                    # This is the normal expected case
+                    pass
+                elif 'invalid' in parsed_line['state']:
+                    invalid = True
+                    current_objects[obj]['curcount'] = 0
+                    if options.invalid:
+                        invalid_objects.append((obj, current_objects[obj]))
+                elif 'destructor' in parsed_line['state']:
+                    current_objects[obj]['curcount'] = 0
+                    if options.skewed:
+                        skewed_objects.append((obj, current_objects[obj]))
+                else:
+                    current_objects[obj]['curcount'] = int(
+                        parsed_line['state'])
                     if options.skewed:
                         skewed_objects.append((obj, current_objects[obj]))
             else:
                 current_objects[obj]['curcount'] += int(parsed_line['delta'])
 
-            current_objects[obj]['log'].append("[%s] %s:%s %s: %s %s - [%s]" % (
-                parsed_line['thread_id'],
-                parsed_line['file'],
-                parsed_line['line'],
-                parsed_line['function'],
-                parsed_line['delta'],
-                parsed_line['tag'],
-                parsed_line['state']))
-
-            if current_objects[obj]['curcount'] == 0:
-                if options.normal:
+            current_objects[obj]['log'].append(
+                "[%s] %s:%s %s: %s %s - [%s]" % (
+                    parsed_line['thread_id'],
+                    parsed_line['file'],
+                    parsed_line['line'],
+                    parsed_line['function'],
+                    parsed_line['delta'],
+                    parsed_line['tag'],
+                    parsed_line['state']))
+
+            # It is possible for curcount to go below zero if someone
+            # unrefs an object by two or more when there aren't that
+            # many refs remaining.  This condition abnormally finishes
+            # the object.
+            if current_objects[obj]['curcount'] <= 0:
+                if current_objects[obj]['curcount'] < 0:
+                    current_objects[obj]['log'].append(
+                        "[%s] %s:%s %s: %s %s - [%s]" % (
+                            parsed_line['thread_id'],
+                            parsed_line['file'],
+                            parsed_line['line'],
+                            parsed_line['function'],
+                            "+0",
+                            "Object abnormally finalized",
+                            "**implied destructor**"))
+                    # Highlight the abnormally finished object in the
+                    # invalid section as well as reporting it in the normal
+                    # finished section.
+                    if options.invalid:
+                        invalid_objects.append((obj, current_objects[obj]))
+                if not invalid and options.normal:
                     finished_objects.append((obj, current_objects[obj]))
                 del current_objects[obj]
 
     if options.leaks:
         for key, lines in current_objects.iteritems():
             leaked_objects.append((key, lines))
-    return (finished_objects, leaked_objects, skewed_objects)
+    return (finished_objects, invalid_objects, leaked_objects, skewed_objects)
 
 
 def print_objects(objects, prefix=""):
@@ -138,6 +178,10 @@ def main(argv=None):
     parser.add_option("-f", "--file", action="store", type="string",
                       dest="filepath", default="/var/log/asterisk/refs",
                       help="The full path to the refs file to process")
+    parser.add_option("-i", "--suppress-invalid", action="store_false",
+                      dest="invalid", default=True,
+                      help="If specified, don't output invalid object "
+                           "references")
     parser.add_option("-l", "--suppress-leaks", action="store_false",
                       dest="leaks", default=True,
                       help="If specified, don't output leaked objects")
@@ -152,7 +196,8 @@ def main(argv=None):
 
     (options, args) = parser.parse_args(argv)
 
-    if not options.leaks and not options.skewed and not options.normal:
+    if not options.invalid and not options.leaks and not options.normal \
+            and not options.skewed:
         print >>sys.stderr, "All options disabled"
         return -1
 
@@ -162,9 +207,14 @@ def main(argv=None):
 
     try:
         (finished_objects,
+         invalid_objects,
          leaked_objects,
          skewed_objects) = process_file(options)
 
+        if options.invalid and len(invalid_objects):
+            print_objects(invalid_objects, "Invalid Referenced")
+            ret_code |= 4
+
         if options.leaks and len(leaked_objects):
             print_objects(leaked_objects, "Leaked")
             ret_code |= 1
diff --git a/doc/aelparse.8 b/doc/aelparse.8
new file mode 100644
index 0000000..9c81c8f
--- /dev/null
+++ b/doc/aelparse.8
@@ -0,0 +1,28 @@
+.TH AELPARSE "8" "Jul 2014" "Asterisk trunk" ""
+.SH NAME
+aelparse \- utility to check extensions.ael for errors
+.SH SYNOPSIS
+.B aelparse
+[\-d] [\-n] [\-q] [\-w]
+.SH DESCRIPTION
+aelparse is a utility to check the extensions.ael configuration file before
+feeding it to asterisk.
+.SH OPTIONS
+.TP
+\fB\-d\fR
+Use the current working directory as the CONFIG_DIR.
+.TP
+\fB\-n\fR
+Do not display the instructions generated by the compiler.
+.TP
+\fB\-q\fR
+Suppress progress and non-error messages.
+.TP
+\fB\-w\fR
+Dump extensions.conf format to extensions.conf.aeldump.
+
+.SH SEE ALSO
+.B asterisk(8)
+
+.SH AUTHOR
+This manual page was written by Jeremy Lainé <jeremy.laine at m4x.org>.
diff --git a/doc/smsq.8 b/doc/smsq.8
new file mode 100644
index 0000000..f036355
--- /dev/null
+++ b/doc/smsq.8
@@ -0,0 +1,146 @@
+.TH SMSQ "8" "May 2014" "Asterisk trunk" ""
+.SH NAME
+smsq \- helper to send SMS messages
+.SH SYNOPSIS
+.B smsq
+\fI\,<oa/da> <message>\/\fR
+.SH DESCRIPTION
+smsq is a simple helper application designed to make it easy to send messages
+from a command line. it is intended to run on the Asterisk box and have direct
+access to the queue directories for SMS and for Asterisk.
+.SH OPTIONS
+.TP
+\fB\-q\fR, \fB\-\-queue\fR=\fI\,number[\-X]\/\fR
+Queue [inc sub address] (default: "")
+.TP
+\fB\-d\fR, \fB\-\-da\fR=\fI\,number\/\fR
+Destination address
+.TP
+\fB\-o\fR, \fB\-\-oa\fR=\fI\,number\/\fR
+Origination address
+.TP
+\fB\-m\fR, \fB\-\-ud\fR=\fI\,text\/\fR
+Message
+.TP
+\fB\-f\fR, \fB\-\-ud\-file\fR=\fI\,filename\/\fR
+Message file
+.TP
+\fB\-\-UTF\-8\fR
+File treated as null terminated UTF\-8
+(default)
+.TP
+\fB\-\-UCS\-1\fR
+File treated as UCS\-1
+.TP
+\fB\-\-UCS\-2\fR
+File treated as UCS\-2
+.TP
+\fB\-t\fR, \fB\-\-mt\fR
+Mobile Terminated
+.TP
+\fB\-\-mo\fR
+Mobile Originated
+.TP
+\fB\-\-tx\fR
+Send message
+.TP
+\fB\-r\fR, \fB\-\-rx\fR
+Queue for receipt
+.TP
+\fB\-e\fR, \fB\-\-process\fR=\fI\,command\/\fR
+Rx queue process command
+.TP
+\fB\-x\fR, \fB\-\-no\-dial\fR
+Do not dial
+.TP
+\fB\-\-no\-wait\fR
+Do not wait if already calling
+.TP
+\fB\-\-concurrent\fR=\fI\,n\/\fR
+Number of concurrent calls to allow
+(default: 1)
+.TP
+\fB\-\-motx\-channel\fR=\fI\,channel\/\fR
+Channel for motx calls (default:
+"Local/1709400X")
+.TP
+\fB\-\-motx\-callerid\fR=\fI\,number\/\fR
+Caller ID for motx calls (default is
+queue name without sub address)
+.TP
+\fB\-\-motx\-wait\fR=\fI\,seconds\/\fR
+Time to wait for motx call to answer
+(default: 10)
+.TP
+\fB\-\-motx\-delay\fR=\fI\,seconds\/\fR
+Time between motx call retries (default:
+1)
+.TP
+\fB\-\-motx\-retries\fR=\fI\,n\/\fR
+Number of retries for motx call (default:
+10)
+.TP
+\fB\-\-mttx\-channel\fR=\fI\,channel\/\fR
+Channel for mttx calls (default is Local/
+and queue name without sub address)
+.TP
+\fB\-\-mttx\-callerid\fR=\fI\,number\/\fR
+Caller ID for mttx calls (default is
+queue name without sub address) (default:
+"080058752X0")
+.TP
+\fB\-\-mttx\-wait\fR=\fI\,seconds\/\fR
+Time to wait for mttx call to answer
+(default: 10)
+.TP
+\fB\-\-mttx\-delay\fR=\fI\,seconds\/\fR
+Time between mttx call retries (default:
+30)
+.TP
+\fB\-\-mttx\-retries\fR=\fI\,n\/\fR
+Number of retries for mttx call (default:
+100)
+.TP
+\fB\-n\fR, \fB\-\-mr\fR=\fI\,n\/\fR
+Message reference
+.TP
+\fB\-p\fR, \fB\-\-pid\fR=\fI\,n\/\fR
+Protocol ID
+.TP
+\fB\-c\fR, \fB\-\-dcs\fR=\fI\,n\/\fR
+Data Coding Scheme
+.TP
+\fB\-\-udh\fR=\fI\,hex\/\fR
+User data header
+.TP
+\fB\-\-srr\fR
+Status Report Request
+.TP
+\fB\-\-rp\fR
+Return Path request
+.TP
+\fB\-\-v\fR=\fI\,seconds\/\fR
+Validity Period
+.TP
+\fB\-\-scts\fR=\fI\,YYYY\-MM\-SSTHH\/\fR:MM:SS
+Timestamp
+.TP
+\fB\-\-default\-sub\-address\fR=\fI\,X\/\fR
+Default sub address (default: "9")
+.TP
+\fB\-\-spool\-dir\fR=\fI\,dirname\/\fR
+Asterisk spool dir (default:
+"/var/spool/asterisk")
+.SS "Help options:"
+.TP
+\-?, \fB\-\-help\fR
+Show this help message
+.TP
+\fB\-\-usage\fR
+Display brief usage message
+
+.SH SEE ALSO
+.B asterisk(8)
+
+.SH AUTHOR
+This manual page was written by Jeremy Lainé <jeremy.laine at m4x.org>.
diff --git a/funcs/func_config.c b/funcs/func_config.c
index d3ea099..2c84f4a 100644
--- a/funcs/func_config.c
+++ b/funcs/func_config.c
@@ -33,7 +33,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 400697 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 421328 $")
 
 #include "asterisk/module.h"
 #include "asterisk/channel.h"
@@ -165,7 +165,7 @@ static int config_function_read(struct ast_channel *chan, const char *cmd, char
 	}
 
 	if (!(val = ast_variable_retrieve(cfg, args.category, args.variable))) {
-		ast_log(LOG_ERROR, "'%s' not found in [%s] of '%s'\n", args.variable, 
+		ast_debug(1, "'%s' not found in [%s] of '%s'\n", args.variable,
 			args.category, args.filename);
 		AST_RWLIST_UNLOCK(&configs);
 		return -1;
diff --git a/include/asterisk/config.h b/include/asterisk/config.h
index dae4b52..711a4f4 100644
--- a/include/asterisk/config.h
+++ b/include/asterisk/config.h
@@ -576,8 +576,11 @@ void ast_category_append(struct ast_config *config, struct ast_category *cat);
  * \details
  * This function is used to insert a new category above another category
  * matching the match parameter.
+ *
+ * \retval 0 if succeeded
+ * \retval -1 if NULL parameters or match category was not found
  */
-void ast_category_insert(struct ast_config *config, struct ast_category *cat, const char *match);
+int ast_category_insert(struct ast_config *config, struct ast_category *cat, const char *match);
 int ast_category_delete(struct ast_config *cfg, const char *category);
 
 /*!
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index 25d4c6d..8ca1632 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -317,6 +317,15 @@ int ast_xml_escape(const char *string, char *outbuf, size_t buflen);
  */
 char *ast_escape_quoted(const char *string, char *outbuf, int buflen);
 
+/*!
+ * \brief Unescape quotes in a string
+ *
+ * \param quote_str The string with quotes to be unescaped
+ *
+ * \note This function mutates the passed-in string.
+ */
+void ast_unescape_quoted(char *quote_str);
+
 static force_inline void ast_slinear_saturated_add(short *input, short *value)
 {
 	int res;
diff --git a/main/app.c b/main/app.c
index cc6bb80..c2fbf4f 100644
--- a/main/app.c
+++ b/main/app.c
@@ -29,7 +29,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 413587 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 421164 $")
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -190,7 +190,6 @@ enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *promp
 
 	filename = ast_strdupa(prompt);
 	while ((front = strsep(&filename, "&"))) {
-		ast_test_suite_event_notify("PLAYBACK", "Message: %s\r\nChannel: %s", front, ast_channel_name(c));
 		if (!ast_strlen_zero(front)) {
 			res = ast_streamfile(c, front, ast_channel_language(c));
 			if (res)
@@ -1086,7 +1085,6 @@ int ast_play_and_wait(struct ast_channel *chan, const char *fn)
 {
 	int d = 0;
 
-	ast_test_suite_event_notify("PLAYBACK", "Message: %s\r\nChannel: %s", fn, ast_channel_name(chan));
 	if ((d = ast_streamfile(chan, fn, ast_channel_language(chan)))) {
 		return d;
 	}
diff --git a/main/astobj2.c b/main/astobj2.c
index cad1c0c..8ee58a0 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -24,7 +24,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 418505 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 423400 $")
 
 #include "asterisk/_private.h"
 #include "asterisk/astobj2.h"
@@ -524,8 +524,14 @@ int __ao2_ref_debug(void *user_data, int delta, const char *tag, const char *fil
 	}
 
 	if (ref_log && user_data) {
-		if (obj && old_refcount + delta == 0) {
-			fprintf(ref_log, "%p,%d,%d,%s,%d,%s,**destructor**,%s\n", user_data, delta, ast_get_tid(), file, line, func, tag);
+		if (!obj) {
+			/* Invalid object: Bad magic number. */
+			fprintf(ref_log, "%p,%d,%d,%s,%d,%s,**invalid**,%s\n",
+				user_data, delta, ast_get_tid(), file, line, func, tag);
+			fflush(ref_log);
+		} else if (old_refcount + delta == 0) {
+			fprintf(ref_log, "%p,%d,%d,%s,%d,%s,**destructor**,%s\n",
+				user_data, delta, ast_get_tid(), file, line, func, tag);
 			fflush(ref_log);
 		} else if (delta != 0) {
 			fprintf(ref_log, "%p,%s%d,%d,%s,%d,%s,%d,%s\n", user_data, (delta < 0 ? "" : "+"),
diff --git a/main/callerid.c b/main/callerid.c
index 3e75ee7..d2d59ff 100644
--- a/main/callerid.c
+++ b/main/callerid.c
@@ -29,7 +29,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 413587 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 422113 $")
 
 #include <time.h>
 #include <math.h>
@@ -1008,50 +1008,39 @@ int ast_is_shrinkable_phonenumber(const char *exten)
 
 int ast_callerid_parse(char *instr, char **name, char **location)
 {
-	char *ns, *ne, *ls, *le;
+	char *ls, *le, *name_start;
 
-	/* Try "name" <location> format or name <location> format */
-	if ((ls = strrchr(instr, '<')) && (le = strrchr(ls, '>'))) {
-		*ls = *le = '\0';	/* location found, trim off the brackets */
-		*location = ls + 1;	/* and this is the result */
-		if ((ns = strchr(instr, '"')) && (ne = strchr(ns + 1, '"'))) {
-			*ns = *ne = '\0';	/* trim off the quotes */
-			*name = ns + 1;		/* and this is the name */
-		} else if (ns) {
-			/* An opening quote was found but no closing quote was. The closing
-			 * quote may actually be after the end of the bracketed number
-			 */
-			if (strchr(le + 1, '\"')) {
-				*ns = '\0';
-				*name = ns + 1;
-				ast_trim_blanks(*name);
-			} else {
-				*name = NULL;
-			}
-		} else { /* no quotes, trim off leading and trailing spaces */
-			*name = ast_skip_blanks(instr);
-			ast_trim_blanks(*name);
+	/* Handle surrounding quotes */
+	instr = ast_strip_quoted(instr, "\"", "\"");
+
+	/* Try "name" <location> format or name <location> format or with a missing > */
+	if ((ls = strrchr(instr, '<'))) {
+		if ((le = strrchr(ls, '>'))) {
+			*le = '\0';	/* location found, trim off the brackets */
 		}
+		*ls = '\0';
+		*location = ls + 1;	/* and this is the result */
+
+		name_start = ast_strip_quoted(instr, "\"", "\"");
 	} else {	/* no valid brackets */
 		char tmp[256];
 
 		ast_copy_string(tmp, instr, sizeof(tmp));
 		ast_shrink_phone_number(tmp);
 		if (ast_isphonenumber(tmp)) {	/* Assume it's just a location */
-			*name = NULL;
+			name_start = NULL;
 			strcpy(instr, tmp); /* safe, because tmp will always be the same size or smaller than instr */
 			*location = instr;
 		} else { /* Assume it's just a name. */
 			*location = NULL;
-			if ((ns = strchr(instr, '"')) && (ne = strchr(ns + 1, '"'))) {
-				*ns = *ne = '\0';	/* trim off the quotes */
-				*name = ns + 1;		/* and this is the name */
-			} else { /* no quotes, trim off leading and trailing spaces */
-				*name = ast_skip_blanks(instr);
-				ast_trim_blanks(*name);
-			}
+			name_start = ast_strip_quoted(instr, "\"", "\"");
 		}
 	}
+
+	if (name_start) {
+		ast_unescape_quoted(name_start);
+	}
+	*name = name_start;
 	return 0;
 }
 
@@ -1078,14 +1067,18 @@ char *ast_callerid_merge(char *buf, int bufsiz, const char *name, const char *nu
 {
 	if (!unknown)
 		unknown = "<unknown>";
-	if (name && num)
-		snprintf(buf, bufsiz, "\"%s\" <%s>", name, num);
-	else if (name)
+	if (name && num) {
+		char name_buf[128];
+
+		ast_escape_quoted(name, name_buf, sizeof(name_buf));
+		snprintf(buf, bufsiz, "\"%s\" <%s>", name_buf, num);
+	} else if (name) {
 		ast_copy_string(buf, name, bufsiz);
-	else if (num)
+	} else if (num) {
 		ast_copy_string(buf, num, bufsiz);
-	else
+	} else {
 		ast_copy_string(buf, unknown, bufsiz);
+	}
 	return buf;
 }
 
diff --git a/main/channel.c b/main/channel.c
index 60f06cf..4988616 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -29,7 +29,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 413587 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 423010 $")
 
 #include "asterisk/_private.h"
 
@@ -7963,8 +7963,13 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
 
 		if (config->timelimit) {
 			time_left_ms = config->timelimit - ast_tvdiff_ms(now, config->start_time);
-			if (time_left_ms < to)
+			if (time_left_ms < 0) {
+				time_left_ms = 0;
+			}
+
+			if (time_left_ms < to) {
 				to = time_left_ms;
+			}
 
 			if (time_left_ms <= 0) {
 				if (caller_warning && config->end_sound)
@@ -7972,7 +7977,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
 				if (callee_warning && config->end_sound)
 					bridge_playfile(c1, c0, config->end_sound, 0);
 				*fo = NULL;
-				res = 0;
+				res = AST_BRIDGE_COMPLETE;
 				ast_test_suite_event_notify("BRIDGE_TIMELIMIT", "Channel1: %s\r\nChannel2: %s", ast_channel_name(c0), ast_channel_name(c1));
 				break;
 			}
@@ -8015,7 +8020,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
 		if (ast_test_flag(ast_channel_flags(c0), AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
 		    ast_test_flag(ast_channel_flags(c1), AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) {
 			*fo = NULL;
-			res = 0;
+			res = AST_BRIDGE_COMPLETE;
 			ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
 				ast_channel_name(c0), ast_channel_name(c1),
 				ast_test_flag(ast_channel_flags(c0), AST_FLAG_ZOMBIE) ? "Yes" : "No",
@@ -8031,7 +8036,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
 
 		if (ast_channel_tech(c0)->bridge &&
 			/* if < 1 ms remains use generic bridging for accurate timing */
-			(!config->timelimit || to > 1000 || to == 0) &&
+			(!config->timelimit || to > 1000 || to == -1) &&
 		    (ast_channel_tech(c0)->bridge == ast_channel_tech(c1)->bridge) &&
 		    !ast_channel_monitor(c0) && !ast_channel_monitor(c1) &&
 		    !ast_channel_audiohooks(c0) && !ast_channel_audiohooks(c1) &&
diff --git a/main/cli.c b/main/cli.c
index 93e6334..5d2b6b0 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -29,7 +29,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 413587 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 421602 $")
 
 #include "asterisk/_private.h"
 #include "asterisk/paths.h"	/* use ast_config_AST_MODULE_DIR */
@@ -227,7 +227,7 @@ static char *complete_fn(const char *word, int state)
 	if (c)
 		c = ast_strdup(c);
 
-	free(d);
+	ast_std_free(d);
 
 	return c;
 }
diff --git a/main/config.c b/main/config.c
index 86972e4..5760ddf 100644
--- a/main/config.c
+++ b/main/config.c
@@ -32,7 +32,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 418366 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 423277 $")
 
 #include "asterisk/paths.h"	/* use ast_config_AST_CONFIG_DIR */
 #include "asterisk/network.h"	/* we do some sockaddr manipulation here */
@@ -729,24 +729,28 @@ void ast_category_append(struct ast_config *config, struct ast_category *categor
 	config->current = category;
 }
 
-void ast_category_insert(struct ast_config *config, struct ast_category *cat, const char *match)
+int ast_category_insert(struct ast_config *config, struct ast_category *cat, const char *match)
 {
 	struct ast_category *cur_category;
 
-	if (!cat || !match)
-		return;
+	if (!config || !cat || !match) {
+		return -1;
+	}
 	if (!strcasecmp(config->root->name, match)) {
 		cat->next = config->root;
 		config->root = cat;
-		return;
+		return 0;
 	}
-	for (cur_category = config->root; cur_category; cur_category = cur_category->next) {
+	for (cur_category = config->root; cur_category && cur_category->next;
+		cur_category = cur_category->next) {
 		if (!strcasecmp(cur_category->next->name, match)) {
 			cat->next = cur_category->next;
 			cur_category->next = cat;
-			break;
+			return 0;
 		}
 	}
+
+	return -1;
 }
 
 static void ast_destroy_template_list(struct ast_category *cat)
@@ -1996,21 +2000,27 @@ static void inclfile_destroy(void *obj)
 	ast_free(o->fname);
 }
 
-
-static struct inclfile *set_fn(char *fn, int fn_size, const char *file, const char *configfile, struct ao2_container *fileset)
+static void make_fn(char *fn, size_t fn_size, const char *file, const char *configfile)
 {
-	struct inclfile lookup;
-	struct inclfile *fi;
-
 	if (ast_strlen_zero(file)) {
-		if (configfile[0] == '/')
+		if (configfile[0] == '/') {
 			ast_copy_string(fn, configfile, fn_size);
-		else
+		} else {
 			snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
-	} else if (file[0] == '/')
+		}
+	} else if (file[0] == '/') {
 		ast_copy_string(fn, file, fn_size);
-	else
+	} else {
 		snprintf(fn, fn_size, "%s/%s", ast_config_AST_CONFIG_DIR, file);
+	}
+}
+
+static struct inclfile *set_fn(char *fn, size_t fn_size, const char *file, const char *configfile, struct ao2_container *fileset)
+{
+	struct inclfile lookup;
+	struct inclfile *fi;
+
+	make_fn(fn, fn_size, file, configfile);
 	lookup.fname = fn;
 	fi = ao2_find(fileset, &lookup, OBJ_POINTER);
 	if (fi) {
@@ -2119,11 +2129,29 @@ int ast_config_text_file_save(const char *configfile, const struct ast_config *c
 		return -1;
 	}
 
-	/* reset all the output flags, in case this isn't our first time saving this data */
+	/* Check all the files for write access before attempting to modify any of them */
 	for (incl = cfg->includes; incl; incl = incl->next) {
+		/* reset all the output flags in case this isn't our first time saving this data */
 		incl->output = 0;
+		/* now make sure we have write access */
+		if (!incl->exec) {
+			make_fn(fn, sizeof(fn), incl->included_file, configfile);
+			if (access(fn, R_OK | W_OK)) {
+				ast_log(LOG_ERROR, "Unable to write %s (%s)\n", fn, strerror(errno));
+				return -1;
+			}
+		}
 	}
 
+	/* now make sure we have write access to the main config file */
+	make_fn(fn, sizeof(fn), 0, configfile);
+	if (access(fn, R_OK | W_OK)) {
+		ast_log(LOG_ERROR, "Unable to write %s (%s)\n", fn, strerror(errno));
+		return -1;
+	}
+
+	/* Now that we know we have write access to all files, it's safe to start truncating them */
+
 	/* go thru all the inclusions and make sure all the files involved (configfile plus all its inclusions)
 	   are all truncated to zero bytes and have that nice header*/
 	for (incl = cfg->includes; incl; incl = incl->next) {
@@ -2135,8 +2163,7 @@ int ast_config_text_file_save(const char *configfile, const struct ast_config *c
 				gen_header(f, configfile, fn, generator);
 				fclose(f); /* this should zero out the file */
 			} else {
-				ast_debug(1, "Unable to open for writing: %s\n", fn);
-				ast_verb(2, "Unable to write %s (%s)\n", fn, strerror(errno));
+				ast_log(LOG_ERROR, "Unable to write %s (%s)\n", fn, strerror(errno));
 			}
 			if (fi) {
 				ao2_ref(fi, -1);
@@ -2169,8 +2196,7 @@ int ast_config_text_file_save(const char *configfile, const struct ast_config *c
 			fi = set_fn(fn, sizeof(fn), cat->file, configfile, fileset);
 			f = fopen(fn, "a");
 			if (!f) {
-				ast_debug(1, "Unable to open for writing: %s\n", fn);
-				ast_verb(2, "Unable to write %s (%s)\n", fn, strerror(errno));
+				ast_log(LOG_ERROR, "Unable to write %s (%s)\n", fn, strerror(errno));
 				if (fi) {
 					ao2_ref(fi, -1);
 				}
diff --git a/main/file.c b/main/file.c
index 5d4d717..7f7b183 100644
--- a/main/file.c
+++ b/main/file.c
@@ -29,7 +29,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 413587 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 421060 $")
 
 #include <dirent.h>
 #include <sys/stat.h>
@@ -1045,6 +1045,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p
 		return -1;
 	if (vfs && ast_applystream(chan, vfs))
 		return -1;
+	ast_test_suite_event_notify("PLAYBACK", "Message: %s\r\nChannel: %s", filename, ast_channel_name(chan));
 	res = ast_playstream(fs);
 	if (!res && vfs)
 		res = ast_playstream(vfs);
@@ -1461,7 +1462,6 @@ int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *
 {
 	int res = 0;
 	if (!ast_strlen_zero(file)) {
-		ast_test_suite_event_notify("PLAYBACK", "Message: %s\r\nChannel: %s", file, ast_channel_name(chan));
 		res = ast_streamfile(chan, file, ast_channel_language(chan));
 		if (!res) {
 			res = ast_waitstream(chan, digits);
diff --git a/main/logger.c b/main/logger.c
index 24a50df..7eb60e3 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -31,7 +31,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 416733 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 420897 $")
 
 /* When we include logger.h again it will trample on some stuff in syslog.h, but
  * nothing we care about in here. */
@@ -86,7 +86,7 @@ static int display_callids;
 static void unique_callid_cleanup(void *data);
 
 struct ast_callid {
-    int call_identifier; /* Numerical value of the call displayed in the logs */
+	int call_identifier; /* Numerical value of the call displayed in the logs */
 };
 
 AST_THREADSTORAGE_CUSTOM(unique_callid, NULL, unique_callid_cleanup);
@@ -1044,25 +1044,58 @@ static void ast_log_vsyslog(struct logmsg *msg)
 	syslog(syslog_level, "%s", buf);
 }
 
+static char *logger_strip_verbose_magic(const char *message, int level)
+{
+	const char *begin, *end;
+	char *stripped_message, *dst;
+	char magic = -(level + 1);
+
+	if (!(stripped_message = ast_malloc(strlen(message) + 1))) {
+		return NULL;
+	}
+
+	begin = message;
+	dst = stripped_message;
+	do {
+		end = strchr(begin, magic);
+		if (end) {
+			size_t len = end - begin;
+			memcpy(dst, begin, len);
+			begin = end + 1;
+			dst += len;
+		} else {
+			strcpy(dst, begin); /* safe */
+			break;
+		}
+	} while (1);
+
+	return stripped_message;
+}
+
 /*! \brief Print a normal log message to the channels */
 static void logger_print_normal(struct logmsg *logmsg)
 {
 	struct logchannel *chan = NULL;
 	char buf[BUFSIZ];
 	struct verb *v = NULL;
+	char *tmpmsg;
 	int level = 0;
 
 	if (logmsg->level == __LOG_VERBOSE) {
-		char *tmpmsg = ast_strdupa(logmsg->message + 1);
-
-		level = VERBOSE_MAGIC2LEVEL(logmsg->message);
 
 		/* Iterate through the list of verbosers and pass them the log message string */
 		AST_RWLIST_RDLOCK(&verbosers);
 		AST_RWLIST_TRAVERSE(&verbosers, v, list)
 			v->verboser(logmsg->message);
 		AST_RWLIST_UNLOCK(&verbosers);
-		ast_string_field_set(logmsg, message, tmpmsg);
+
+		level = VERBOSE_MAGIC2LEVEL(logmsg->message);
+
+		tmpmsg = logger_strip_verbose_magic(logmsg->message, level);
+		if (tmpmsg) {
+			ast_string_field_set(logmsg, message, tmpmsg);
+			ast_free(tmpmsg);
+		}
 	}
 
 	AST_RWLIST_RDLOCK(&logchannels);
diff --git a/main/manager.c b/main/manager.c
index e1ff9d3..765a268 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -47,7 +47,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 419943 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 423277 $")
 
 #include "asterisk/_private.h"
 #include "asterisk/paths.h"	/* use various ast_config_AST_* */
@@ -194,7 +194,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 419943 $")
 		</synopsis>
 		<syntax>
 			<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
-			<parameter name="Channel" required="true">
+			<parameter name="Channel" required="false">
 				<para>The name of the channel to query for status.</para>
 			</parameter>
 			<parameter name="Variables">
@@ -1200,6 +1200,8 @@ static void free_channelvars(void);
 
 static enum add_filter_result manager_add_filter(const char *filter_pattern, struct ao2_container *whitefilters, struct ao2_container *blackfilters);
 
+static int match_filter(struct mansession *s, char *eventdata);
+
 /*!
  * \internal
  * \brief Find a registered action object.
@@ -2931,7 +2933,11 @@ static enum error_type handle_updates(struct mansession *s, const struct message
 			if (ast_strlen_zero(match)) {
 				ast_category_append(cfg, category);
 			} else {
-				ast_category_insert(cfg, category, match);
+				if (ast_category_insert(cfg, category, match)) {
+					result = FAILURE_NEWCAT;
+					ast_category_destroy(category);
+					break;
+				}
 			}
 		} else if (!strcasecmp(action, "renamecat")) {
 			if (ast_strlen_zero(value)) {
@@ -3205,8 +3211,9 @@ static int action_waitevent(struct mansession *s, const struct message *m)
 		struct eventqent *eqe = s->session->last_ev;
 		astman_send_response(s, m, "Success", "Waiting for Event completed.");
 		while ((eqe = advance_event(eqe))) {
-			if (((s->session->readperm & eqe->category) == eqe->category) &&
-			    ((s->session->send_events & eqe->category) == eqe->category)) {
+			if (((s->session->readperm & eqe->category) == eqe->category)
+				&& ((s->session->send_events & eqe->category) == eqe->category)
+				&& match_filter(s, eqe->eventdata)) {
 				astman_append(s, "%s", eqe->eventdata);
 			}
 			s->session->last_ev = eqe;
@@ -3314,6 +3321,7 @@ static int action_login(struct mansession *s, const struct message *m)
 	}
 	astman_send_ack(s, m, "Authentication accepted");
 	if ((s->session->send_events & EVENT_FLAG_SYSTEM)
+		&& (s->session->readperm & EVENT_FLAG_SYSTEM)
 		&& ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
 		struct ast_str *auth = ast_str_alloca(80);
 		const char *cat_str = authority_to_str(EVENT_FLAG_SYSTEM, &auth);
diff --git a/main/tcptls.c b/main/tcptls.c
index d841ff4..563259a 100644
--- a/main/tcptls.c
+++ b/main/tcptls.c
@@ -31,7 +31,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 420655 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 426019 $")
 
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
@@ -746,6 +746,8 @@ static int __ssl_setup(struct ast_tls_config *cfg, int client)
 	cfg->enabled = 0;
 	return 0;
 #else
+	int disable_ssl = 0;
+ 
 	if (!cfg->enabled) {
 		return 0;
 	}
@@ -761,22 +763,21 @@ static int __ssl_setup(struct ast_tls_config *cfg, int client)
 	if (client) {
 #ifndef OPENSSL_NO_SSL2
 		if (ast_test_flag(&cfg->flags, AST_SSL_SSLV2_CLIENT)) {
+			ast_log(LOG_WARNING, "Usage of SSLv2 is discouraged due to known vulnerabilities. Please use 'tlsv1' or leave the TLS method unspecified!\n");
 			cfg->ssl_ctx = SSL_CTX_new(SSLv2_client_method());
 		} else
 #endif
 		if (ast_test_flag(&cfg->flags, AST_SSL_SSLV3_CLIENT)) {
+			ast_log(LOG_WARNING, "Usage of SSLv3 is discouraged due to known vulnerabilities. Please use 'tlsv1' or leave the TLS method unspecified!\n");
 			cfg->ssl_ctx = SSL_CTX_new(SSLv3_client_method());
 		} else if (ast_test_flag(&cfg->flags, AST_SSL_TLSV1_CLIENT)) {
 			cfg->ssl_ctx = SSL_CTX_new(TLSv1_client_method());
 		} else {
-			/* SSLv23_client_method() sends SSLv2, this was the original
-			 * default for ssl clients before the option was given to
-			 * pick what protocol a client should use.  In order not
-			 * to break expected behavior it remains the default. */
+			disable_ssl = 1;
 			cfg->ssl_ctx = SSL_CTX_new(SSLv23_client_method());
 		}
 	} else {
-		/* SSLv23_server_method() supports TLSv1, SSLv2, and SSLv3 inbound connections. */
+		disable_ssl = 1;
 		cfg->ssl_ctx = SSL_CTX_new(SSLv23_server_method());
 	}
 
@@ -786,6 +787,17 @@ static int __ssl_setup(struct ast_tls_config *cfg, int client)
 		return 0;
 	}
 
+	/* Due to the POODLE vulnerability, completely disable
+	 * SSLv2 and SSLv3 if we are not explicitly told to use
+	 * them. SSLv23_*_method supports TLSv1+.
+	 */
+	if (disable_ssl) {
+		long ssl_opts;
+
+		ssl_opts = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3;
+		SSL_CTX_set_options(cfg->ssl_ctx, ssl_opts);
+	}
+
 	SSL_CTX_set_verify(cfg->ssl_ctx,
 		ast_test_flag(&cfg->flags, AST_SSL_VERIFY_CLIENT) ? SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT : SSL_VERIFY_NONE,
 		NULL);
diff --git a/main/utils.c b/main/utils.c
index b917665..0e32ac7 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -29,7 +29,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 420715 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 422113 $")
 
 #include <ctype.h>
 #include <sys/stat.h>
@@ -493,6 +493,29 @@ char *ast_escape_quoted(const char *string, char *outbuf, int buflen)
 
 	return outbuf;
 }
+
+void ast_unescape_quoted(char *quote_str)
+{
+	int esc_pos;
+	int unesc_pos;
+	int quote_str_len = strlen(quote_str);
+
+	for (esc_pos = 0, unesc_pos = 0;
+		esc_pos < quote_str_len;
+		esc_pos++, unesc_pos++) {
+		if (quote_str[esc_pos] == '\\') {
+			/* at least one more char and current is \\ */
+			esc_pos++;
+			if (esc_pos >= quote_str_len) {
+				break;
+			}
+		}
+
+		quote_str[unesc_pos] = quote_str[esc_pos];
+	}
+	quote_str[unesc_pos] = '\0';
+}
+
 int ast_xml_escape(const char *string, char * const outbuf, const size_t buflen)
 {
 	char *dst = outbuf;
diff --git a/menuselect/menuselect.c b/menuselect/menuselect.c
index c0d73b6..a3f5715 100644
--- a/menuselect/menuselect.c
+++ b/menuselect/menuselect.c
@@ -457,7 +457,7 @@ static int parse_tree(const char *tree_file)
 
 			if (!cat->positive_output) {
 				mem->enabled = 1;
-				if (!(mem->defaultenabled && strcasecmp(mem->defaultenabled, "no"))) {
+				if (!mem->defaultenabled || strcasecmp(mem->defaultenabled, "no")) {
 					mem->was_enabled = 1;
 					print_debug("Enabled %s because the category does not have positive output\n", mem->name);
 				}
diff --git a/res/res_fax_spandsp.c b/res/res_fax_spandsp.c
index 8adf4c7..4271a6c 100644
--- a/res/res_fax_spandsp.c
+++ b/res/res_fax_spandsp.c
@@ -50,7 +50,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 413587 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 423360 $")
 
 #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
 #include <spandsp.h>
@@ -176,8 +176,25 @@ static void set_ecm(t30_state_t *t30_state, struct ast_fax_session_details *deta
 static void session_destroy(struct spandsp_pvt *p)
 {
 	struct ast_frame *f;
+	t30_state_t *t30_to_terminate;
 
-	t30_terminate(p->t30_state);
+	if (p->t30_state) {
+		t30_to_terminate = p->t30_state;
+	} else if (p->ist38) {
+#if SPANDSP_RELEASE_DATE >= 20080725
+		t30_to_terminate = &p->t38_state.t30;
+#else
+		t30_to_terminate = &p->t38_state.t30_state;
+#endif
+	} else {
+#if SPANDSP_RELEASE_DATE >= 20080725
+		t30_to_terminate = &p->fax_state.t30;
+#else
+		t30_to_terminate = &p->fax_state.t30_state;
+#endif
+	}
+
+	t30_terminate(t30_to_terminate);
 	p->isdone = 1;
 
 	ast_timer_close(p->timer);
diff --git a/res/res_jabber.c b/res/res_jabber.c
index ab93f12..778dfad 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -40,7 +40,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 419162 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 426019 $")
 
 #include <ctype.h>
 #include <iksemel.h>
@@ -1282,14 +1282,17 @@ static int aji_start_tls(struct aji_client *client)
 static int aji_tls_handshake(struct aji_client *client)
 {
 	int sock;
+	long ssl_opts;
 
 	ast_debug(1, "Starting TLS handshake\n");
 
 	/* Choose an SSL/TLS protocol version, create SSL_CTX */
-	client->ssl_method = SSLv3_method();
+	client->ssl_method = SSLv23_method();
 	if (!(client->ssl_context = SSL_CTX_new((SSL_METHOD *) client->ssl_method))) {
 		return IKS_NET_TLSFAIL;
 	}
+	ssl_opts = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3;
+	SSL_CTX_set_options(client->ssl_context, ssl_opts);
 
 	/* Create new SSL session */
 	if (!(client->ssl_session = SSL_new(client->ssl_context))) {
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 85a3ccf..776c8ee 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -32,7 +32,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 416440 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 421977 $")
 
 #include <ctype.h>
 #include <signal.h>
@@ -162,6 +162,8 @@ struct moh_files_state {
 	int sample_queue;
 	int pos;
 	int save_pos;
+	int save_total;
+	char name[MAX_MUSICCLASS];
 	char save_pos_filename[PATH_MAX];
 };
 
@@ -234,21 +236,17 @@ static int reload(void);
 #define mohclass_unref(class,string) _mohclass_unref(class, string, __FILE__,__LINE__,__PRETTY_FUNCTION__)
 static struct mohclass *_mohclass_unref(struct mohclass *class, const char *tag, const char *file, int line, const char *funcname)
 {
-	struct mohclass *dup;
-	if ((dup = ao2_find(mohclasses, class, OBJ_POINTER))) {
+	struct mohclass *dup = ao2_callback(mohclasses, OBJ_POINTER, ao2_match_by_addr, class);
+
+	if (dup) {
 		if (__ao2_ref_debug(dup, -1, (char *) tag, (char *) file, line, funcname) == 2) {
-			FILE *ref = fopen("/tmp/refs", "a");
-			if (ref) {
-				fprintf(ref, "%p =1   %s:%d:%s (%s) BAD ATTEMPT!\n", class, file, line, funcname, tag);
-				fclose(ref);
-			}
 			ast_log(LOG_WARNING, "Attempt to unref mohclass %p (%s) when only 1 ref remained, and class is still in a container! (at %s:%d (%s))\n",
 				class, class->name, file, line, funcname);
 		} else {
 			ao2_ref(class, -1);
 		}
 	} else {
-		ao2_t_ref(class, -1, (char *) tag);
+		__ao2_ref_debug(class, -1, (char *) tag, (char *) file, line, funcname);
 	}
 	return NULL;
 }
@@ -456,11 +454,9 @@ static void *moh_files_alloc(struct ast_channel *chan, void *params)
 		}
 	}
 
-	/* class is reffed, so we can safely compare it against the (possibly
-	 * recently unreffed) state->class. The unref was done after the ref
-	 * of class, so we're sure that they won't point to the same memory
-	 * by accident. */
-	if (state->class != class) {
+	/* Resume MOH from where we left off last time or start from scratch? */
+	if (state->save_total != class->total_files || strcmp(state->name, class->name) != 0) {
+		/* Start MOH from scratch. */
 		memset(state, 0, sizeof(*state));
 		if (ast_test_flag(class, MOH_RANDOMIZE) && class->total_files) {
 			state->pos = ast_random() % class->total_files;
@@ -470,6 +466,9 @@ static void *moh_files_alloc(struct ast_channel *chan, void *params)
 	state->class = mohclass_ref(class, "Reffing music class for channel");
 	ast_format_copy(&state->origwfmt, ast_channel_writeformat(chan));
 	ast_format_copy(&state->mohwfmt, ast_channel_writeformat(chan));
+	/* For comparison on restart of MOH (see above) */
+	ast_copy_string(state->name, class->name, sizeof(state->name));
+	state->save_total = class->total_files;
 
 
 	ast_verb(3, "Started music on hold, class '%s', on %s\n", class->name, ast_channel_name(chan));
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 26cc5b2..ec3f147 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -35,7 +35,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 417677 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 423253 $")
 
 #include <sys/time.h>
 #include <signal.h>
@@ -85,9 +85,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision: 417677 $")
 #define MINIMUM_RTP_PORT 1024 /*!< Minimum port number to accept */
 #define MAXIMUM_RTP_PORT 65535 /*!< Maximum port number to accept */
 
-#define DEFAULT_TURN_PORT 34780
+#define DEFAULT_TURN_PORT 3478
 
-#define TURN_ALLOCATION_WAIT_TIME 2000
+#define TURN_STATE_WAIT_TIME 2000
 
 #define RTCP_PT_FUR     192
 #define RTCP_PT_SR      200
@@ -150,20 +150,39 @@ static pj_str_t turnpassword;
 /*! \brief Pool factory used by pjlib to allocate memory. */
 static pj_caching_pool cachingpool;
 
-/*! \brief Pool used by pjlib functions which require memory allocation. */
+/*! \brief Global memory pool for configuration and timers */
 static pj_pool_t *pool;
 
-/*! \brief I/O queue for TURN relay traffic */
-static pj_ioqueue_t *ioqueue;
+/*! \brief Global timer heap */
+static pj_timer_heap_t *timer_heap;
 
-/*! \brief Timer heap for ICE and TURN stuff */
-static pj_timer_heap_t *timerheap;
+/*! \brief Thread executing the timer heap */
+static pj_thread_t *timer_thread;
 
-/*! \brief Worker thread for ICE/TURN */
-static pj_thread_t *thread;
+/*! \brief Used to tell the timer thread to terminate */
+static int timer_terminate;
+
+/*! \brief Structure which contains ioqueue thread information */
+struct ast_rtp_ioqueue_thread {
+	/*! \brief Pool used by the thread */
+	pj_pool_t *pool;
+	/*! \brief The thread handling the queue and timer heap */
+	pj_thread_t *thread;
+	/*! \brief Ioqueue which polls on sockets */
+	pj_ioqueue_t *ioqueue;
+	/*! \brief Timer heap for scheduled items */
+	pj_timer_heap_t *timerheap;
+	/*! \brief Termination request */
+	int terminate;
+	/*! \brief Current number of descriptors being waited on */
+	unsigned int count;
+	/*! \brief Linked list information */
+	AST_LIST_ENTRY(ast_rtp_ioqueue_thread) next;
+};
+
+/*! \brief List of ioqueue threads */
+static AST_LIST_HEAD_STATIC(ioqueues, ast_rtp_ioqueue_thread);
 
-/*! \brief Notification that the ICE/TURN worker thread should stop */
-static int worker_terminate;
 #endif
 
 #define FLAG_3389_WARNING               (1 << 0)
@@ -173,10 +192,10 @@ static int worker_terminate;
 #define FLAG_NEED_MARKER_BIT            (1 << 3)
 #define FLAG_DTMF_COMPENSATE            (1 << 4)
 
-#define TRANSPORT_SOCKET_RTP 1
-#define TRANSPORT_SOCKET_RTCP 2
-#define TRANSPORT_TURN_RTP 3
-#define TRANSPORT_TURN_RTCP 4
+#define TRANSPORT_SOCKET_RTP 0
+#define TRANSPORT_SOCKET_RTCP 1
+#define TRANSPORT_TURN_RTP 2
+#define TRANSPORT_TURN_RTCP 3
 
 /*! \brief RTP learning mode tracking information */
 struct rtp_learning_info {
@@ -277,7 +296,13 @@ struct ast_rtp {
 	pj_turn_state_t turn_state; /*!< Current state of the TURN relay session */
 	ast_cond_t cond;            /*!< Condition for signaling */
 	unsigned int passthrough:1; /*!< Bit to indicate that the received packet should be passed through */
+	unsigned int rtp_passthrough:1; /*!< Bit to indicate that TURN RTP should be passed through */
+	unsigned int rtcp_passthrough:1; /*!< Bit to indicate that TURN RTCP should be passed through */
 	unsigned int ice_port;      /*!< Port that ICE was started with if it was previously started */
+	struct ast_sockaddr rtp_loop; /*!< Loopback address for forwarding RTP from TURN */
+	struct ast_sockaddr rtcp_loop; /*!< Loopback address for forwarding RTCP from TURN */
+
+	struct ast_rtp_ioqueue_thread *ioqueue; /*!< The ioqueue thread handling us */
 
 	char remote_ufrag[256];  /*!< The remote ICE username */
 	char remote_passwd[256]; /*!< The remote ICE password */
@@ -521,7 +546,7 @@ static void pj_thread_register_check(void)
 }
 
 /*! \brief Helper function which updates an ast_sockaddr with the candidate used for the component */
-static void update_address_with_ice_candidate(struct ast_rtp *rtp, int component, struct ast_sockaddr *cand_address)
+static void update_address_with_ice_candidate(struct ast_rtp *rtp, enum ast_rtp_ice_component_type component, struct ast_sockaddr *cand_address)
 {
 	char address[PJ_INET6_ADDRSTRLEN];
 
@@ -533,6 +558,18 @@ static void update_address_with_ice_candidate(struct ast_rtp *rtp, int component
 	ast_sockaddr_set_port(cand_address, pj_sockaddr_get_port(&rtp->ice->comp[component - 1].valid_check->rcand->addr));
 }
 
+/*! \brief Helper function which sets up channel binding on a TURN session if applicable */
+static void turn_enable_bind_channel(struct ast_rtp *rtp, pj_turn_sock *turn, enum ast_rtp_ice_component_type component, int transport)
+{
+	if (!rtp->ice || !turn || (component < 1) || !rtp->ice->comp[component - 1].valid_check ||
+		(rtp->ice->comp[component - 1].valid_check->lcand->transport_id != transport)) {
+		return;
+	}
+
+	pj_turn_sock_bind_channel(turn, &rtp->ice->comp[component - 1].valid_check->rcand->addr,
+		sizeof(rtp->ice->comp[component - 1].valid_check->rcand->addr));
+}
+
 static int ice_create(struct ast_rtp_instance *instance, struct ast_sockaddr *addr,
 	int port, int replace);
 
@@ -666,7 +703,7 @@ static void ast_rtp_ice_start(struct ast_rtp_instance *instance)
 	if (pj_ice_sess_create_check_list(rtp->ice, &ufrag, &passwd, ao2_container_count(rtp->ice_active_remote_candidates), &candidates[0]) == PJ_SUCCESS) {
 		ast_test_suite_event_notify("ICECHECKLISTCREATE", "Result: SUCCESS");
 		pj_ice_sess_start_check(rtp->ice);
-		pj_timer_heap_poll(timerheap, NULL);
+		pj_timer_heap_poll(timer_heap, NULL);
 		rtp->strict_rtp_state = STRICT_RTP_OPEN;
 		return;
 	}
@@ -792,6 +829,325 @@ static void ast_rtp_ice_add_cand(struct ast_rtp *rtp, unsigned comp_id, unsigned
 	ao2_ref(candidate, -1);
 }
 
+static void ast_rtp_on_turn_rx_rtp_data(pj_turn_sock *turn_sock, void *pkt, unsigned pkt_len, const pj_sockaddr_t *peer_addr, unsigned addr_len)
+{
+	struct ast_rtp_instance *instance = pj_turn_sock_get_user_data(turn_sock);
+	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
+	pj_status_t status;
+
+	status = pj_ice_sess_on_rx_pkt(rtp->ice, AST_RTP_ICE_COMPONENT_RTP, TRANSPORT_TURN_RTP, pkt, pkt_len, peer_addr,
+		addr_len);
+	if (status != PJ_SUCCESS) {
+		char buf[100];
+
+		pj_strerror(status, buf, sizeof(buf));
+		ast_log(LOG_WARNING, "PJ ICE Rx error status code: %d '%s'.\n",
+			(int)status, buf);
+		return;
+	}
+	if (!rtp->rtp_passthrough) {
+		return;
+	}
+	rtp->rtp_passthrough = 0;
+
+	ast_sendto(rtp->s, pkt, pkt_len, 0, &rtp->rtp_loop);
+}
+
+static void ast_rtp_on_turn_rtp_state(pj_turn_sock *turn_sock, pj_turn_state_t old_state, pj_turn_state_t new_state)
+{
+	struct ast_rtp_instance *instance = pj_turn_sock_get_user_data(turn_sock);
+	struct ast_rtp *rtp;
+
+	/* If this is a leftover from an already notified RTP instance just ignore the state change */
+	if (!instance) {
+		return;
+	}
+
+	rtp = ast_rtp_instance_get_data(instance);
+
+	/* We store the new state so the other thread can actually handle it */
+	ast_mutex_lock(&rtp->lock);
+	rtp->turn_state = new_state;
+	ast_cond_signal(&rtp->cond);
+
+	if (new_state == PJ_TURN_STATE_DESTROYING) {
+		pj_turn_sock_set_user_data(rtp->turn_rtp, NULL);
+		rtp->turn_rtp = NULL;
+	}
+
+	ast_mutex_unlock(&rtp->lock);
+}
+
+/* RTP TURN Socket interface declaration */
+static pj_turn_sock_cb ast_rtp_turn_rtp_sock_cb = {
+	.on_rx_data = ast_rtp_on_turn_rx_rtp_data,
+	.on_state = ast_rtp_on_turn_rtp_state,
+};
+
+static void ast_rtp_on_turn_rx_rtcp_data(pj_turn_sock *turn_sock, void *pkt, unsigned pkt_len, const pj_sockaddr_t *peer_addr, unsigned addr_len)
+{
+	struct ast_rtp_instance *instance = pj_turn_sock_get_user_data(turn_sock);
+	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
+	pj_status_t status;
+
+	status = pj_ice_sess_on_rx_pkt(rtp->ice, AST_RTP_ICE_COMPONENT_RTCP, TRANSPORT_TURN_RTCP, pkt, pkt_len, peer_addr,
+		addr_len);
+	if (status != PJ_SUCCESS) {
+		char buf[100];
+
+		pj_strerror(status, buf, sizeof(buf));
+		ast_log(LOG_WARNING, "PJ ICE Rx error status code: %d '%s'.\n",
+			(int)status, buf);
+		return;
+	}
+	if (!rtp->rtcp_passthrough) {
+		return;
+	}
+	rtp->rtcp_passthrough = 0;
+
+	ast_sendto(rtp->rtcp->s, pkt, pkt_len, 0, &rtp->rtcp_loop);
+}
+
+static void ast_rtp_on_turn_rtcp_state(pj_turn_sock *turn_sock, pj_turn_state_t old_state, pj_turn_state_t new_state)
+{
+	struct ast_rtp_instance *instance = pj_turn_sock_get_user_data(turn_sock);
+	struct ast_rtp *rtp = NULL;
+
+	/* If this is a leftover from an already destroyed RTP instance just ignore the state change */
+	if (!instance) {
+		return;
+	}
+
+	rtp = ast_rtp_instance_get_data(instance);
+
+	/* We store the new state so the other thread can actually handle it */
+	ast_mutex_lock(&rtp->lock);
+	rtp->turn_state = new_state;
+	ast_cond_signal(&rtp->cond);
+
+	if (new_state == PJ_TURN_STATE_DESTROYING) {
+		pj_turn_sock_set_user_data(rtp->turn_rtcp, NULL);
+		rtp->turn_rtcp = NULL;
+	}
+
+	ast_mutex_unlock(&rtp->lock);
+}
+
+/* RTCP TURN Socket interface declaration */
+static pj_turn_sock_cb ast_rtp_turn_rtcp_sock_cb = {
+	.on_rx_data = ast_rtp_on_turn_rx_rtcp_data,
+	.on_state = ast_rtp_on_turn_rtcp_state,
+};
+
+/*! \brief Worker thread for ioqueue and timerheap */
+static int ioqueue_worker_thread(void *data)
+{
+	struct ast_rtp_ioqueue_thread *ioqueue = data;
+
+	while (!ioqueue->terminate) {
+		const pj_time_val delay = {0, 10};
+
+		pj_ioqueue_poll(ioqueue->ioqueue, &delay);
+
+		pj_timer_heap_poll(ioqueue->timerheap, NULL);
+	}
+
+	return 0;
+}
+
+/*! \brief Destroyer for ioqueue thread */
+static void rtp_ioqueue_thread_destroy(struct ast_rtp_ioqueue_thread *ioqueue)
+{
+	if (ioqueue->thread) {
+		ioqueue->terminate = 1;
+		pj_thread_join(ioqueue->thread);
+		pj_thread_destroy(ioqueue->thread);
+	}
+
+	pj_pool_release(ioqueue->pool);
+	ast_free(ioqueue);
+}
+
+/*! \brief Removal function for ioqueue thread, determines if it should be terminated and destroyed */
+static void rtp_ioqueue_thread_remove(struct ast_rtp_ioqueue_thread *ioqueue)
+{
+	int destroy = 0;
+
+	/* If nothing is using this ioqueue thread destroy it */
+	AST_LIST_LOCK(&ioqueues);
+	if ((ioqueue->count - 2) == 0) {
+		destroy = 1;
+		AST_LIST_REMOVE(&ioqueues, ioqueue, next);
+	}
+	AST_LIST_UNLOCK(&ioqueues);
+
+	if (!destroy) {
+		return;
+	}
+
+	rtp_ioqueue_thread_destroy(ioqueue);
+}
+
+/*! \brief Finder and allocator for an ioqueue thread */
+static struct ast_rtp_ioqueue_thread *rtp_ioqueue_thread_get_or_create(void)
+{
+	struct ast_rtp_ioqueue_thread *ioqueue;
+	pj_lock_t *lock;
+
+	AST_LIST_LOCK(&ioqueues);
+
+	/* See if an ioqueue thread exists that can handle more */
+	AST_LIST_TRAVERSE(&ioqueues, ioqueue, next) {
+		if ((ioqueue->count + 2) < PJ_IOQUEUE_MAX_HANDLES) {
+			break;
+		}
+	}
+
+	/* If we found one bump it up and return it */
+	if (ioqueue) {
+		ioqueue->count += 2;
+		goto end;
+	}
+
+	ioqueue = ast_calloc(1, sizeof(*ioqueue));
+	if (!ioqueue) {
+		goto end;
+	}
+
+	ioqueue->pool = pj_pool_create(&cachingpool.factory, "rtp", 512, 512, NULL);
+
+	/* We use a timer on the ioqueue thread for TURN so that two threads aren't operating
+	 * on a session at the same time
+	 */
+	if (pj_timer_heap_create(ioqueue->pool, 4, &ioqueue->timerheap) != PJ_SUCCESS) {
+		goto fatal;
+	}
+
+	if (pj_lock_create_recursive_mutex(ioqueue->pool, "rtp%p", &lock) != PJ_SUCCESS) {
+		goto fatal;
+	}
+
+	pj_timer_heap_set_lock(ioqueue->timerheap, lock, PJ_TRUE);
+
+	if (pj_ioqueue_create(ioqueue->pool, PJ_IOQUEUE_MAX_HANDLES, &ioqueue->ioqueue) != PJ_SUCCESS) {
+		goto fatal;
+	}
+
+	if (pj_thread_create(ioqueue->pool, "ice", &ioqueue_worker_thread, ioqueue, 0, 0, &ioqueue->thread) != PJ_SUCCESS) {
+		goto fatal;
+	}
+
+	AST_LIST_INSERT_HEAD(&ioqueues, ioqueue, next);
+
+	/* Since this is being returned to an active session the count always starts at 2 */
+	ioqueue->count = 2;
+
+	goto end;
+
+fatal:
+	rtp_ioqueue_thread_destroy(ioqueue);
+	ioqueue = NULL;
+
+end:
+	AST_LIST_UNLOCK(&ioqueues);
+	return ioqueue;
+}
+
+static void ast_rtp_ice_turn_request(struct ast_rtp_instance *instance, enum ast_rtp_ice_component_type component,
+		pj_turn_tp_type conn_type, const char *server, unsigned int port, const char *username, const char *password)
+{
+	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
+	pj_turn_sock **turn_sock;
+	const pj_turn_sock_cb *turn_cb;
+	int conn_transport;
+	pj_stun_auth_cred cred = { 0, };
+	pj_str_t turn_addr;
+	struct ast_sockaddr addr = { { 0, } };
+	pj_stun_config stun_config;
+	struct timeval wait = ast_tvadd(ast_tvnow(), ast_samp2tv(TURN_STATE_WAIT_TIME, 1000));
+	struct timespec ts = { .tv_sec = wait.tv_sec, .tv_nsec = wait.tv_usec * 1000, };
+	pj_turn_session_info info;
+	struct ast_sockaddr local, loop;
+
+	ast_rtp_instance_get_local_address(instance, &local);
+	if (ast_sockaddr_is_ipv4(&local)) {
+		ast_sockaddr_parse(&loop, "127.0.0.1", PARSE_PORT_FORBID);
+	} else {
+		ast_sockaddr_parse(&loop, "::1", PARSE_PORT_FORBID);
+	}
+
+	/* Determine what component we are requesting a TURN session for */
+	if (component == AST_RTP_ICE_COMPONENT_RTP) {
+		turn_sock = &rtp->turn_rtp;
+		turn_cb = &ast_rtp_turn_rtp_sock_cb;
+		conn_transport = TRANSPORT_TURN_RTP;
+		ast_sockaddr_set_port(&loop, ast_sockaddr_port(&local));
+	} else if (component == AST_RTP_ICE_COMPONENT_RTCP) {
+		turn_sock = &rtp->turn_rtcp;
+		turn_cb = &ast_rtp_turn_rtcp_sock_cb;
+		conn_transport = TRANSPORT_TURN_RTCP;
+		ast_sockaddr_set_port(&loop, ast_sockaddr_port(&rtp->rtcp->us));
+	} else {
+		return;
+	}
+
+	ast_sockaddr_parse(&addr, server, PARSE_PORT_FORBID);
+
+	ast_mutex_lock(&rtp->lock);
+	if (*turn_sock) {
+		pj_turn_sock_destroy(*turn_sock);
+		rtp->turn_state = PJ_TURN_STATE_NULL;
+		while (rtp->turn_state != PJ_TURN_STATE_DESTROYING) {
+			ast_cond_timedwait(&rtp->cond, &rtp->lock, &ts);
+		}
+	}
+	ast_mutex_unlock(&rtp->lock);
+
+	if (component == AST_RTP_ICE_COMPONENT_RTP && !rtp->ioqueue) {
+		rtp->ioqueue = rtp_ioqueue_thread_get_or_create();
+		if (!rtp->ioqueue) {
+			return;
+		}
+	}
+
+	pj_stun_config_init(&stun_config, &cachingpool.factory, 0, rtp->ioqueue->ioqueue, rtp->ioqueue->timerheap);
+
+	if (pj_turn_sock_create(&stun_config, ast_sockaddr_is_ipv4(&addr) ? pj_AF_INET() : pj_AF_INET6(), conn_type,
+		turn_cb, NULL, instance, turn_sock) != PJ_SUCCESS) {
+		ast_log(LOG_WARNING, "Could not create a TURN client socket\n");
+		return;
+	}
+
+	cred.type = PJ_STUN_AUTH_CRED_STATIC;
+	pj_strset2(&cred.data.static_cred.username, (char*)username);
+	cred.data.static_cred.data_type = PJ_STUN_PASSWD_PLAIN;
+	pj_strset2(&cred.data.static_cred.data, (char*)password);
+
+	/* Because the TURN socket is asynchronous but we are synchronous we need to wait until it is done */
+	ast_mutex_lock(&rtp->lock);
+	pj_turn_sock_alloc(*turn_sock, pj_cstr(&turn_addr, server), port, NULL, &cred, NULL);
+	while (rtp->turn_state < PJ_TURN_STATE_READY) {
+		ast_cond_timedwait(&rtp->cond, &rtp->lock, &ts);
+	}
+	ast_mutex_unlock(&rtp->lock);
+
+	/* If a TURN session was allocated add it as a candidate */
+	if (rtp->turn_state != PJ_TURN_STATE_READY) {
+		return;
+	}
+
+	pj_turn_sock_get_info(*turn_sock, &info);
+
+	ast_rtp_ice_add_cand(rtp, component, conn_transport, PJ_ICE_CAND_TYPE_RELAYED, 65535, &info.relay_addr,
+		&info.relay_addr, NULL, pj_sockaddr_get_len(&info.relay_addr));
+
+	if (component == AST_RTP_ICE_COMPONENT_RTP) {
+		ast_sockaddr_copy(&rtp->rtp_loop, &loop);
+	} else if (component == AST_RTP_ICE_COMPONENT_RTCP) {
+		ast_sockaddr_copy(&rtp->rtcp_loop, &loop);
+	}
+}
+
 static char *generate_random_string(char *buf, size_t size)
 {
         long val[4];
@@ -1233,6 +1589,22 @@ static void ast_rtp_on_ice_complete(pj_ice_sess *ice, pj_status_t status)
 	struct ast_rtp_instance *instance = ice->user_data;
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
 
+	if (status == PJ_SUCCESS) {
+		struct ast_sockaddr remote_address;
+
+		/* Symmetric RTP must be disabled for the remote address to not get overwritten */
+		ast_rtp_instance_set_prop(instance, AST_RTP_PROPERTY_NAT, 0);
+
+		update_address_with_ice_candidate(rtp, AST_RTP_ICE_COMPONENT_RTP, &remote_address);
+		ast_rtp_instance_set_remote_address(instance, &remote_address);
+		turn_enable_bind_channel(rtp, rtp->turn_rtp, AST_RTP_ICE_COMPONENT_RTP, TRANSPORT_TURN_RTP);
+
+		if (rtp->rtcp) {
+			update_address_with_ice_candidate(rtp, AST_RTP_ICE_COMPONENT_RTCP, &rtp->rtcp->them);
+			turn_enable_bind_channel(rtp, rtp->turn_rtcp, AST_RTP_ICE_COMPONENT_RTCP, TRANSPORT_TURN_RTCP);
+		}
+	}
+
 #ifdef HAVE_OPENSSL_SRTP
 	dtls_perform_handshake(instance, &rtp->dtls, 0);
 
@@ -1256,7 +1628,13 @@ static void ast_rtp_on_ice_rx_data(pj_ice_sess *ice, unsigned comp_id, unsigned
 
 	/* Instead of handling the packet here (which really doesn't work with our architecture) we set a bit to indicate that it should be handled after pj_ice_sess_on_rx_pkt
 	 * returns */
-	rtp->passthrough = 1;
+	if (transport_id == TRANSPORT_SOCKET_RTP || transport_id == TRANSPORT_SOCKET_RTCP) {
+		rtp->passthrough = 1;
+	} else if (transport_id == TRANSPORT_TURN_RTP) {
+		rtp->rtp_passthrough = 1;
+	} else if (transport_id == TRANSPORT_TURN_RTCP) {
+		rtp->rtcp_passthrough = 1;
+	}
 }
 
 static pj_status_t ast_rtp_on_ice_tx_pkt(pj_ice_sess *ice, unsigned comp_id, unsigned transport_id, const void *pkt, pj_size_t size, const pj_sockaddr_t *dst_addr, unsigned dst_addr_len)
@@ -1302,106 +1680,20 @@ static pj_ice_sess_cb ast_rtp_ice_sess_cb = {
 	.on_tx_pkt = ast_rtp_on_ice_tx_pkt,
 };
 
-static void ast_rtp_on_turn_rx_rtp_data(pj_turn_sock *turn_sock, void *pkt, unsigned pkt_len, const pj_sockaddr_t *peer_addr, unsigned addr_len)
-{
-	struct ast_rtp_instance *instance = pj_turn_sock_get_user_data(turn_sock);
-	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
-	struct ast_sockaddr dest = { { 0, }, };
-
-	ast_rtp_instance_get_local_address(instance, &dest);
-
-	ast_sendto(rtp->s, pkt, pkt_len, 0, &dest);
-}
-
-static void ast_rtp_on_turn_rtp_state(pj_turn_sock *turn_sock, pj_turn_state_t old_state, pj_turn_state_t new_state)
-{
-	struct ast_rtp_instance *instance = pj_turn_sock_get_user_data(turn_sock);
-	struct ast_rtp *rtp = NULL;
-
-	/* If this is a leftover from an already destroyed RTP instance just ignore the state change */
-	if (!instance) {
-		return;
-	}
-
-	rtp = ast_rtp_instance_get_data(instance);
-
-	/* If the TURN session is being destroyed we need to remove it from the RTP instance */
-	if (new_state == PJ_TURN_STATE_DESTROYING) {
-		rtp->turn_rtp = NULL;
-		return;
-	}
-
-	/* We store the new state so the other thread can actually handle it */
-	ast_mutex_lock(&rtp->lock);
-	rtp->turn_state = new_state;
-
-	/* If this is a state that the main thread should be notified about do so */
-	if (new_state == PJ_TURN_STATE_READY || new_state == PJ_TURN_STATE_DEALLOCATING || new_state == PJ_TURN_STATE_DEALLOCATED) {
-		ast_cond_signal(&rtp->cond);
-	}
-
-	ast_mutex_unlock(&rtp->lock);
-}
-
-/* RTP TURN Socket interface declaration */
-static pj_turn_sock_cb ast_rtp_turn_rtp_sock_cb = {
-	.on_rx_data = ast_rtp_on_turn_rx_rtp_data,
-	.on_state = ast_rtp_on_turn_rtp_state,
-};
-
-static void ast_rtp_on_turn_rx_rtcp_data(pj_turn_sock *turn_sock, void *pkt, unsigned pkt_len, const pj_sockaddr_t *peer_addr, unsigned addr_len)
-{
-	struct ast_rtp_instance *instance = pj_turn_sock_get_user_data(turn_sock);
-	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
-
-	ast_sendto(rtp->rtcp->s, pkt, pkt_len, 0, &rtp->rtcp->us);
-}
-
-static void ast_rtp_on_turn_rtcp_state(pj_turn_sock *turn_sock, pj_turn_state_t old_state, pj_turn_state_t new_state)
+/*! \brief Worker thread for timerheap */
+static int timer_worker_thread(void *data)
 {
-	struct ast_rtp_instance *instance = pj_turn_sock_get_user_data(turn_sock);
-	struct ast_rtp *rtp = NULL;
-
-	/* If this is a leftover from an already destroyed RTP instance just ignore the state change */
-	if (!instance) {
-		return;
-	}
-
-	rtp = ast_rtp_instance_get_data(instance);
-
-	/* If the TURN session is being destroyed we need to remove it from the RTP instance */
-	if (new_state == PJ_TURN_STATE_DESTROYING) {
-		rtp->turn_rtcp = NULL;
-		return;
-	}
+	pj_ioqueue_t *ioqueue;
 
-	/* We store the new state so the other thread can actually handle it */
-	ast_mutex_lock(&rtp->lock);
-	rtp->turn_state = new_state;
-
-	/* If this is a state that the main thread should be notified about do so */
-	if (new_state == PJ_TURN_STATE_READY || new_state == PJ_TURN_STATE_DEALLOCATING || new_state == PJ_TURN_STATE_DEALLOCATED) {
-		ast_cond_signal(&rtp->cond);
+	if (pj_ioqueue_create(pool, 1, &ioqueue) != PJ_SUCCESS) {
+		return -1;
 	}
 
-       ast_mutex_unlock(&rtp->lock);
-}
-
-/* RTCP TURN Socket interface declaration */
-static pj_turn_sock_cb ast_rtp_turn_rtcp_sock_cb = {
-	.on_rx_data = ast_rtp_on_turn_rx_rtcp_data,
-	.on_state = ast_rtp_on_turn_rtcp_state,
-};
-
-/*! \brief Worker thread for I/O queue and timerheap */
-static int ice_worker_thread(void *data)
-{
-	while (!worker_terminate) {
+	while (!timer_terminate) {
 		const pj_time_val delay = {0, 10};
 
+		pj_timer_heap_poll(timer_heap, NULL);
 		pj_ioqueue_poll(ioqueue, &delay);
-
-		pj_timer_heap_poll(timerheap, NULL);
 	}
 
 	return 0;
@@ -1690,6 +1982,9 @@ static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t s
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
 	struct ast_srtp *srtp = ast_rtp_instance_get_srtp(instance);
 	char *in = buf;
+#ifdef USE_PJPROJECT
+	struct ast_sockaddr *loop = rtcp ? &rtp->rtcp_loop : &rtp->rtp_loop;
+#endif
 
 	if ((len = ast_recvfrom(rtcp ? rtp->rtcp->s : rtp->s, buf, size, flags, sa)) < 0) {
 	   return len;
@@ -1745,7 +2040,16 @@ static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t s
 #endif
 
 #ifdef USE_PJPROJECT
-	if (rtp->ice) {
+	if (!ast_sockaddr_isnull(loop) && !ast_sockaddr_cmp(loop, sa)) {
+		/* ICE traffic will have been handled in the TURN callback, so skip it but update the address
+		 * so it reflects the actual source and not the loopback
+		 */
+		if (rtcp) {
+			ast_sockaddr_copy(sa, &rtp->rtcp->them);
+		} else {
+			ast_rtp_instance_get_remote_address(instance, sa);
+		}
+	} else if (rtp->ice) {
 		pj_str_t combined = pj_str(ast_sockaddr_stringify(sa));
 		pj_sockaddr address;
 		pj_status_t status;
@@ -1762,7 +2066,7 @@ static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t s
 
 			pj_strerror(status, buf, sizeof(buf));
 			ast_log(LOG_WARNING, "PJ ICE Rx error status code: %d '%s'.\n",
-				(int) status, buf);
+				(int)status, buf);
 			return -1;
 		}
 		if (!rtp->passthrough) {
@@ -1931,7 +2235,7 @@ static int rtp_learning_rtp_seq_update(struct rtp_learning_info *info, uint16_t
 
 #ifdef USE_PJPROJECT
 static void rtp_add_candidates_to_ice(struct ast_rtp_instance *instance, struct ast_rtp *rtp, struct ast_sockaddr *addr, int port, int component,
-				      int transport, const pj_turn_sock_cb *turn_cb, pj_turn_sock **turn_sock)
+				      int transport)
 {
 	pj_sockaddr address[16];
 	unsigned int count = PJ_ARRAY_SIZE(address), pos = 0;
@@ -1970,38 +2274,9 @@ static void rtp_add_candidates_to_ice(struct ast_rtp_instance *instance, struct
 	}
 
 	/* If configured to use a TURN relay create a session and allocate */
-	if (pj_strlen(&turnaddr) && pj_turn_sock_create(&rtp->ice->stun_cfg, ast_sockaddr_is_ipv4(addr) ? pj_AF_INET() : pj_AF_INET6(), PJ_TURN_TP_TCP,
-							turn_cb, NULL, instance, turn_sock) == PJ_SUCCESS) {
-		pj_stun_auth_cred cred = { 0, };
-		struct timeval wait = ast_tvadd(ast_tvnow(), ast_samp2tv(TURN_ALLOCATION_WAIT_TIME, 1000));
-		struct timespec ts = { .tv_sec = wait.tv_sec, .tv_nsec = wait.tv_usec * 1000, };
-
-		cred.type = PJ_STUN_AUTH_CRED_STATIC;
-		cred.data.static_cred.username = turnusername;
-		cred.data.static_cred.data_type = PJ_STUN_PASSWD_PLAIN;
-		cred.data.static_cred.data = turnpassword;
-
-		/* Because the TURN socket is asynchronous but we are synchronous we need to wait until it is done */
-		ast_mutex_lock(&rtp->lock);
-		pj_turn_sock_alloc(*turn_sock, &turnaddr, turnport, NULL, &cred, NULL);
-		ast_cond_timedwait(&rtp->cond, &rtp->lock, &ts);
-		ast_mutex_unlock(&rtp->lock);
-
-		/* If a TURN session was allocated add it as a candidate */
-		if (rtp->turn_state == PJ_TURN_STATE_READY) {
-			pj_turn_session_info info;
-
-			pj_turn_sock_get_info(*turn_sock, &info);
-
-			if (transport == TRANSPORT_SOCKET_RTP) {
-				transport = TRANSPORT_TURN_RTP;
-			} else if (transport == TRANSPORT_SOCKET_RTCP) {
-				transport = TRANSPORT_TURN_RTCP;
-			}
-
-			ast_rtp_ice_add_cand(rtp, component, transport, PJ_ICE_CAND_TYPE_RELAYED, 65535, &info.relay_addr, &info.relay_addr,
-					     NULL, pj_sockaddr_get_len(&info.relay_addr));
-		}
+	if (pj_strlen(&turnaddr)) {
+		ast_rtp_ice_turn_request(instance, component, PJ_TURN_TP_TCP, pj_strbuf(&turnaddr), turnport,
+			pj_strbuf(&turnusername), pj_strbuf(&turnpassword));
 	}
 }
 #endif
@@ -2060,7 +2335,7 @@ static int ice_create(struct ast_rtp_instance *instance, struct ast_sockaddr *ad
 
 	pj_thread_register_check();
 
-	pj_stun_config_init(&stun_config, &cachingpool.factory, 0, ioqueue, timerheap);
+	pj_stun_config_init(&stun_config, &cachingpool.factory, 0, NULL, timer_heap);
 
 	ufrag = pj_str(rtp->local_ufrag);
 	passwd = pj_str(rtp->local_passwd);
@@ -2073,14 +2348,14 @@ static int ice_create(struct ast_rtp_instance *instance, struct ast_sockaddr *ad
 
 		/* Add all of the available candidates to the ICE session */
 		rtp_add_candidates_to_ice(instance, rtp, addr, port, AST_RTP_ICE_COMPONENT_RTP,
-			TRANSPORT_SOCKET_RTP, &ast_rtp_turn_rtp_sock_cb, &rtp->turn_rtp);
+			TRANSPORT_SOCKET_RTP);
 
 		/* Only add the RTCP candidates to ICE when replacing the session. New sessions
 		 * handle this in a separate part of the setup phase */
 		if (replace && rtp->rtcp) {
 			rtp_add_candidates_to_ice(instance, rtp, &rtp->rtcp->us,
 				ast_sockaddr_port(&rtp->rtcp->us), AST_RTP_ICE_COMPONENT_RTCP,
-				TRANSPORT_SOCKET_RTCP, &ast_rtp_turn_rtcp_sock_cb, &rtp->turn_rtcp);
+				TRANSPORT_SOCKET_RTCP);
 		}
 
 		return 0;
@@ -2187,6 +2462,10 @@ static int ast_rtp_new(struct ast_rtp_instance *instance,
 static int ast_rtp_destroy(struct ast_rtp_instance *instance)
 {
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
+#ifdef USE_PJPROJECT
+	struct timeval wait = ast_tvadd(ast_tvnow(), ast_samp2tv(TURN_STATE_WAIT_TIME, 1000));
+	struct timespec ts = { .tv_sec = wait.tv_sec, .tv_nsec = wait.tv_usec * 1000, };
+#endif
 
 	/* Destroy the smoother that was smoothing out audio if present */
 	if (rtp->smoother) {
@@ -2223,21 +2502,33 @@ static int ast_rtp_destroy(struct ast_rtp_instance *instance)
 #ifdef USE_PJPROJECT
 	pj_thread_register_check();
 
-	/* Destroy the ICE session if being used */
-	if (rtp->ice) {
-		pj_ice_sess_destroy(rtp->ice);
-	}
-
 	/* Destroy the RTP TURN relay if being used */
+	ast_mutex_lock(&rtp->lock);
 	if (rtp->turn_rtp) {
-		pj_turn_sock_set_user_data(rtp->turn_rtp, NULL);
 		pj_turn_sock_destroy(rtp->turn_rtp);
+		rtp->turn_state = PJ_TURN_STATE_NULL;
+		while (rtp->turn_state != PJ_TURN_STATE_DESTROYING) {
+			ast_cond_timedwait(&rtp->cond, &rtp->lock, &ts);
+		}
 	}
 
 	/* Destroy the RTCP TURN relay if being used */
 	if (rtp->turn_rtcp) {
-		pj_turn_sock_set_user_data(rtp->turn_rtcp, NULL);
 		pj_turn_sock_destroy(rtp->turn_rtcp);
+		rtp->turn_state = PJ_TURN_STATE_NULL;
+		while (rtp->turn_state != PJ_TURN_STATE_DESTROYING) {
+			ast_cond_timedwait(&rtp->cond, &rtp->lock, &ts);
+		}
+	}
+	ast_mutex_unlock(&rtp->lock);
+
+	if (rtp->ioqueue) {
+		rtp_ioqueue_thread_remove(rtp->ioqueue);
+	}
+
+	/* Destroy the ICE session if being used */
+	if (rtp->ice) {
+		pj_ice_sess_destroy(rtp->ice);
 	}
 
 	/* Destroy any candidates */
@@ -2340,9 +2631,6 @@ static int ast_rtp_dtmf_begin(struct ast_rtp_instance *instance, char digit)
 				ast_sockaddr_stringify(&remote_address),
 				strerror(errno));
 		}
-#ifdef USE_PJPROJECT
-		update_address_with_ice_candidate(rtp, AST_RTP_ICE_COMPONENT_RTP, &remote_address);
-#endif
 		if (rtp_debug_test_addr(&remote_address)) {
 			ast_verbose("Sent RTP DTMF packet to %s%s (type %-2.2d, seq %-6.6d, ts %-6.6u, len %-6.6d)\n",
 				    ast_sockaddr_stringify(&remote_address),
@@ -2392,10 +2680,6 @@ static int ast_rtp_dtmf_continuation(struct ast_rtp_instance *instance)
 			strerror(errno));
 	}
 
-#ifdef USE_PJPROJECT
-	update_address_with_ice_candidate(rtp, AST_RTP_ICE_COMPONENT_RTP, &remote_address);
-#endif
-
 	if (rtp_debug_test_addr(&remote_address)) {
 		ast_verbose("Sent RTP DTMF packet to %s%s (type %-2.2d, seq %-6.6d, ts %-6.6u, len %-6.6d)\n",
 			    ast_sockaddr_stringify(&remote_address),
@@ -2470,10 +2754,6 @@ static int ast_rtp_dtmf_end_with_duration(struct ast_rtp_instance *instance, cha
 				strerror(errno));
 		}
 
-#ifdef USE_PJPROJECT
-		update_address_with_ice_candidate(rtp, AST_RTP_ICE_COMPONENT_RTP, &remote_address);
-#endif
-
 		if (rtp_debug_test_addr(&remote_address)) {
 			ast_verbose("Sent RTP DTMF packet to %s%s (type %-2.2d, seq %-6.6d, ts %-6.6u, len %-6.6d)\n",
 				    ast_sockaddr_stringify(&remote_address),
@@ -2636,10 +2916,6 @@ static int ast_rtcp_write_rr(struct ast_rtp_instance *instance)
 
 	rtp->rtcp->rr_count++;
 
-#ifdef USE_PJPROJECT
-	update_address_with_ice_candidate(rtp, AST_RTP_ICE_COMPONENT_RTCP, &remote_address);
-#endif
-
 	if (rtcp_debug_test_addr(&remote_address)) {
 		ast_verbose("\n* Sending RTCP RR to %s%s\n"
 			"  Our SSRC: %u\nTheir SSRC: %u\niFraction lost: %d\nCumulative loss: %u\n"
@@ -2749,10 +3025,6 @@ static int ast_rtcp_write_sr(struct ast_rtp_instance *instance)
 
 	rtp->rtcp->lastsrtxcount = rtp->txcount;
 
-#ifdef USE_PJPROJECT
-	update_address_with_ice_candidate(rtp, AST_RTP_ICE_COMPONENT_RTCP, &remote_address);
-#endif
-
 	if (rtcp_debug_test_addr(&rtp->rtcp->them)) {
 		ast_verbose("* Sent RTCP SR to %s%s\n", ast_sockaddr_stringify(&remote_address), ice ? " (via ICE)" : "");
 		ast_verbose("  Our SSRC: %u\n", rtp->ssrc);
@@ -2940,10 +3212,6 @@ static int ast_rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame
 			}
 		}
 
-#ifdef USE_PJPROJECT
-		update_address_with_ice_candidate(rtp, AST_RTP_ICE_COMPONENT_RTP, &remote_address);
-#endif
-
 		if (rtp_debug_test_addr(&remote_address)) {
 			ast_verbose("Sent RTP packet to      %s%s (type %-2.2d, seq %-6.6d, ts %-6.6u, len %-6.6d)\n",
 				    ast_sockaddr_stringify(&remote_address),
@@ -3821,10 +4089,6 @@ static int bridge_p2p_rtp_write(struct ast_rtp_instance *instance, unsigned int
 		return 0;
 	}
 
-#ifdef USE_PJPROJECT
-	update_address_with_ice_candidate(rtp, AST_RTP_ICE_COMPONENT_RTP, &remote_address);
-#endif
-
 	if (rtp_debug_test_addr(&remote_address)) {
 		ast_verbose("Sent RTP P2P packet to %s%s (type %-2.2d, len %-6.6d)\n",
 			    ast_sockaddr_stringify(&remote_address),
@@ -4282,8 +4546,7 @@ static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_pro
 
 #ifdef USE_PJPROJECT
 			if (rtp->ice) {
-				rtp_add_candidates_to_ice(instance, rtp, &rtp->rtcp->us, ast_sockaddr_port(&rtp->rtcp->us), AST_RTP_ICE_COMPONENT_RTCP, TRANSPORT_SOCKET_RTCP,
-							  &ast_rtp_turn_rtcp_sock_cb, &rtp->turn_rtcp);
+				rtp_add_candidates_to_ice(instance, rtp, &rtp->rtcp->us, ast_sockaddr_port(&rtp->rtcp->us), AST_RTP_ICE_COMPONENT_RTCP, TRANSPORT_SOCKET_RTCP);
 			}
 #endif
 
@@ -4586,10 +4849,6 @@ static int ast_rtp_sendcng(struct ast_rtp_instance *instance, int level)
 		return res;
 	}
 
-#ifdef USE_PJPROJECT
-	update_address_with_ice_candidate(rtp, AST_RTP_ICE_COMPONENT_RTP, &remote_address);
-#endif
-
 	if (rtp_debug_test_addr(&remote_address)) {
 		ast_verbose("Sent Comfort Noise RTP packet to %s%s (type %-2.2d, seq %-6.6d, ts %-6.6u, len %-6.6d)\n",
 			    ast_sockaddr_stringify(&remote_address),
@@ -4856,17 +5115,17 @@ static int rtp_reload(int reload)
 			if (ast_parse_arg(s, PARSE_INADDR, &addr)) {
 				ast_log(LOG_WARNING, "Invalid TURN server address: %s\n", s);
 			} else {
-				pj_strdup2(pool, &turnaddr, ast_inet_ntoa(addr.sin_addr));
+				pj_strdup2_with_null(pool, &turnaddr, ast_inet_ntoa(addr.sin_addr));
 				/* ntohs() is not a bug here. The port number is used in host byte order with
 				 * a pjnat API. */
 				turnport = ntohs(addr.sin_port);
 			}
 		}
 		if ((s = ast_variable_retrieve(cfg, "general", "turnusername"))) {
-			pj_strdup2(pool, &turnusername, s);
+			pj_strdup2_with_null(pool, &turnusername, s);
 		}
 		if ((s = ast_variable_retrieve(cfg, "general", "turnpassword"))) {
-			pj_strdup2(pool, &turnpassword, s);
+			pj_strdup2_with_null(pool, &turnpassword, s);
 		}
 #endif
 		ast_config_destroy(cfg);
@@ -4886,6 +5145,22 @@ static int reload_module(void)
 	return 0;
 }
 
+#ifdef USE_PJPROJECT
+static void rtp_terminate_pjproject(void)
+{
+	pj_thread_register_check();
+
+	if (timer_thread) {
+		timer_terminate = 1;
+		pj_thread_join(timer_thread);
+		pj_thread_destroy(timer_thread);
+	}
+
+	pj_caching_pool_destroy(&cachingpool);
+	pj_shutdown();
+}
+#endif
+
 static int load_module(void)
 {
 #ifdef USE_PJPROJECT
@@ -4898,12 +5173,12 @@ static int load_module(void)
 	}
 
 	if (pjlib_util_init() != PJ_SUCCESS) {
-		pj_shutdown();
+		rtp_terminate_pjproject();
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	if (pjnath_init() != PJ_SUCCESS) {
-		pj_shutdown();
+		rtp_terminate_pjproject();
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
@@ -4911,52 +5186,34 @@ static int load_module(void)
 
 	pool = pj_pool_create(&cachingpool.factory, "rtp", 512, 512, NULL);
 
-	if (pj_timer_heap_create(pool, 100, &timerheap) != PJ_SUCCESS) {
-		pj_caching_pool_destroy(&cachingpool);
-		pj_shutdown();
+	if (pj_timer_heap_create(pool, 100, &timer_heap) != PJ_SUCCESS) {
+		rtp_terminate_pjproject();
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	if (pj_lock_create_recursive_mutex(pool, "rtp%p", &lock) != PJ_SUCCESS) {
-		pj_caching_pool_destroy(&cachingpool);
-		pj_shutdown();
+		rtp_terminate_pjproject();
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
-	pj_timer_heap_set_lock(timerheap, lock, PJ_TRUE);
+	pj_timer_heap_set_lock(timer_heap, lock, PJ_TRUE);
 
-	if (pj_ioqueue_create(pool, 16, &ioqueue) != PJ_SUCCESS) {
-		pj_caching_pool_destroy(&cachingpool);
-		pj_shutdown();
-		return AST_MODULE_LOAD_DECLINE;
-	}
-
-	if (pj_thread_create(pool, "ice", &ice_worker_thread, NULL, 0, 0, &thread) != PJ_SUCCESS) {
-		pj_caching_pool_destroy(&cachingpool);
-		pj_shutdown();
+	if (pj_thread_create(pool, "ice", &timer_worker_thread, NULL, 0, 0, &timer_thread) != PJ_SUCCESS) {
+		rtp_terminate_pjproject();
 		return AST_MODULE_LOAD_DECLINE;
 	}
 #endif
 
 	if (ast_rtp_engine_register(&asterisk_rtp_engine)) {
 #ifdef USE_PJPROJECT
-		worker_terminate = 1;
-		pj_thread_join(thread);
-		pj_thread_destroy(thread);
-		pj_caching_pool_destroy(&cachingpool);
-		pj_shutdown();
+		rtp_terminate_pjproject();
 #endif
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	if (ast_cli_register_multiple(cli_rtp, ARRAY_LEN(cli_rtp))) {
 #ifdef USE_PJPROJECT
-		worker_terminate = 1;
-		pj_thread_join(thread);
-		pj_thread_destroy(thread);
-		ast_rtp_engine_unregister(&asterisk_rtp_engine);
-		pj_caching_pool_destroy(&cachingpool);
-		pj_shutdown();
+		rtp_terminate_pjproject();
 #endif
 		return AST_MODULE_LOAD_DECLINE;
 	}
@@ -4972,15 +5229,7 @@ static int unload_module(void)
 	ast_cli_unregister_multiple(cli_rtp, ARRAY_LEN(cli_rtp));
 
 #ifdef USE_PJPROJECT
-	worker_terminate = 1;
-
-	pj_thread_register_check();
-
-	pj_thread_join(thread);
-	pj_thread_destroy(thread);
-
-	pj_caching_pool_destroy(&cachingpool);
-	pj_shutdown();
+	rtp_terminate_pjproject();
 #endif
 
 	return 0;
diff --git a/res/res_xmpp.c b/res/res_xmpp.c
index ca21f0d..4357415 100644
--- a/res/res_xmpp.c
+++ b/res/res_xmpp.c
@@ -39,7 +39,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 413587 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 426019 $")
 
 #include <ctype.h>
 #include <iksemel.h>
@@ -2501,6 +2501,7 @@ static int xmpp_client_requested_tls(struct ast_xmpp_client *client, struct ast_
 {
 #ifdef HAVE_OPENSSL
 	int sock;
+	long ssl_opts;
 #endif
 
 	if (!strcmp(iks_name(node), "success")) {
@@ -2519,11 +2520,14 @@ static int xmpp_client_requested_tls(struct ast_xmpp_client *client, struct ast_
 	ast_log(LOG_ERROR, "Somehow we managed to try to start TLS negotiation on client '%s' without OpenSSL support, disconnecting\n", client->name);
 	return -1;
 #else
-	client->ssl_method = SSLv3_method();
+	client->ssl_method = SSLv23_method();
 	if (!(client->ssl_context = SSL_CTX_new((SSL_METHOD *) client->ssl_method))) {
 		goto failure;
 	}
 
+	ssl_opts = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3;
+	SSL_CTX_set_options(client->ssl_context, ssl_opts);
+
 	if (!(client->ssl_session = SSL_new(client->ssl_context))) {
 		goto failure;
 	}
diff --git a/sounds/Makefile b/sounds/Makefile
index 6c33061..2a74ccb 100644
--- a/sounds/Makefile
+++ b/sounds/Makefile
@@ -19,8 +19,8 @@ CMD_PREFIX?=@
 SOUNDS_DIR:=$(DESTDIR)$(ASTDATADIR)/sounds
 SOUNDS_CACHE_DIR?=
 MOH_DIR:=$(DESTDIR)$(ASTDATADIR)/moh
-CORE_SOUNDS_VERSION:=1.4.25
-EXTRA_SOUNDS_VERSION:=1.4.14
+CORE_SOUNDS_VERSION:=1.4.26
+EXTRA_SOUNDS_VERSION:=1.4.15
 MOH_VERSION:=2.03
 SOUNDS_URL:=http://downloads.asterisk.org/pub/telephony/sounds/releases
 MCS:=$(subst -EN-,-en-,$(MENUSELECT_CORE_SOUNDS))
@@ -30,6 +30,7 @@ MCS:=$(subst -FR-,-fr-,$(MCS))
 MCS:=$(subst -ES-,-es-,$(MCS))
 MCS:=$(subst -RU-,-ru-,$(MCS))
 MCS:=$(subst -IT-,-it-,$(MCS))
+MCS:=$(subst -JA-,-ja-,$(MCS))
 MCS:=$(subst -WAV,-wav,$(MCS))
 MCS:=$(subst -ULAW,-ulaw,$(MCS))
 MCS:=$(subst -ALAW,-alaw,$(MCS))
@@ -150,6 +151,8 @@ $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,it,$(CORE_SOUNDS_
 
 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,ru,$(CORE_SOUNDS_VERSION)))
 
+$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,ja,$(CORE_SOUNDS_VERSION)))
+
 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,en,$(EXTRA_SOUNDS_VERSION)))
 
 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,en_GB,$(EXTRA_SOUNDS_VERSION)))
diff --git a/sounds/sounds.xml b/sounds/sounds.xml
index 768ddde..5934bb3 100644
--- a/sounds/sounds.xml
+++ b/sounds/sounds.xml
@@ -189,6 +189,33 @@
 		<member name="CORE-SOUNDS-RU-SIREN14" displayname="Russian, G.722.1C (Siren14) format">
 			<support_level>core</support_level>
 		</member>
+		<member name="CORE-SOUNDS-JA-WAV" displayname="Japanese, WAV format">
+			<support_level>core</support_level>
+		</member>
+		<member name="CORE-SOUNDS-JA-ULAW" displayname="Japanese, mu-Law format">
+			<support_level>core</support_level>
+		</member>
+		<member name="CORE-SOUNDS-JA-ALAW" displayname="Japanese, a-Law format">
+			<support_level>core</support_level>
+		</member>
+		<member name="CORE-SOUNDS-JA-GSM" displayname="Japanese, GSM format">
+			<support_level>core</support_level>
+		</member>
+		<member name="CORE-SOUNDS-JA-G729" displayname="Japanese, G.729 format">
+			<support_level>core</support_level>
+		</member>
+		<member name="CORE-SOUNDS-JA-G722" displayname="Japanese, G.722 format">
+			<support_level>core</support_level>
+		</member>
+		<member name="CORE-SOUNDS-JA-SLN16" displayname="Japanese, Signed-linear 16kHz format">
+			<support_level>core</support_level>
+		</member>
+		<member name="CORE-SOUNDS-JA-SIREN7" displayname="Japanese, G.722.1 (Siren7) format">
+			<support_level>core</support_level>
+		</member>
+		<member name="CORE-SOUNDS-JA-SIREN14" displayname="Japanese, G.722.1C (Siren14) format">
+			<support_level>core</support_level>
+		</member>
 	</category>
 	<category name="MENUSELECT_MOH" displayname="Music On Hold File Packages" positive_output="yes">
 		<member name="MOH-OPSOUND-WAV" displayname="opsound.org Music On Hold Files, WAV format" >
diff --git a/tests/test_callerid.c b/tests/test_callerid.c
new file mode 100644
index 0000000..731d66f
--- /dev/null
+++ b/tests/test_callerid.c
@@ -0,0 +1,165 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2014, Kinsey Moore
+ *
+ * Kinsey Moore <kmoore at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief Callerid Tests
+ *
+ * \author\verbatim Kinsey Moore <kmoore at digium.com> \endverbatim
+ *
+ * This is an Asterisk test module for callerid functionality
+ * \ingroup tests
+ */
+
+/*** MODULEINFO
+	<depend>TEST_FRAMEWORK</depend>
+	<support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+#include "asterisk/callerid.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 422113 $")
+
+#include "asterisk/utils.h"
+#include "asterisk/module.h"
+#include "asterisk/test.h"
+
+struct cid_set {
+	char *cid;
+	char *name;
+	char *number;
+};
+
+AST_TEST_DEFINE(parse_nominal)
+{
+	static const struct cid_set cid_sets[] = {
+		{"\"name\" <number>", "name", "number"},
+		{"\"   name  \" <number>", "   name  ", "number"},
+		{"name <number>", "name", "number"},
+		{"         name     <number>", "name", "number"},
+		{"\"\" <number>", NULL, "number"},
+		{"<number>", NULL, "number"},
+		{"name", "name", NULL},
+		{"\"name\"", "name", NULL},
+		{"\"name\" <>", "name", NULL},
+		{"name <>", "name", NULL},
+		{"1234", NULL, "1234"},
+		{"\"na\\\"me\" <number>", "na\"me", "number"},
+	};
+	char *name;
+	char *number;
+	int i;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "parse_nominal";
+		info->category = "/main/callerid/";
+		info->summary = "Callerid nominal parse unit test";
+		info->description =
+			"This tests parsing of nominal callerid strings.";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	for (i = 0; i < ARRAY_LEN(cid_sets); i++) {
+		RAII_VAR(char *, callerid, ast_strdup(cid_sets[i].cid), ast_free);
+
+		ast_callerid_parse(callerid, &name, &number);
+		if (!cid_sets[i].name == !ast_strlen_zero(name) || (cid_sets[i].name && strcmp(name, cid_sets[i].name))) {
+			ast_test_status_update(test,
+				"Expected callerid name '%s' instead of '%s'\n",
+				cid_sets[i].name, name);
+			return AST_TEST_FAIL;
+		}
+
+		if (!cid_sets[i].number == !ast_strlen_zero(number) || (cid_sets[i].number && strcmp(number, cid_sets[i].number))) {
+			ast_test_status_update(test,
+				"Expected callerid number '%s' instead of '%s'\n",
+				cid_sets[i].number, number);
+			return AST_TEST_FAIL;
+		}
+	}
+
+	return AST_TEST_PASS;
+}
+
+AST_TEST_DEFINE(parse_off_nominal)
+{
+	static const struct cid_set cid_sets[] = {
+		{"na\\\"me <number>", "na\"me", "number"},
+		{"\"na\"me\" <number>", "na\"me", "number"},
+		{"na\"me <number>", "na\"me", "number"},
+		{"\"name <number>", "\"name", "number"},
+		{"name <number", "name", "number"},
+		{"\"name <number>\"", "name", "number"},
+	};
+	char *name;
+	char *number;
+	int i;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "parse_off_nominal";
+		info->category = "/main/callerid/";
+		info->summary = "Callerid off-nominal parse unit test";
+		info->description =
+			"This tests parsing of off-nominal callerid strings.";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	for (i = 0; i < ARRAY_LEN(cid_sets); i++) {
+		RAII_VAR(char *, callerid, ast_strdup(cid_sets[i].cid), ast_free);
+
+		ast_callerid_parse(callerid, &name, &number);
+		if (!cid_sets[i].name == !ast_strlen_zero(name) || (cid_sets[i].name && strcmp(name, cid_sets[i].name))) {
+			ast_test_status_update(test,
+				"Expected callerid name '%s' instead of '%s'\n",
+				cid_sets[i].name, name);
+			return AST_TEST_FAIL;
+		}
+
+		if (!cid_sets[i].number == !ast_strlen_zero(number) || (cid_sets[i].number && strcmp(number, cid_sets[i].number))) {
+			ast_test_status_update(test,
+				"Expected callerid number '%s' instead of '%s'\n",
+				cid_sets[i].number, number);
+			return AST_TEST_FAIL;
+		}
+	}
+
+	return AST_TEST_PASS;
+}
+
+static int unload_module(void)
+{
+	AST_TEST_UNREGISTER(parse_nominal);
+	AST_TEST_UNREGISTER(parse_off_nominal);
+	return 0;
+}
+
+static int load_module(void)
+{
+	AST_TEST_REGISTER(parse_nominal);
+	AST_TEST_REGISTER(parse_off_nominal);
+	return AST_MODULE_LOAD_SUCCESS;
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Callerid Parse Tests");
diff --git a/tests/test_utils.c b/tests/test_utils.c
index 32635fb..3e1cd08 100644
--- a/tests/test_utils.c
+++ b/tests/test_utils.c
@@ -32,7 +32,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 356397 $");
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 422113 $");
 
 #include "asterisk/utils.h"
 #include "asterisk/test.h"
@@ -421,6 +421,100 @@ AST_TEST_DEFINE(agi_loaded_test)
 	return res;
 }
 
+struct quote_set {
+	char *input;
+	char *output;
+};
+
+AST_TEST_DEFINE(quote_mutation)
+{
+	char escaped[64];
+	static const struct quote_set escape_sets[] = {
+		{"\"string\"", "\\\"string\\\""},
+		{"\"string", "\\\"string"},
+		{"string\"", "string\\\""},
+		{"string", "string"},
+		{"str\"ing", "str\\\"ing"},
+		{"\"", "\\\""},
+		{"\\\"", "\\\\\\\""},
+	};
+	int i;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "quote_mutation";
+		info->category = "/main/utils/";
+		info->summary = "Test mutation of quotes in strings";
+		info->description =
+			"This tests escaping and unescaping of quotes in strings to "
+			"verify that the original string is recovered.";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	for (i = 0; i < ARRAY_LEN(escape_sets); i++) {
+		ast_escape_quoted(escape_sets[i].input, escaped, sizeof(escaped));
+
+		if (strcmp(escaped, escape_sets[i].output)) {
+			ast_test_status_update(test,
+				"Expected escaped string '%s' instead of '%s'\n",
+				escape_sets[i].output, escaped);
+			return AST_TEST_FAIL;
+		}
+
+		ast_unescape_quoted(escaped);
+		if (strcmp(escaped, escape_sets[i].input)) {
+			ast_test_status_update(test,
+				"Expected unescaped string '%s' instead of '%s'\n",
+				escape_sets[i].input, escaped);
+			return AST_TEST_FAIL;
+		}
+	}
+
+	return AST_TEST_PASS;
+}
+
+AST_TEST_DEFINE(quote_unescaping)
+{
+	static const struct quote_set escape_sets[] = {
+		{"\"string\"", "\"string\""},
+		{"\\\"string\"", "\"string\""},
+		{"\"string\\\"", "\"string\""},
+		{"str\\ing", "string"},
+		{"string\\", "string"},
+		{"\\string", "string"},
+	};
+	int i;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "quote_unescaping";
+		info->category = "/main/utils/";
+		info->summary = "Test unescaping of off-nominal strings";
+		info->description =
+			"This tests unescaping of strings which contain a mix of "
+			"escaped and unescaped sequences.";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	for (i = 0; i < ARRAY_LEN(escape_sets); i++) {
+		RAII_VAR(char *, escaped, ast_strdup(escape_sets[i].input), ast_free);
+
+		ast_unescape_quoted(escaped);
+		if (strcmp(escaped, escape_sets[i].output)) {
+			ast_test_status_update(test,
+				"Expected unescaped string '%s' instead of '%s'\n",
+				escape_sets[i].output, escaped);
+			return AST_TEST_FAIL;
+		}
+	}
+
+	return AST_TEST_PASS;
+}
+
 static int unload_module(void)
 {
 	AST_TEST_UNREGISTER(uri_encode_decode_test);
@@ -431,6 +525,8 @@ static int unload_module(void)
 	AST_TEST_UNREGISTER(crypto_loaded_test);
 	AST_TEST_UNREGISTER(adsi_loaded_test);
 	AST_TEST_UNREGISTER(agi_loaded_test);
+	AST_TEST_UNREGISTER(quote_mutation);
+	AST_TEST_UNREGISTER(quote_unescaping);
 	return 0;
 }
 
@@ -444,6 +540,8 @@ static int load_module(void)
 	AST_TEST_REGISTER(crypto_loaded_test);
 	AST_TEST_REGISTER(adsi_loaded_test);
 	AST_TEST_REGISTER(agi_loaded_test);
+	AST_TEST_REGISTER(quote_mutation);
+	AST_TEST_REGISTER(quote_unescaping);
 	return AST_MODULE_LOAD_SUCCESS;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/asterisk.git



More information about the Pkg-voip-commits mailing list