Make a NOTICE about an invalid channel name more useful.
res_rtp_asterisk & udptl: fix port selection to work with SELinux restrictions

ast_bind to a port reserved for another program by SELinux causes
errno == EACCES.  This caused random failures when binding rtp or
udptl sockets.  Treat EACCES as a non-fatal error, try next port.

(closes issue ASTERISK-23134)
Reported by: Corey Farrell
........

Merged revisions 406933 from http://svn.asterisk.org/svn/asterisk/branches/1.8
app_dial: Allow macro/gosub pre-bridge execution to occur on priorities

The parsing for the destination of the macro/gosub uses the '^' character to
separate out context, extension, and priority. However, the logic for the
macro/gosub execution was written such that it would only do the actual
macro/gosub jump if a '^' character existed. This doesn't apply when the
macro/gosub jump occurs in a priority/priority label. This patch changes
the logic so that the parsing still occurs, but the jump will occur even
for priorities/priority labels.

(issue ASTERISK-23164)

Review: https://reviewboard.asterisk.org/r/3154
........

Merged revisions 407041 from http://svn.asterisk.org/svn/asterisk/branches/1.8
app_stack: protect against missing parameters to STACK_PEEK and LOCAL_PEEK

STACK_PEEK requires 2 parameters and LOCAL_PEEK requires 1 parameter.  This
protects against situations where those parameters are blank or missing by
logging an error and returning.

(closes issue ASTERISK-23220)
Reported by: James Sharp
........

Merged revisions 407100 from http://svn.asterisk.org/svn/asterisk/branches/1.8
res_clialiases: Fix crash when reloading and re-aliasing an alias that is in use.

The code assumed that unregistering the alias would always succeed while in
practice this is not actually true. A common case is the "reload" command itself.
If the cli_aliases.conf configuration file was changed and reload executed the
command would fail to unregister and ultimately point to freed memory.

The reload process now checks whether unregistering succeeded or not and if not
the old CLI alias is retained.

(closes issue ASTERISK-19773)
Reported by: Joel Vandal

(closes issue ASTERISK-22757)
Reported by: Gareth Blades
........

Merged revisions 407205 from http://svn.asterisk.org/svn/asterisk/branches/1.8
tcptls.c: Made TLS handle a certificate chain file.

Thanks to Guillaume Martres for doing the necessary research to validate
the change.

(closes issue ASTERISK-17727)
Reported by: LN
Patches:
      use_certificate_chain.patch (license #5864) patch uploaded by st
      documente_certificate_chain.patch (license #6576) patch uploaded by Guillaume Martres
........

Merged revisions 407272 from http://svn.asterisk.org/svn/asterisk/branches/1.8
devicestate: Make ast_devstate_changed_literal() return value and doxygen consistent.

Nothing actually cares about the value anyway.

(closes issue ASTERISK-23178)
Reported by: Jonathan Rose
........

Merged revisions 407337 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Logger: Fix handling of absolute paths

This fixes path handling for log files so that an extra / is not
appended to the file path when the path is absolute (begins with /).
This would previously result in different but functionally equivalent
paths in the output of 'logger show channels'.
........

Merged revisions 407455 from http://svn.asterisk.org/svn/asterisk/branches/1.8
chan_local: Fix reversed LocalOptimization field in LocalBridge event

(closes issue ASTERISK-23232)
Reported by: Leon Roy
formats/format_wav: enhancing log message "Not a wav file" to be clear on what is supported

Modifying the log message to be more specific as to what is supported. Specifically it seems format_wav supports only PCM encoded versions with a lower-case '.wav' extension.

(closes issues ASTERISK-22310)
Reported by: Jim Credland
Review: https://reviewboard.asterisk.org/r/3188/
........

Merged revisions 407511 from http://svn.asterisk.org/svn/asterisk/branches/1.8
indications.conf: add stutter tone; end properly

* If the "stutter" (voicemail indication) tone is indeed a stutter tone,
  and it ends with a constant tone, make sure that it is the dial tone.
  This was done for India (in), Mexico (mx) and the Philippines (ph).
* If no "stutter" tone exists for a country, provide one. This was done for
  Spain (es), Malaysia (my) and Venezuela (ve).

Review: https://reviewboard.asterisk.org/r/3158/
........

Merged revisions 407622 from http://svn.asterisk.org/svn/asterisk/branches/1.8
chan_iax2: Block unnecessary control frames to/from the wire.

Establishing an IAX2 call between Asterisk v1.4 and v1.8 (or later)
results in an unexpected call disconnect.  The problem happens because
newer values in the enum ast_control_frame_type are not consistent between
the branch versions of Asterisk.

For example:
1) v1.4 calls v1.8 (or later) using IAX2

2) v1.8 answers and sends a connected line update control frame.  (on v1.8
AST_CONTROL_CONNECTED_LINE = 22)

3) v1.4 receives the control frame as an end-of-q (on v1.4
AST_CONTROL_END_OF_Q = 22)

4) v1.4 disconnects the call once the receive queue becomes empty.

Several things are done by this patch to fix the problem and attempt to
prevent it from happening again in the future:

* Added a warning at the definition of enum ast_control_frame_type about
how to add new control frame values.

* Made block sending and receiving control frames that have no reason to
go over the wire.

* Extended the connectedline iax.conf parameter to also include the
redirecting information updates.

* Updated the connectedline iax.conf parameter documentation to include a
notice that the parameter must be "no" when the peer is an Asterisk v1.4
instance.

(closes issue AST-1302)

Review: https://reviewboard.asterisk.org/r/3174/
........

Merged revisions 407678 from http://svn.asterisk.org/svn/asterisk/branches/1.8
chan_iax2: Add some more iaxs[] NULL checks to a routine already full of them.
........

Merged revisions 407764 from http://svn.asterisk.org/svn/asterisk/branches/1.8
chan_dahdi: handle DAHDI_EVENT_REMOVED on a pri D-Channel

When a DAHDI device is removed at run-time it sends the event
DAHDI_EVENT_REMOVED on each channel. This is intended to signal the
userspace program to close the respective file handle, as the driver of
the device will need all of them closed to properly clean-up.

This event has long since been handled in chan_dahdi (chan_zap at the
time). However the event that is sent on a D-Channel of a "PRI" (ISDN)
span simply gets ignored.

This commit adds handling for closing the file descriptor (and shutting
down the span, while we're at it).

It also adds a CLI command 'pri destroy span <N>' to destroy the span
and its DAHDI channels.

Backported from trunk/12.

Review: https://reviewboard.asterisk.org/r/726/
........

Merged revisions 394552 394567 from http://svn.asterisk.org/svn/asterisk/trunk
........

Merged revisions 407817 from http://svn.asterisk.org/svn/asterisk/branches/1.8
ConfBridge: Correct prompt playback target

Currently, when the first marked user enters the conference that
contains waitmarked users, a prompt is played indicating that the user
is being placed into the conference. Unfortunately, this prompt is
played to the marked user and not the waitmarked users which is not
very helpful.

This patch changes that behavior to play a prompt stating
"The conference will now begin" to the entire conference after adding
and unmuting the waitmarked users since the design of confbridge is not
conducive to playing a prompt to a subset of users in a conference in
an asynchronous manner.

(closes issue PQ-1396)
Review: https://reviewboard.asterisk.org/r/3155/
Reported by: Steve Pitts
res_config_pgsql: Fix ast_update2_realtime calls.

Fix so multiple updates from a single call works (add missing ',').
Remove bogus ast_free's that weren't supposed to be there.
Moved a few spaces for readability.

Review: https://reviewboard.asterisk.org/r/3194/
........

Merged revisions 407873 from http://svn.asterisk.org/svn/asterisk/branches/1.8
configs/agents.conf.sample - Remove example for non-functional "goodbye" parameter

The "goodbye" parameter is not implemented in the source code, it does nothing.

(closes issue SWP-6518)
Reported By: Steve Pitts
........

Merged revisions 408020 from http://svn.asterisk.org/svn/asterisk/branches/1.8
buildsystem: Don't force main to depend on everything else.

Directory 'main' only needs to depend on embedded modules. If no
module embedding is selected, the dependency is dropped.

Review: https://reviewboard.asterisk.org/r/3212/
........

Merged revisions 408083 from http://svn.asterisk.org/svn/asterisk/branches/1.8
format.c: correct possible null pointer dereference

In ast_format_sdp_parse and ast_format_sdp_generate
the check checks for a valid interface and function
were potentially confusing, and hid an error in the
test of the presence of the function that is called
later.  This patch clears up and corrects the test.

Review: https://reviewboard.asterisk.org/r/3208/
(closes issue ASTERISK-23098)
Reported by: marcelloceschia
Patches:
     main_format.patch uploaded by marcelloceschia (license 6036)
	 ASTERISK-23098.patch uploaded by coreyfarrell (license 5909)
pbx: ast_custom_function_unregister resource leak

In pbx.c ast_custom_function_unregister(), a list
of escalations being removed from the list wasn't
being free'd creating a leak. This patch corrects
that by freeing the records.

Review: https://reviewboard.asterisk.org/r/3213/
Reported by: Corey Farrell
Patches:
     acf_escalating_leak.patch uploaded by coreyfarrell (license 5909)
........

Merged revisions 408142 from http://svn.asterisk.org/svn/asterisk/branches/1.8