Commit Graph

26228 Commits

Author SHA1 Message Date
Matthew Jordan ab6e2c93f3 app_voicemail: Fix crash with IMAP backends when greetings aren't present
When an IMAP backend is in use and greetings are set to be used, but aren't
present for a user in their IMAP folder, Asterisk will crash. This occurs
due to the mailstream being set to the 'greetings' folder and being left
in that particular state, regardless of the success/failure of the attempt
to access the folder the mailstream points to. Later access of the mailstream
assumes that it points to the 'INBOX' (or some other folder), resulting in
either a crash (if the greetings folder didn't exist and the mailstream is
invalid) or an inability to read messages from the 'INBOX' folder.

This patch restores the mailstream to its correct state after accessing the
greetings. This fixes the crash, and sets the mailstream to the state that
VoiceMailMain expects.

Note that while ASTERISK-23390 also contained a patch for this issue, the
patch on ASTERISK-24786 is the one being merged here.

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

ASTERISK-23390 #close
Reported by: Ben Smithurst

ASTERISK-24786 #close
Reported by: Graham Barnett
Tested by: Graham Barnett
patches:
  app_voicemail.c.patch.SIGSEGV3rev2 uploaded by Graham Barnett (License 6685)
........

Merged revisions 432695 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432696 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432697 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-10 18:13:27 +00:00
Matthew Jordan 79e9b37ad0 localtime: Fix file descriptor leak on kqueue(2) systems
The localtime management in the Asterisk core contains a thread that watches
for changes in the local timezone. On systems where the directory containing
/etc/localtime is modified frequently, the thread monitoring the changes will
be woken up to determine if any changes in timezone have occurred. When using
kqueue(2), this can cause a leak of file descriptors due to some improper
management of resources.

This patch updates the kqueue(2) handling in localtime, such that is no longer
leaks resources.

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

ASTERISK-24739 #close
Reported by: Ed Hynan
patches:
  11.15.0-u.diff uploaded by Ed Hynan (Licnese 6680)
  11.7.0-u.diff uploaded by Ed Hynan (License 6680)
  svn-trunk-Jan-26-2015-u.diff uploaded by Ed Hynan (License 6680)
........

Merged revisions 432691 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432693 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432694 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-10 18:05:37 +00:00
Richard Mudgett e7ee83ea90 res_pjsip_refer: Fix occasional unexpected BYE sent after receiving a REFER.
A race condition happened between initiating a transfer and requesting
that a dialog termination be delayed.  Occasionally, the transferrer
channels would exit the bridge and hangup before the dialog termination
delay was requested.

* Made request dialog termination delay before initiating the transfer
action.  If the transfer fails then cancel the delayed dialog termination
request.

ASTERISK-24755 #close
Reported by: John Bigelow

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

Merged revisions 432668 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432669 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-10 16:08:40 +00:00
Kevin Harwell 1ce529d30e res_pjsip: allow configuration of endpoint identifier query order
It's possible to have a scenario that will create a conflict between endpoint
identifiers. For instance an incoming call could be identified by two different
endpoint identifiers and the one chosen depended upon which identifier module
loaded first. This of course causes problems when, for example, the incoming
call is expected to be identified by username, but instead is identified by ip.
This patch adds a new 'global' option to res_pjsip called
'endpoint_identifier_order'. It is a comma separated list of endpoint
identifier names that specifies the order by which identifiers are processed
and checked.

ASTERISK-24840 #close
Reported by: Mark Michelson
Review: https://reviewboard.asterisk.org/r/4455/
........

Merged revisions 432638 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432639 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-09 16:13:40 +00:00
Joshua Colp a5f80f1781 res_rtp_asterisk: Fix wrongful use of USE_PJPROJECT define.
As pjproject is now used as a shared library a different define,
HAVE_PJPROJECT, is used to specify if pjproject is present.

ASTERISK-24830 #close
Reported by: Stefan Engström
........

Merged revisions 432614 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432615 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-08 01:47:03 +00:00
Richard Mudgett affcf1d766 res_pjsip_refer: Make safely get the context for a blind transfer.
Made safely get the TRANSFER_CONTEXT channel value while the channel is
locked in refer_incoming_attended_request() and
refer_incoming_blind_request().  The pointer returned by
pbx_builtin_getvar_helper() is only valid while the channel is locked.
........

Merged revisions 432594 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432595 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-06 22:59:29 +00:00
Richard Mudgett 090ab1735b res_pjsip_refer: Made refer_attended_alloc() not create the ao2 object with a lock.
The lock is unused.
........

Merged revisions 432574 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432579 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-06 22:18:28 +00:00
Jonathan Rose b85cb7ea1b app: Add functions to swap voicemail function table for testing purposes
........

Merged revisions 432556 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432573 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-06 21:38:36 +00:00
Richard Mudgett c7cc1b3059 chan_dahdi/sig_analog: Fix distinctive ring detection to suck less.
The distinctive ring feature interferes with detecting Caller ID and
appears to have been broken for years.  What happens is if you have a
ring-ring cadence as used in the UK you get too many DAHDI events for the
distinctive ring pattern array and Caller ID detection is aborted.  I
think when Zapata/DAHDI added the ring begin event it broke distinctive
ring.  More events happen than before and the code does no filtering of
which event times are recorded in the pattern array.

* Made distinctive ring only record the ringt count when the ring ends
instead of on just any DAHDI event.  Distinctive ring can be ring,
ring-ring, ring-ring-ring, or different ring durations for the up to three
rings.

* Fixed the distinctive ring detection enable (chan_dahdi.conf option
usedistinctiveringdetection) to be per port instead of somewhat per port
and somewhat global.  This has been broken since v1.8.

* Fixed using the default distinctive ring context when the detected
pattern does not match any configured dringX patterns.  The default
context did not get set when the previous call was a matched distinctive
ring pattern and the current call is not matched.  This has been broken
since v1.8.

* Made distinctive ring have no effect on Caller ID detection when it is
disabled.  Caller ID detection just monitors for 10 seconds before giving
up.

* Fixed leak of struct callerid_state memory when a polarity reversal
during Caller ID detection causes the incoming call to be aborted.

DAHDI-1143
AST-1545
ASTERISK-24825 #close
Reported by: Richard Mudgett

ASTERISK-17588
Reported by: Daniel Flounders

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

Merged revisions 432530 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432534 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432551 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-06 20:24:58 +00:00
Richard Mudgett f1ab2c5e8b chan_sip: Fix realtime locking inversion when poking a just built peer.
When a realtime peer is built it can cause a locking inversion when the
just built peer is poked.  If the CLI command "sip show channels" is
periodically executed then a deadlock can happen because of the locking
inversion.

* Push the peer poke off onto the scheduler thread to avoid the locking
inversion of the just built realtime peer.

AST-1540
ASTERISK-24838 #close
Reported by: Richard Mudgett

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

Merged revisions 432526 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432528 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432529 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-06 19:34:35 +00:00
George Joseph 5c3e33b3ca app_voicemail: Fix compile breaking in app_voicemail with IMAP_STORAGE.
There is a leftover "assert" in app_voicemail/__messagecount that references 
variables that don't exist.  This causes the compile to fail when 
--enable-dev-mode and IMAP_STORAGE are selected.

This patch removes the assert.

Tested-by: George Joseph

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

Merged revisions 432484 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432485 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432486 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-05 16:40:27 +00:00
Matthew Jordan 41ba8fd7c0 translate: Prevent invalid memory accesses on fast shutdown
When a 'core restart now' or 'core stop now' is executed and a channel is
currently in a media operation, the translator matrix can be destroyed while a
channel is currently blocked on getting the best translation choice
(see ast_translator_best_choice). When the channel gets the mutex, the
translation matrix now has invalid memory, and Asterisk crashes.

This patch does two things:
(1) We now only clean up the translation matrix on a graceful shutdown. In that
    case, there are no channels, and so there is no risk of this occurring.
(2) We also now set the __matrix and __indextable to NULL. In some initial
    backtraces when this occurred, it looked as if there was a memory corruption
    occurring, and it wasn't until we determined that something had restarted
    Asterisk that the issue became clear. By setting these to NULL on shutdown,
    it becomes a bit easier to determine why a crash is occurring.

Note that we could litter the code with NULL checks on the __matrix, but the
act of making the translation matrix cleaned up on shutdown should preclude
this issue from occurring in the first place, and this part of the code needs
to be as fast as possible.

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

Merged revisions 432453 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432455 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-04 18:55:08 +00:00
Matthew Jordan 278ea2f468 res/res_pjsip_sdp_rtp: Revert portion of r432195
Unfortunately, while initial testing with ConfBridge did not reproduce the
audio problem alluded to in the comment in res_pjsip_sdp_rtp, further testing
did show that bridge_softmix and/or ConfBridge has a severe problem bridging
two or more participants at different sampling rates. Sometimes, it even picks
odd sampling rates that cause hideous audio problems.

This patch backs out the offending portion of the code until the issues in
the affected bridging modules can be more properly analyzed.

ASTERISK-24841
........

Merged revisions 432423 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432425 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-02 19:15:58 +00:00
Richard Mudgett 9e841e4fb6 ARI: Fix crash if integer values used in JSON payload 'variables' object.
Sending the following ARI commands caused Asterisk to crash if the JSON
body 'variables' object passes values of types other than strings.

POST /ari/channels
POST /ari/channels/{channelid}
PUT /ari/endpoints/sendMessage
PUT /ari/endpoints/{tech}/{resource}/sendMessage

* Eliminated RAII_VAR usage in ast_ari_channels_originate_with_id(),
ast_ari_channels_originate(), ast_ari_endpoints_send_message(), and
ast_ari_endpoints_send_message_to_endpoint().

ASTERISK-24751 #close
Reported by:  jeffrey putnam

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

Merged revisions 432404 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432405 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-27 18:31:31 +00:00
Scott Griepentrog d79670b269 Dial API: add self destruct option when complete
This patch adds a self-destruction option to the
dial api.  The usefulness of this is mostly when
using async mode to spawn a separate thread used
to handle the new call, while the calling thread
is allowed to go on about other business.

The only alternative to this option would be the
calling thread spawning a new thread, or hanging
around itself waiting to destroy the dial struct
after completion.

Example of use (minus error checking):

  struct ast_dial *dial = ast_dial_create();

  ast_dial_append(dial, "PJSIP", "200", NULL);

  ast_dial_option_global_enable(dial, AST_DIAL_OPTION_ANSWER_EXEC, "Echo");
  ast_dial_option_global_enable(dial, AST_DIAL_OPTION_SELF_DESTROY, NULL);

  ast_dial_run(dial, NULL, 1);

The dial_run call will return almost immediately
after spawning the new thread to run and monitor
the dial.  If the call is answered, it is placed
into the echo app.  When completed, it will call
ast_dial_destroy() on the dial structure.

Note that any allocations made to pass values to
ast_dial_set_user_data() or dial options must be
free'd in a state callback function on any of:
  AST_DIAL_RESULT_UNASWERED,
  AST_DIAL_RESULT_ANSWERED,
  AST_DIAL_RESULT_HANGUP, or 
  AST_DIAL_RESULT_TIMEOUT.

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

Merged revisions 432385 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432386 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-26 18:53:36 +00:00
Kevin Harwell d04fbb0f9d app_chanspy, channel: fix frame leaks
Fixed a couple of frame leaks that were found during testing.

ASTERISK-24828 #close
Reported by: John Hardin
Review: https://reviewboard.asterisk.org/r/4445/
........

Merged revisions 432362 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432363 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432364 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-26 17:12:12 +00:00
Matthew Jordan 8a16c2f0c2 make: Remove 'res_features' from libraries to link against with cygwin/mingw32
Both the apps and channels Makefiles still listed 'res_features' as modules to
link against when compiling for cygwin or mingw32. This module hasn't existed
for quite some time.

ASTERISK-18105 #close
Reported by: feyfre
........

Merged revisions 432341 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432342 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432343 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-26 04:58:38 +00:00
Matthew Jordan 3725173b9e channels/chan_sip: Don't send a BYE after final response when PBX thread fails
When Asterisk fails to start a PBX thread for a new channel - for example, when
the maxcalls setting in asterisk.conf is exceeded - we currently send a final
response, and then attempt to send a BYE request to the UA. Since that's all
sorts of wrong, this patch fixes that by setting sipalreadygone on the sip_pvt
such that we don't get stuck sending BYE requests to something that does not
want it.

Note that this patch is a slight modification of the one on ASTERISK-15434.
For clarity, it explicitly calls sipalreadygone with the calls to transmit a
final response.

ASTERISK-21845
ASTERISK-15434 #close
Reported by: Makoto Dei
Tested by: Matt Jordan
patches:
  sip-pbxstart-failed.patch uploaded by Makoto Dei (License 5027)
........

Merged revisions 432320 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432321 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432322 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-26 03:03:39 +00:00
Rusty Newton e484140aed configs/basic-pbx - Super Awesome Company example configs Phase 1, Patch 1
Example configuration files for a "basic PBX" deployment for the fictitious
Super Awesome Company. Details at https://reviewboard.asterisk.org/r/4379/
and https://wiki.asterisk.org/wiki/display/AST/Super+Awesome+Company

Reported by: Malcolm Davenport
Tested by: Rusty Newton

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

Merged revisions 432301 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432302 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-25 23:49:21 +00:00
Matthew Jordan ced84d7e62 configure: Promote SQLite3 "not installed" warning to error
Since Asterisk won't build without the library, not having it is definitely
an error. Thanks to Kyle Kurz for pointing this out.
........

Merged revisions 432280 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432281 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432282 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-25 23:09:51 +00:00
Matthew Jordan 4b63da7f7d channels/chan_sip: Clarify WARNING message in mismatched SRTP scenario
When we receive an SDP as part of an offer/answer for a peer/friend has been
configured to require encryption, and that SDP offer/answer failed to provide
acceptable crypto attributes, we currently issue a WARNING that uses the phrase
"we" and "requested". In this case, both of those terms are ambiguous - the
user will probably think "we" is Asterisk (it most likely isn't) and it may
not be a "request", so much as an SDP that was received in some fashion.

This patch makes the WARNING messages slightly less bad and a bit more
accurate as well.

ASTERISK-23214 #close
Reported by: Rusty Newton
........

Merged revisions 432277 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432278 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432279 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-25 23:05:40 +00:00
Matthew Jordan d68012d1a3 channels/sip/sdp_crypto: Handle SRTP keys negotiated with key lifetime/MKI
Prior to this patch, SDP offers negotiating SDES-SRTP crypto attributes would
be rejected if those crypto attributes contained either a key lifetime or a
MKI parameter. While from a theoretical point of view this was defensible -
Asterisk does not support key lifetimes or multiple crypto keys - from a
practical point of view, this is quite a problem. A large number of endpoints
offer lifetimes/MKI, which Asterisk can tolerate so long as it doesn't actually
have to support anything more than a single key or refresh the key.
In reality, this is (so far as we've seen) always the case.

This patch is a forward port of Olle's work in the lingon-srtp-key-lifetime-1.8
branch. To quote Olle from ASTERISK-17721, it handles lifetime/MKI parameters
in the following fashion:

> The Lingon branch now handle lifetime and MKI parameters.
>
> We only accept lifetimes up to max for the crypto and higher than 10 hours
> for packetization of 20 ms (50 pps).
>
> We only handle MKI with index 1.
>
> We do not really bother with counting packets and reinviting at end of
> lifetime, so the min of 10 hours kind of takes care of most calls. If there
> are longer ones, we rely on the other side for re-invites.
>
> It's still not perfect, but I personally think this is an improvement. A
> configuration option for minimum lifetime accepted could be added.

When the patch was ported forward, I decided against adding a configuration
option as Olle's handling was more than sufficient for every case I've seen
come through the issue tracker or through interoperability testing. We can
revisit that decision if it proves to be false.

A few small other tweaks were made to the surrounding code to reduce
indentation and provide better type safety for the 'tag' parameter.

Review: https://reviewboard.asterisk.org/r/4419/
Review: https://reviewboard.asterisk.org/r/4418/

ASTERISK-17721 #close
Reported by: Terry Wilson

ASTERISK-17899 #close
Reported by: Dwayne Hubbard
patches:
  lingon-srtp-key-lifetime-1.8.diff uploaded by oej (License 5267)

ASTERISK-20233
Reported by: tootai

ASTERISK-22748
Reported by: Alejandro Mejia
........

Merged revisions 432239 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432258 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432259 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-25 21:42:39 +00:00
David M. Lee ff642289f4 Increase WebSocket frame size and improve large read handling
Some WebSocket applications, like [chan_respoke][], require a larger
frame size than the default 8k; this patch bumps the default to 16k.
This patch also fixes some problems exacerbated by large frames.

The sanity counter was decremented on every fread attempt in
ws_safe_read(), regardless of whether data was read from the socket or
not. For large frames, this could result in loss of sanity prior to
reading the entire frame. (16k frame / 1448 bytes per segment = 12
segments).

This patch changes the sanity counter so that it only decrements when
fread() doesn't read any bytes. This more closely matches the original
intention of ws_safe_read(), given that the error message is
"Websocket seems unresponsive".

This patch also properly logs EOF conditions, so disconnects are no
longer confused with unresponsive connections.

 [chan_respoke]: https://github.com/respoke/chan_respoke

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

Merged revisions 432236 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432237 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432238 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-25 20:47:39 +00:00
Richard Mudgett 57525c3cf2 config.h: Use real parameter names for ast_variable_new() define.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432220 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-24 23:00:24 +00:00
Matthew Jordan 8574c4d197 channels/chan_sip: Fix crash when transmitting packet after thread shutdown
When the monitor thread is stopped, its pthread ID is set to a specific value
(AST_PTHREADT_STOP) so that later portions of the code can determine whether
or not it is safe to manipulate the thread. Unfortunately, __sip_reliable_xmit
failed to check for that value, checking instead only for AST_PTHREAD_STOP.
Passing the invalid yet very specific value to pthread_kill causes a crash.

This patch adds a check for AST_PTHREADT_STOP in __sip_reliable_xmit such that
it doesn't attempt to poke the thread if the thread has already been stopped.

ASTERISK-24800 #close
Reported by: JoshE
........

Merged revisions 432198 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432199 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432200 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-24 22:14:44 +00:00
Matthew Jordan a528dfc9a7 ARI/PJSIP: Apply requesting channel's format cap to created channels
This patch addresses the following problems:
* ari/resource_channels: In ARI, we currently create a format capability
  structure of SLIN and apply it to the new channel being created. This was
  originally done when the PBX core was used to create the channel, as there
  was a condition where a newly created channel could be created without any
  formats. Unfortunately, now that the Dial API is being used, this has two
  drawbacks:
  (a) SLIN, while it will ensure audio will flows, can cause a lot of
      needless transcodings to occur, particularly when a Local channel is
      created to the dialplan. When no format capabilities are available, the
      Dial API handles this better by handing all audio formats to the requsted
      channels. As such, we defer to that API to provide the format
      capabilities.
  (b) If a channel (requester) is causing this channel to be created, we
      currently don't use its format capabilities as we are passing in our own.
      However, the Dial API will use the requester channel's formats if none
      are passed into it, and the requester channel exists and has format
      capabilities. This is the "best" scenario, as it is the most likely to
      create a media path that minimizes transcoding.
  Fixing this simply entails removing the providing of the format capabilities
  structure to the Dial API.

* chan_pjsip: Rather than blindly picking the first format in the format
  capability structure - which actually *can* be a video or text format - we
  select an audio format, and only pick the first format if that fails. That
  minimizes the weird scenario where we attempt to transcode between video/audio.

* res_pjsip_sdp_rtp: Applied the joint capapbilites to the format structure.
  Since ast_request already limits us down to one format capability once the
  format capabilities are passed along, there's no reason to squelch it here.

* channel: Fixed a comment. The reason we have to minimize our requested
  format capabilities down to a single format is due to Asterisk's inability
  to convey the format to be used back "up" a channel chain. Consider the
  following:

    PJSIP/A => L;1 <=> L;2 => PJSIP/B
    g,u,a     g,u,a    g,u,a      u

  That is, we have PJSIP/A dialing a Local channel, where the Local;2 dials
  PJSIP/B. PJSIP/A has native format capabilities g722,ulaw,alaw; the Local
  channel has inherited those format capabilities down the line; PJSIP/B
  supports only ulaw. According to these format capabilities, ulaw is
  acceptable and should be selected across all the channels, and no
  transcoding should occur. However, there is no way to convey this: when L;2
  and PJSIP/B are put into a bridge, we will select ulaw, but that is not
  conveyed to PJSIP/A and L;1. Thus, we end up with:

    PJSIP/A <=> L;1 <=> L;2 <=> PJSIP/B
      g          g   X   u        u

  Which causes g722 to be written to PJSIP/B.

  Even if we can convey the 'ulaw' choice back up the chain (which through
  some severe hacking in Local channels was accomplished), such that the chain
  looks like:

    PJSIP/A <=> L;1 <=> L;2 <=> PJSIP/B
      u          u       u         u

  We have no way to tell PJSIP/A's *channel driver* to Answer in the SDP back
  with only 'ulaw'. This results in all the channel structures being set up
  correctly, but PJSIP/A *still* sending g722 and causing the chain to fall
  apart.

  There's a lot of difficulty just in setting this up, as there are numerous
  race conditions in the act of bridging, and no clean mechanism to pass the
  selected format backwards down an established channel chain. As such, the
  best that can be done at this point in time is clarifying the comment.

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

ASTERISK-24812 #close
Reported by: Matt Jordan
........

Merged revisions 432195 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432196 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-24 22:00:51 +00:00
Kevin Harwell 91733b5d15 bridge_softmix: G.729 codec license held
When more than one call using the same codec type enters into a softmix bridge
and no audio is present for a channel the bridge optimizes the out frame by
using the same one for all channels with the same codec type. Unfortunately,
when that number (channels with same codec type) dropped to <= 1 the codec
was not dereferenced. At least not until all parties left the bridge. Thus in
the case of G.729 the license was not released. This patch ensures that the
codec is dereferenced immediately when the optimization no longer applies.

ASTERISK-24797 #close
Reported by: Luke Hulsey
Review: https://reviewboard.asterisk.org/r/4429/
........

Merged revisions 432174 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432175 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432176 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-24 18:38:03 +00:00
Joshua Colp bedf51b2ce res_ari_channels: Return a 404 response when a requested channel variable does not exist.
This change makes it so that if a channel variable is requested and it does not exist
a 404 response will be returned instead of an allocation failed response. This makes
it easier to debug and figure out what is going on for a user.

ASTERISK-24677 #close
Reported by: Joshua Colp
........

Merged revisions 432154 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432155 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-21 20:48:17 +00:00
Joshua Colp 87b7060f36 res_pjsip_registrar: Add Expires header to 200 OK if present in REGISTER.
Some implementations don't pay attention to the expires for individual contacts.
In this case they may consider the lack of an Expires header in the 200 OK as
unregistered. This change makes it so if an Expires header is present in the REGISTER
we will add one in the 200 OK.

ASTERISK-24785 #close
Reported by: Ross Beer
........

Merged revisions 432136 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432137 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-21 19:28:09 +00:00
Joshua Colp 283bb15c16 res_pjsip: Add a log message when creating a UAC dialog to a target URI that is invalid.
ASTERISK-24499 #close
Reported by: Rusty Newton
........

Merged revisions 432118 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432119 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-21 18:53:34 +00:00
Matthew Jordan b3c1ad5d73 apps/app_voicemail: Demote an ERROR message to a WARNING message
When using IMAP voicemail with FreePBX, you will often get ERROR messages
complaining about not being able to find a mailbox. This is due to how FreePBX
handles voicemail mailboxes. Unfortunately, app_voicemail has to consider this
a configuration error, as in any other system it would be indicative of
someone misconfiguring their system.

Regardless, a misconfiguration is a WARNING, and not an ERROR. This patch
demotes the message so that system administrators can hopefully reduce some
of the noise in their log files.

Note that in the original patch this was made into a NOTICE, but that's a
too forgiving.

ASTERISK-24790 #close
Reported by: Graham Barnett
patches:
  app_voicemail.c.patch_noise uploaded by Graham Barnett (License 6685)
........

Merged revisions 432098 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432099 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432100 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-21 17:36:39 +00:00
Joshua Colp 2ea7ccbf70 http: Add missing html tag to 'httpstatus' functionality.
ASTERISK-24724 #close
Reported by: Ashley Sanders
........

Merged revisions 432078 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432079 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432080 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-21 14:06:20 +00:00
Corey Farrell e66b874f5d Allow shutdown to unload modules that register bucket scheme's or codec's.
* Change __ast_module_shutdown_ref to be NULL safe (11+).
* Allow modules that call ast_bucket_scheme_register or ast_codec_register
  to be unloaded during graceful shutdown only (13+ only).

ASTERISK-24796 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4428/
........

Merged revisions 432058 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432059 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432060 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-21 02:58:19 +00:00
Corey Farrell bb71672a47 main/asterisk.c: Reverse #if statement in listener() to fix code folding.
listener() opens the same code block in two places (#if and #else).  This
confuses some folding editors causing it to think that an extra code block
was opened.  Folding in 'geany' causes all code after listener() to be
folded as if it were part of that procedure.

ASTERISK-24813 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4435/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432057 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-21 02:51:35 +00:00
Corey Farrell ce50fa314a asterisk/lock.h: Fix syntax errors for non-gcc OSX with 64-bit integers.
Add a couple of missing closing brackets / parenthesis.

ASTERISK-24814 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4436/
........

Merged revisions 432054 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432055 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432056 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-21 02:47:44 +00:00
Richard Mudgett bb06603d5f chan_dahdi/sig_analog: Put log message strings on one line.
With the log messages on one line, you can search for the log message seen
in the log and expect to find it.
........

Merged revisions 432032 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432034 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432036 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-20 17:55:41 +00:00
George Joseph 340818ad12 ASTERISK-24811: Add ast_sorcery_apply_config() to res_pjsip_publish_asterisk.
Matt Hoskins reported that res_pjsip_publish_asterisk wouldn't pull config from 
realtime.  Turns out it was just missing a call ast_sorcery_apply_config().

res_pjsip_acl was missing it as well, so I added it.  The other pjsip modules 
looked OK.

ASTERISK-24811 #close
Reported-by: Matt Hoskins
Tested-by: George Joseph
Tested-by: Matt Hoskins
patches:
	res_pjsip_publish_asterisk.c.patch submitted by Matt Hoskins (license 6688)

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

Merged revisions 432033 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432035 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-20 17:53:33 +00:00
Matthew Jordan 4dab71831f apps/app_voicemail: Fix IMAP header compatibility issue with Microsoft Exchange
When interfacing with Microsoft Exchange, custom headers will be returned as
all lower case. Currently, the IMAP header code will fail to parse the returned
custom headers, as it will be performing a case sensitive comparison. This can
cause playback of messages to fail, as needed information - such as origtime -
will not be present.

This patch updates app_voicemail's header parsing code to perform a case
insensitive lookup for the requested custom headers. Since the headers are
specific to Asterisk, e.g., 'x-asterisk-vm-orig-time', and headers should be
unique in an IMAP message, this should cause no issues with other systems.

ASTERISK-24787 #close
Reported by: Graham Barnett
patches:
  app_voicemail.c.patch_MSExchange uploaded by Graham Barnett (License 6685)
........

Merged revisions 432012 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 432013 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432014 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-20 15:47:46 +00:00
Richard Mudgett 05cc6d6d55 chan_dahdi: Remove some dead code.
........

Merged revisions 431992 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 431993 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431994 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-19 21:26:55 +00:00
Richard Mudgett 252aee4228 ISDN AOC: Fix crash from an AOC-E message that doesn't have a channel association.
Processing an AOC-E event that does not or no longer has a channel
association causes a crash.

The problem with posting AOC events to the channel topic is that AOC-E
events don't always have a channel association and posting the event to
the all channels topic is just wrong.  AOC-E events do however have their
own charging association method to refer to the agreement with the
charging entity.

* Changed the AOC events to post to the AMI manager topic instead of the
channel topics.  If a channel is associated with the event then channel
snapshot information is supplied with the AMI event.

* Eliminated RAII_VAR() usage in aoc_to_ami() and ast_aoc_manager_event().

This patch supercedes the patch on Review: https://reviewboard.asterisk.org/r/4427/

ASTERISK-22670 #close
Reported by: klaus3000

ASTERISK-24689 #close
Reported by: Marcel Manz

ASTERISK-24740 #close
Reported by: Panos Gkikakis

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

Merged revisions 431974 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431975 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-19 18:26:49 +00:00
Richard Mudgett 6992b2e8fa res_pjsip_refer: Handle INVITE with Replaces failure after answer.
* Fixed hangup handling of the session->channel after answer if the
ast_channel_move() or ast_bridge_impart() fails.  We are still the thread
controlling the session->channel so we need to call ast_hangup() to kill
the channel.

* Fixed debug messages in refer_incoming_invite_request() referencing
incorrect channnels on success.  Code comments now say why the
session->channel cannot be used.

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

Merged revisions 431956 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-19 17:37:00 +00:00
Matthew Jordan e3fd826cdb tcptls: Handle new OpenSSL compile time option to disable SSLv3
Some distributions are going to disable SSLv3 at compile time. This option can
be checked using the directive OPENSSL_NO_SSL3_METHOD. This patch updates the
TCP/TLS handling in Asterisk to look for that directive before attempting to
use the SSLv3 specific methods.

ASTERISK-24799 #close
Reported by: Alexander Traud
patches:
  no-ssl3-method.patch uploaded by Alexander Traud (License 6520)
........

Merged revisions 431936 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 431937 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431938 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-19 15:28:56 +00:00
Corey Farrell a4774ceaa5 Create work around for scheduler leaks during shutdown.
* Added ast_sched_clean_by_callback for cleanup of scheduled events
  that have not yet fired.
* Run all pending peercnt_remove_cb and replace_callno events in chan_iax2.
  Cleanup of replace_callno events is only run 11, since it no longer
  releases any references or allocations in 13+.

ASTERISK-24451 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4425/
........

Merged revisions 431916 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 431917 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431918 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-19 02:03:01 +00:00
Richard Mudgett 09bfe4b208 res_pjsip_refer: Fix crash from a REFER and BYE collision.
Analyzing a one-off crash on a busy system showed that processing a REFER
request had a NULL session channel pointer.  The only way I can think of
that could cause this is if an outgoing BYE transaction overlapped the
incoming REFER transaction in a collision.  Asterisk sends a BYE while the
phone sends a REFER to complete an attended transfer.

* Made check the session channel pointer before processing an incoming
REFER request in res_pjsip_refer.

* Fixed similar crash potential for res_pjsip supplement incoming request
processing for res_pjsip_sdp_rtp INFO, res_pjsip_caller_id INVITE/UPDATE,
res_pjsip_messaging MESSAGE, and res_pjsip_send_to_voicemail REFER
messages.

* Made res_pjsip_messaging respond to a message body too large with a 413
instead of ignoring it.

ASTERISK-24700 #close
Reported by: Zane Conkle

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

Merged revisions 431898 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431899 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-17 15:34:10 +00:00
Matthew Jordan d808eace5c res/res_rtp_asterisk: Fix crash in debug from RTCP reports without report block
When RTCP debugging was enabled, an RTCP report without a report block would
cause a crash. This was due to the verbose output not checking to see if the
report_block pointer was NULl before dereferencing it.

This patch adds the necessary check to prevent printing any verbose output
if the far side hasn't provided us the information they should have.

ASTERISK-24791 #close
Reported by: JoshE
Tested by: JoshE
........

Merged revisions 431879 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431880 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-16 21:29:39 +00:00
Joshua Colp 55eb8fc068 pjsip: Remove "contact" type from pjsip.conf.sample
The "contact" object is not meant to be configured from the pjsip.conf
configuration file. It is meant to be created as a result of a registration
and stored elsewhere.

ASTERISK-24085 #close
Reported by: Rusty Newton
........

Merged revisions 431860 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431861 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-15 19:01:44 +00:00
Joshua Colp 55709bc1f7 install_prereq: Tweak flags when configuring pjproject.
This change does two things:
1. Disables debugging so assertions which can return an error do,
instead of asserting.
2. Enables IPv6 support.

ASTERISK-24632 #close
Reported by: Rusty Newton
........

Merged revisions 431843 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431844 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-15 18:00:18 +00:00
Joshua Colp e78dd39885 res_sorcery_config: Improve object lookup times.
The res_sorcery_config module currently uses a fixed bucket
size of 53. This means that depending on the number of objects
you either end up with excess buckets or a lot of collisions.
Due to the way that res_sorcery_config is implemented it's actually
possible to make the bucket size dynamic based on the number of
objects. This is due to the fact that each loading of the config file
produces a new container and does not modify the existing one.
This change uses the number of expected objects and finds a prime
number near it. In practice depending on the number of objects this
can speed up lookups anywhere from 2X to 15X. This change also removes
the lock from the container as it is not needed.

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

Merged revisions 431841 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431842 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-15 17:43:21 +00:00
Joshua Colp e6fe69b76c res_pjsip: Add "pjsip show version" CLI command.
When debugging things it can be useful to know absolutely what
version of pjproject res_pjsip is running against. This change
adds a "pjsip show version" CLI command which can be used to
query for this.

ASTERISK-24685 #close
Reported by: Joshua Colp

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

Merged revisions 431824 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431825 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-15 16:01:09 +00:00
Joshua Colp 17f9e0cacc res_timing_pthread: Fix leaky pipes.
During some refactoring the way private information for timers
was stored was changed. As a result of this the action which normally
removed the timer upon closure in res_timing_pthread was also removed
causing the timer to remain after it should using up resources.
This change ensures that the timer is removed upon closure.

ASTERISK-24768 #close
Reported by: Matthias Urlichs
patches:
 timer.patch submitted by Matthias Urlichs (license 5508)
........

Merged revisions 431807 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431808 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-15 12:41:06 +00:00